From 5e6cb6cbd10fe265a89e30d5c923c3cb16dd7273 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 27 May 2015 11:47:53 +0300 Subject: [PATCH] Server does not reply with clTRID when not specified in request --- app/views/epp/shared/_trID.xml.builder | 2 +- spec/epp/domain_spec.rb | 2 +- spec/epp/session_spec.rb | 7 +++++++ spec/support/epp.rb | 18 +++++++++--------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/views/epp/shared/_trID.xml.builder b/app/views/epp/shared/_trID.xml.builder index 5d59baa0c..995c27c05 100644 --- a/app/views/epp/shared/_trID.xml.builder +++ b/app/views/epp/shared/_trID.xml.builder @@ -1,4 +1,4 @@ xml.trID do - xml.clTRID params[:clTRID] + xml.clTRID params[:clTRID] if params[:clTRID].present? xml.svTRID @svTRID end diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 4078f5dd0..b886e229e 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1931,10 +1931,10 @@ describe 'EPP Domain', epp: true do domain.save xml = domain_info_xml(name: { value: domain.name }) - response = epp_plain_request(xml, :xml) response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:result_code].should == '1000' + response[:clTRID].should be_nil inf_data = response[:parsed].css('resData infData') inf_data.css('name').text.should == domain.name diff --git a/spec/epp/session_spec.rb b/spec/epp/session_spec.rb index 85d536b16..4f4cde6c4 100644 --- a/spec/epp/session_spec.rb +++ b/spec/epp/session_spec.rb @@ -46,6 +46,13 @@ describe 'EPP Session', epp: true do response[:clTRID].should == 'ABC-12345' end + it 'should not have clTRID in response if client does not send it' do + epp_xml_no_cltrid = EppXml.new(cl_trid: '') + wrong_user = epp_xml_no_cltrid.session.login(clID: { value: 'wrong-user' }, pw: { value: 'ghyt9e4fu' }) + response = epp_plain_request(wrong_user, :xml) + response[:clTRID].should be_nil + end + context 'with valid user' do it 'logs in epp user' do response = epp_plain_request(@login_xml_cache, :xml) diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 052074ca0..f877bfc2f 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -31,14 +31,14 @@ module Epp @xml ||= EppXml.new(cl_trid: 'ABC-12345') case user when :gitlab - @gitlab_login_xml ||= - @xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' }) + @gitlab_login_xml ||= + @xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' }) when :registrar1 - @registrar1_login_xml ||= - @xml.session.login(clID: { value: 'registrar1' }, pw: { value: 'ghyt9e4fu' }) + @registrar1_login_xml ||= + @xml.session.login(clID: { value: 'registrar1' }, pw: { value: 'ghyt9e4fu' }) when :registrar2 - @registrar2_login_xml ||= - @xml.session.login(clID: { value: 'registrar2' }, pw: { value: 'ghyt9e4fu' }) + @registrar2_login_xml ||= + @xml.session.login(clID: { value: 'registrar2' }, pw: { value: 'ghyt9e4fu' }) end end @@ -78,7 +78,7 @@ module Epp rescue => e e end - + def server # tag and password not in use, add those at login xml @server ||= Epp::Server.new({ server: 'localhost', port: 701, tag: '', password: '' }) @@ -89,7 +89,7 @@ module Epp obj = { results: [], - clTRID: res.css('epp trID clTRID').text, + clTRID: res.css('epp trID clTRID').first.try(:text), parsed: res.remove_namespaces!, raw: raw } @@ -127,7 +127,7 @@ module Epp xml_params = defaults.deep_merge(xml_params) - epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345') + epp_xml = EppXml::Domain.new(cl_trid: '') epp_xml.info(xml_params) end