From 340ca96d1eefffdcee8d6c8185413b9d6d742e1c Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 28 May 2015 17:02:59 +0300 Subject: [PATCH] Added more epp tests about domain verify logic #2557 --- spec/epp/domain_spec.rb | 77 ++++++++++++++++++++++++++++++++++++++ spec/models/domain_spec.rb | 21 +++++++++++ 2 files changed, 98 insertions(+) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 0440e6995..f222f5abb 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1411,6 +1411,83 @@ describe 'EPP Domain', epp: true do d.pending_update?.should == true end + it 'should not return action pending when changes are invalid' do + existing_pw = domain.auth_info + + xml_params = { + name: { value: domain.name }, + chg: [ + registrant: { value: 'FIXED:CITIZEN_1234' } + ], + rem: + domain.nameservers.map do |ns| + { + ns: [ + { + hostAttr: [ + { hostName: { value: ns.hostname } } + ] + } + ] + } + end + } + + response = epp_plain_request(domain_update_xml(xml_params, {}, { + _anonymus: [ + legalDocument: { + value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==', + attrs: { type: 'pdf' } + } + ] + }), :xml) + + response[:results][0][:msg].should == 'Nameservers count must be between 2-11 [nameservers]' + response[:results][0][:result_code].should == '2004' + + d = Domain.last + + d.registrant_code.should_not == 'FIXED:CITIZEN_1234' # should not update, because pending + d.auth_info.should == existing_pw + d.nameservers.size == 3 + d.pending_update?.should == false + end + + it 'should not return action pending when domain itself is already invaid' do + domain_id = domain.id + domain.nameservers.delete_all + domain.save(validate: false) + domain.reload.nameservers.size.should == 0 + + existing_pw = domain.auth_info + + xml_params = { + name: { value: domain.name }, + chg: [ + registrant: { value: 'FIXED:CITIZEN_1234' } + ] + } + + response = epp_plain_request(domain_update_xml(xml_params, {}, { + _anonymus: [ + legalDocument: { + value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==', + attrs: { type: 'pdf' } + } + ] + }), :xml) + + response[:results][0][:msg].should == 'Nameservers count must be between 2-11 [nameservers]' + response[:results][0][:result_code].should == '2004' + + d = Domain.find(domain_id) + + d.registrant_code.should_not == 'FIXED:CITIZEN_1234' # should not update, because pending + d.auth_info.should == existing_pw + d.nameservers.size.should == 0 + d.pending_update?.should == false + end + it 'should not allow any update when status pending update' do domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE) diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 56d9ee57f..741721f4e 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -106,6 +106,27 @@ describe Domain do end end + context 'about registrant update confirm when domain is invalid' do + before :all do + @domain.registrant_verification_token = 123 + @domain.registrant_verification_asked_at = Time.zone.now + @domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE) + end + + it 'should be registrant update confirm ready' do + @domain.registrant_update_confirmable?('123').should == true + end + + it 'should not be registrant update confirm ready when token does not match' do + @domain.registrant_update_confirmable?('wrong-token').should == false + end + + it 'should not be registrant update confirm ready when no correct status' do + @domain.domain_statuses.delete_all + @domain.registrant_update_confirmable?('123').should == false + end + end + context 'with versioning' do it 'should not have one version' do with_versioning do