Logout command

This commit is contained in:
Martin Lensment 2014-06-25 13:13:16 +03:00
parent b812ea384e
commit 44b257efa3
11 changed files with 90 additions and 1 deletions

View file

@ -12,4 +12,8 @@ module Epp::Common
def parsed_frame
Nokogiri::XML(params[:frame]).remove_namespaces!
end
def error
render 'error'
end
end

View file

@ -0,0 +1,8 @@
class Epp::CommandsController < ApplicationController
include Epp::Common
private
def create
render '/epp/domains/create'
end
end

View file

@ -17,4 +17,9 @@ class Epp::SessionsController < ApplicationController
render 'login_fail'
end
end
def logout
response.headers['X-EPP-Returncode'] = '1500'
render 'logout'
end
end

View file

@ -0,0 +1,8 @@
xml.instruct!
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do
xml.response do
xml.result('code' => '1000') do
xml.msg('Command completed successfully')
end
end
end

View file

View file

@ -0,0 +1,12 @@
xml.instruct!
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do
xml.response do
xml.result('code' => '1500') do
xml.msg('Command completed successfully; ending session', 'lang' => 'en')
end
end
xml.trID do
xml.clTRID 'sample1trid'
end
end

View file

@ -1,6 +1,7 @@
Rails.application.routes.draw do
namespace(:epp) do
match 'session/:command', to: 'sessions#proxy', defaults: { format: :xml }, via: [:get, :post]
match 'command/:command', to: 'commands#proxy', defaults: { format: :xml }, via: [:post, :get]
end
# The priority is based upon order of creation: first created -> highest priority.

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="http://www.nic.cz/xml/epp/domain-1.4" xsi:schemaLocation="http://www.nic.cz/xml/epp/domain-1.4 domain-1.4.xsd">
<domain:name>testing.ee</domain:name>
<domain:period unit="y">1</domain:period>
<domain:nsset>name_server_set1</domain:nsset>
<domain:registrant>domain_registrator1</domain:registrant>
<domain:admin>administrative_contact1</domain:admin>
<domain:authInfo>password</domain:authInfo>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="urn:ee:eis:xml:epp:eis-1.0" xsi:schemaLocation="urn:ee:eis:xml:epp:eis-1.0 eis-1.0.xsd">
<eis:legalDocument type="ddoc">.... base64 encoded document ....</eis:legalDocument>
</eis:extdata>
</extension>
<clTRID>dpbx005#10-01-29at19:21:47</clTRID>
</command>
</epp>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<logout/>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -30,6 +30,14 @@ describe 'EPP Session', epp: true do
expect(result[:code]).to eq('2501')
end
it 'prohibits further actions unless logged in' do
response = Nokogiri::XML(server.send_request(read_body('create_domain.xml')))
expect(parse_result_code(response)).to eq('2002')
msg = response.css('epp response result msg').text
expect(msg).to eq('You need to login first.')
end
it 'logs in epp user' do
Fabricate(:epp_user)
@ -42,6 +50,17 @@ describe 'EPP Session', epp: true do
expect(msg).to eq('Command completed successfully')
end
it 'logs out epp user' do
Fabricate(:epp_user)
server.send_request(read_body('login.xml'))
response = Nokogiri::XML(server.send_request(read_body('logout.xml')))
result = response.css('epp response result').first
expect(result[:code]).to eq('1500')
msg = response.css('epp response result msg').text
expect(msg).to eq('Command completed successfully; ending session')
end
it 'does not log in twice' do
Fabricate(:epp_user)
server.send_request(read_body('login.xml'))

View file

@ -1,7 +1,11 @@
module Epp
def read_body(filename)
def read_body filename
File.read("spec/epp/requests/#{filename}")
end
def parse_result_code response
response.css('epp response result').first[:code]
end
end
RSpec.configure do |c|