Added more epp tests about domain verify logic #2557

This commit is contained in:
Priit Tark 2015-05-28 17:02:59 +03:00
parent 573349d0b6
commit 340ca96d1e
2 changed files with 98 additions and 0 deletions

View file

@ -1411,6 +1411,83 @@ describe 'EPP Domain', epp: true do
d.pending_update?.should == true d.pending_update?.should == true
end 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 it 'should not allow any update when status pending update' do
domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE) domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE)

View file

@ -106,6 +106,27 @@ describe Domain do
end end
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 context 'with versioning' do
it 'should not have one version' do it 'should not have one version' do
with_versioning do with_versioning do