diff --git a/README.md b/README.md index 9b813357e..5e0e2b5ce 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,8 @@ For development configuration, add: SetHandler cgi-script - Listen 700 - + Listen 701 + SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile /etc/apache2/ssl/apache.crt @@ -89,6 +89,8 @@ For development configuration, add: ``` +Note: Its best to go with two virtual hosts, one for test and one for dev, then you don't have to worry about quitting the dev appserver for running tests (because of colliding ports). + For plain TCP EPP configuration, see below (may be useful for debugging purposes). * `sudo a2ensite epp_ssl` @@ -98,7 +100,7 @@ Try it out: * Fire up your appserver on port 8989 (This setup is tested with Unicorn) * `cd $mod_epp` -* `./epptelnet.pl localhost 700 -s` +* `./epptelnet.pl localhost 701 -s` You should receive the greeting from the registry server. Wait for the greeting message on the STD, then send EPP/TCP frame: diff --git a/app/controllers/epp/commands_controller.rb b/app/controllers/epp/commands_controller.rb index 03c4d54cf..8b121fe68 100644 --- a/app/controllers/epp/commands_controller.rb +++ b/app/controllers/epp/commands_controller.rb @@ -12,4 +12,9 @@ class Epp::CommandsController < ApplicationController type = OBJECT_TYPES[parsed_frame.css('create create').attr('schemaLocation').value] send("create_#{type}") end + + def check + type = OBJECT_TYPES[parsed_frame.css('check check').attr('schemaLocation').value] + send("check_#{type}") + end end diff --git a/app/helpers/epp/commands_helper.rb b/app/helpers/epp/commands_helper.rb index e4f6b4f47..eab4e1e09 100644 --- a/app/helpers/epp/commands_helper.rb +++ b/app/helpers/epp/commands_helper.rb @@ -1,6 +1,6 @@ module Epp::CommandsHelper - def command_params - node_set = parsed_frame.css('epp command create create').children.select(&:element?) + def command_params_for type + node_set = parsed_frame.css("epp command #{type} #{type}").children.select(&:element?) node_set.inject({}) {|hash, obj| hash[obj.name.to_sym] = obj.text;hash } end end diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb index b0fbe32ae..892582dc1 100644 --- a/app/helpers/epp/domains_helper.rb +++ b/app/helpers/epp/domains_helper.rb @@ -4,8 +4,17 @@ module Epp::DomainsHelper render '/epp/domains/create' end + def check_domain + cp = command_params_for('check') + @domain = cp[:name] + + render '/epp/domains/check' + end + + ### HELPER METHODS ### + def domain_params - cp = command_params + cp = command_params_for('create') { name: cp[:name], registrar_id: current_epp_user.registrar.try(:id), diff --git a/app/views/epp/domains/check.xml.builder b/app/views/epp/domains/check.xml.builder index 2a7be9f38..da955e0cb 100644 --- a/app/views/epp/domains/check.xml.builder +++ b/app/views/epp/domains/check.xml.builder @@ -1,3 +1,17 @@ xml.epp_head do - xml.bla + xml.response do + xml.result('code' => '1000') do + xml.msg 'Command completed successfully' + end + + xml.resData do + xml.tag!('domain:chkData', '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') do + xml.tag!('domain:cd') do + xml.tag!('domain:name', @domain, 'avail' => 1) + end + end + end + + xml << render('/epp/shared/trID') + end end diff --git a/app/views/epp/shared/_trID.xml.builder b/app/views/epp/shared/_trID.xml.builder new file mode 100644 index 000000000..5d59baa0c --- /dev/null +++ b/app/views/epp/shared/_trID.xml.builder @@ -0,0 +1,4 @@ +xml.trID do + xml.clTRID params[:clTRID] + xml.svTRID @svTRID +end diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index d0c141335..331a3d354 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe 'EPP Domain', epp: true do - let(:server) { server = Epp::Server.new({server: 'localhost', tag: 'test', password: 'test'}) } + let(:server) { server = Epp::Server.new({server: 'localhost', tag: 'test', password: 'test', port: 701}) } context 'with valid user' do before(:each) { Fabricate(:epp_user) } @@ -14,5 +14,11 @@ describe 'EPP Domain', epp: true do expect(Domain.first.registrar.name).to eq('Zone Media OÜ') end + it 'checks domain' do + response = epp_request('domains/check.xml') + expect(response[:result_code]).to eq('1000') + expect(response[:msg]).to eq('Command completed successfully') + end + end end diff --git a/spec/epp/session_spec.rb b/spec/epp/session_spec.rb index d7d7cd6f6..9c7b05818 100644 --- a/spec/epp/session_spec.rb +++ b/spec/epp/session_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe 'EPP Session', epp: true do - let(:server) { server = Epp::Server.new({server: 'localhost', tag: 'test', password: 'test'}) } + let(:server) { server = Epp::Server.new({server: 'localhost', tag: 'test', password: 'test', port: 701}) } context 'when not connected' do it 'greets client upon connection' do