Require legal doc on domain delete

This commit is contained in:
Martin Lensment 2015-01-02 18:14:58 +02:00
parent 56c923c988
commit 1996ff725e
2 changed files with 33 additions and 7 deletions

View file

@ -174,8 +174,7 @@ module Epp::DomainsHelper
## DELETE ## DELETE
def validate_domain_delete_request def validate_domain_delete_request
@ph = params_hash['epp']['command']['delete']['delete'] epp_request_valid?('name', 'legalDocument')
xml_attrs_present?(@ph, [['name']])
end end
## SHARED ## SHARED
@ -192,14 +191,13 @@ module Epp::DomainsHelper
return nil return nil
end end
@ph[:authInfo] ||= {} return domain if domain.auth_info == parsed_frame.css('authInfo pw').text
return domain if domain.auth_info == @ph[:authInfo][:pw]
if (domain.registrar != current_epp_user.registrar && secure[:secure] == true) && if (domain.registrar != current_epp_user.registrar && secure[:secure] == true) &&
epp_errors << { epp_errors << {
code: '2302', code: '2302',
msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'), msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'),
value: { obj: 'name', val: @ph[:name].strip.downcase } value: { obj: 'name', val: parsed_frame.css('name').text.strip.downcase }
} }
return nil return nil
end end

View file

@ -1191,7 +1191,18 @@ describe 'EPP Domain', epp: true do
it 'deletes domain' do it 'deletes domain' do
expect(DomainContact.count).to eq(2) expect(DomainContact.count).to eq(2)
response = epp_request(epp_xml.domain.delete(name: { value: 'example.ee' }), :xml)
response = epp_request(epp_xml.domain.delete({
name: { value: 'example.ee' }
}, {
_anonymus: [
legalDocument: {
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
attrs: { type: 'pdf' }
}
]
}), :xml)
expect(response[:result_code]).to eq('1000') expect(response[:result_code]).to eq('1000')
expect(Domain.first).to eq(nil) expect(Domain.first).to eq(nil)
@ -1201,10 +1212,27 @@ describe 'EPP Domain', epp: true do
it 'does not delete domain with specific status' do it 'does not delete domain with specific status' do
d = Domain.first d = Domain.first
d.domain_statuses.create(value: DomainStatus::CLIENT_DELETE_PROHIBITED) d.domain_statuses.create(value: DomainStatus::CLIENT_DELETE_PROHIBITED)
response = epp_request(epp_xml.domain.delete(name: { value: 'example.ee' }), :xml)
response = epp_request(epp_xml.domain.delete({
name: { value: 'example.ee' }
}, {
_anonymus: [
legalDocument: {
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
attrs: { type: 'pdf' }
}
]
}), :xml)
expect(response[:result_code]).to eq('2304') expect(response[:result_code]).to eq('2304')
expect(response[:msg]).to eq('Domain status prohibits operation') expect(response[:msg]).to eq('Domain status prohibits operation')
end end
it 'does not delete domain without legal document' do
response = epp_request(epp_xml.domain.delete(name: { value: 'example.ee' }), :xml)
expect(response[:result_code]).to eq('2003')
expect(response[:msg]).to eq('Required parameter missing: legalDocument')
end
end end
it 'checks a domain' do it 'checks a domain' do