mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
Logout command
This commit is contained in:
parent
b812ea384e
commit
44b257efa3
11 changed files with 90 additions and 1 deletions
|
@ -12,4 +12,8 @@ module Epp::Common
|
||||||
def parsed_frame
|
def parsed_frame
|
||||||
Nokogiri::XML(params[:frame]).remove_namespaces!
|
Nokogiri::XML(params[:frame]).remove_namespaces!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def error
|
||||||
|
render 'error'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
8
app/controllers/epp/commands_controller.rb
Normal file
8
app/controllers/epp/commands_controller.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class Epp::CommandsController < ApplicationController
|
||||||
|
include Epp::Common
|
||||||
|
|
||||||
|
private
|
||||||
|
def create
|
||||||
|
render '/epp/domains/create'
|
||||||
|
end
|
||||||
|
end
|
|
@ -17,4 +17,9 @@ class Epp::SessionsController < ApplicationController
|
||||||
render 'login_fail'
|
render 'login_fail'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def logout
|
||||||
|
response.headers['X-EPP-Returncode'] = '1500'
|
||||||
|
render 'logout'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
8
app/views/epp/domains/create.xml.builder
Normal file
8
app/views/epp/domains/create.xml.builder
Normal 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
|
0
app/views/epp/error.xml.builder
Normal file
0
app/views/epp/error.xml.builder
Normal file
12
app/views/epp/sessions/logout.xml.builder
Normal file
12
app/views/epp/sessions/logout.xml.builder
Normal 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
|
|
@ -1,6 +1,7 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
namespace(:epp) do
|
namespace(:epp) do
|
||||||
match 'session/:command', to: 'sessions#proxy', defaults: { format: :xml }, via: [:get, :post]
|
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
|
end
|
||||||
|
|
||||||
# The priority is based upon order of creation: first created -> highest priority.
|
# The priority is based upon order of creation: first created -> highest priority.
|
||||||
|
|
21
spec/epp/requests/create_domain.xml
Normal file
21
spec/epp/requests/create_domain.xml
Normal 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>
|
7
spec/epp/requests/logout.xml
Normal file
7
spec/epp/requests/logout.xml
Normal 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>
|
|
@ -30,6 +30,14 @@ describe 'EPP Session', epp: true do
|
||||||
expect(result[:code]).to eq('2501')
|
expect(result[:code]).to eq('2501')
|
||||||
end
|
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
|
it 'logs in epp user' do
|
||||||
Fabricate(:epp_user)
|
Fabricate(:epp_user)
|
||||||
|
|
||||||
|
@ -42,6 +50,17 @@ describe 'EPP Session', epp: true do
|
||||||
expect(msg).to eq('Command completed successfully')
|
expect(msg).to eq('Command completed successfully')
|
||||||
end
|
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
|
it 'does not log in twice' do
|
||||||
Fabricate(:epp_user)
|
Fabricate(:epp_user)
|
||||||
server.send_request(read_body('login.xml'))
|
server.send_request(read_body('login.xml'))
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
module Epp
|
module Epp
|
||||||
def read_body(filename)
|
def read_body filename
|
||||||
File.read("spec/epp/requests/#{filename}")
|
File.read("spec/epp/requests/#{filename}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parse_result_code response
|
||||||
|
response.css('epp response result').first[:code]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue