mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Algorithm validation for dnskey
This commit is contained in:
parent
17e1668794
commit
f776078214
3 changed files with 67 additions and 1 deletions
|
@ -1,3 +1,25 @@
|
|||
class Dnskey < ActiveRecord::Base
|
||||
include EppErrors
|
||||
|
||||
belongs_to :domain
|
||||
|
||||
validate :validate_algorithm
|
||||
|
||||
def epp_code_map
|
||||
{
|
||||
'2005' => [
|
||||
[:alg, :invalid, { value: { obj: 'alg', val: alg } }]
|
||||
],
|
||||
'2306' => [
|
||||
[:ipv4, :blank]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
def validate_algorithm
|
||||
return if %w(3 5 6 7 8 252 253 254 255).include?(alg.to_s)
|
||||
errors.add(:alg, :invalid)
|
||||
# , format: {with: /3|5|6/, message: :alg_invalid}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -183,6 +183,11 @@ en:
|
|||
registrar:
|
||||
blank: 'Registrar is missing'
|
||||
|
||||
dnskey:
|
||||
attributes:
|
||||
alg:
|
||||
invalid: 'Algorithm is invalid'
|
||||
|
||||
attributes:
|
||||
epp_domain: &epp_domain_attributes
|
||||
name: 'Domain name'
|
||||
|
|
|
@ -353,7 +353,7 @@ describe 'EPP Domain', epp: true do
|
|||
]
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml)
|
||||
epp_request(xml, :xml)
|
||||
d = Domain.first
|
||||
|
||||
expect(d.dnskeys.pluck(:flags)).to match_array([257, 0, 256])
|
||||
|
@ -365,6 +365,45 @@ describe 'EPP Domain', epp: true do
|
|||
841936717ae427ace63c28d04918569a841936717ae427ace63c28d0
|
||||
))
|
||||
end
|
||||
|
||||
it 'does not create a domain when dnskeys are invalid' do
|
||||
xml = domain_create_xml({
|
||||
dnssec: [
|
||||
{
|
||||
dnskey: {
|
||||
flags: { value: '257' },
|
||||
protocol: { value: '3' },
|
||||
alg: { value: '9' },
|
||||
pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
|
||||
}
|
||||
},
|
||||
{
|
||||
dnskey: {
|
||||
flags: { value: '0' },
|
||||
protocol: { value: '3' },
|
||||
alg: { value: '10' },
|
||||
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
||||
}
|
||||
},
|
||||
{
|
||||
dnskey: {
|
||||
flags: { value: '256' },
|
||||
protocol: { value: '3' },
|
||||
alg: { value: '254' },
|
||||
pubKey: { value: '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' }
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml)
|
||||
|
||||
expect(response[:results][0][:msg]).to eq('Algorithm is invalid')
|
||||
expect(response[:results][0][:value]).to eq('9')
|
||||
expect(response[:results][1][:msg]).to eq('Algorithm is invalid')
|
||||
expect(response[:results][1][:value]).to eq('10')
|
||||
po response
|
||||
end
|
||||
end
|
||||
|
||||
context 'with juridical persion as an owner' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue