mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
Improve contact ident validation
- Make country-specific national id and reg. no validations fully extendable - Fix wrong error type for reg. no validator #569
This commit is contained in:
parent
48ae6cf471
commit
52452f91bf
6 changed files with 103 additions and 34 deletions
|
@ -88,7 +88,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when code is invalid' do
|
||||
context 'when code is not valid national id' do
|
||||
let(:request_xml) { <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
|
@ -104,7 +104,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:ident type="priv" cc="EE">invalid</eis:ident>
|
||||
<eis:ident type="priv" cc="DE">invalid</eis:ident>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
|
@ -112,6 +112,15 @@ RSpec.describe 'EPP contact:create' do
|
|||
XML
|
||||
}
|
||||
|
||||
before do
|
||||
country_specific_validations = {
|
||||
Country.new('DE') => proc { false },
|
||||
}
|
||||
|
||||
allow(Contact::Ident::NationalIDValidator).to receive(:country_specific_validations)
|
||||
.and_return(country_specific_validations)
|
||||
end
|
||||
|
||||
it 'does not create a contact' do
|
||||
expect { request }.to_not change { Contact.count }
|
||||
end
|
||||
|
@ -119,11 +128,54 @@ RSpec.describe 'EPP contact:create' do
|
|||
specify do
|
||||
request
|
||||
|
||||
message = 'Ident code does not conform to national identification number format of Estonia'
|
||||
message = 'Ident code does not conform to national identification number format of Germany'
|
||||
expect(epp_response).to have_result(:param_syntax_error, message)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when code is not valid registration number' do
|
||||
let(:request_xml) { <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:postalInfo>
|
||||
<contact:name>test</contact:name>
|
||||
</contact:postalInfo>
|
||||
<contact:voice>+1.2</contact:voice>
|
||||
<contact:email>test@test.com</contact:email>
|
||||
</contact:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:ident type="org" cc="DE">invalid</eis:ident>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
}
|
||||
|
||||
before do
|
||||
country_specific_formats = {
|
||||
Country.new('DE') => /\Avalid\z/,
|
||||
}
|
||||
|
||||
allow(Contact::Ident::RegNoValidator).to receive(:country_specific_formats).and_return(country_specific_formats)
|
||||
end
|
||||
|
||||
it 'does not create a contact' do
|
||||
expect { request }.to_not change { Contact.count }
|
||||
end
|
||||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:param_syntax_error,
|
||||
'Ident code does not conform to registration number format of Germany')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when country code is absent' do
|
||||
let(:request_xml) { <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue