mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Validate flags an attributes presence on dnskey
This commit is contained in:
parent
e7644ea69d
commit
338a58a611
3 changed files with 35 additions and 9 deletions
|
@ -3,17 +3,23 @@ class Dnskey < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :domain
|
belongs_to :domain
|
||||||
|
|
||||||
|
validates :alg, :protocol, :flags, :public_key, presence: true
|
||||||
validate :validate_algorithm
|
validate :validate_algorithm
|
||||||
validate :validate_protocol
|
validate :validate_protocol
|
||||||
|
validate :validate_flags
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{
|
{
|
||||||
'2005' => [
|
'2005' => [
|
||||||
[:alg, :invalid, { value: { obj: 'alg', val: alg } }],
|
[:alg, :invalid, { value: { obj: 'alg', val: alg } }],
|
||||||
[:protocol, :invalid, { value: { obj: 'protocol', val: protocol } }],
|
[:protocol, :invalid, { value: { obj: 'protocol', val: protocol } }],
|
||||||
|
[:flags, :invalid, { value: { obj: 'flags', val: flags } }]
|
||||||
],
|
],
|
||||||
'2306' => [
|
'2306' => [
|
||||||
[:ipv4, :blank]
|
[:alg, :blank],
|
||||||
|
[:protocol, :blank],
|
||||||
|
[:flags, :blank],
|
||||||
|
[:public_key, :blank]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -27,4 +33,9 @@ class Dnskey < ActiveRecord::Base
|
||||||
return if %w(3).include?(protocol.to_s)
|
return if %w(3).include?(protocol.to_s)
|
||||||
errors.add(:protocol, :invalid)
|
errors.add(:protocol, :invalid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_flags
|
||||||
|
return if %w(0 256 257).include?(flags.to_s)
|
||||||
|
errors.add(:flags, :invalid)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -187,8 +187,16 @@ en:
|
||||||
attributes:
|
attributes:
|
||||||
alg:
|
alg:
|
||||||
invalid: 'Algorithm is invalid'
|
invalid: 'Algorithm is invalid'
|
||||||
|
blank: 'Algorithm is missing'
|
||||||
protocol:
|
protocol:
|
||||||
invalid: 'Protocol is invalid'
|
invalid: 'Protocol is invalid'
|
||||||
|
blank: 'Protocol is missing'
|
||||||
|
flags:
|
||||||
|
invalid: 'Flag is invalid'
|
||||||
|
blank: 'Flag is missing'
|
||||||
|
public_key:
|
||||||
|
blank: 'Public key is missing'
|
||||||
|
|
||||||
|
|
||||||
attributes:
|
attributes:
|
||||||
epp_domain: &epp_domain_attributes
|
epp_domain: &epp_domain_attributes
|
||||||
|
|
|
@ -371,7 +371,7 @@ describe 'EPP Domain', epp: true do
|
||||||
dnssec: [
|
dnssec: [
|
||||||
{
|
{
|
||||||
dnskey: {
|
dnskey: {
|
||||||
flags: { value: '257' },
|
flags: { value: '250' },
|
||||||
protocol: { value: '4' },
|
protocol: { value: '4' },
|
||||||
alg: { value: '9' },
|
alg: { value: '9' },
|
||||||
pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
|
pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
|
||||||
|
@ -379,7 +379,7 @@ describe 'EPP Domain', epp: true do
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dnskey: {
|
dnskey: {
|
||||||
flags: { value: '0' },
|
flags: { value: '1' },
|
||||||
protocol: { value: '3' },
|
protocol: { value: '3' },
|
||||||
alg: { value: '10' },
|
alg: { value: '10' },
|
||||||
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
||||||
|
@ -390,14 +390,13 @@ describe 'EPP Domain', epp: true do
|
||||||
flags: { value: '256' },
|
flags: { value: '256' },
|
||||||
protocol: { value: '5' },
|
protocol: { value: '5' },
|
||||||
alg: { value: '254' },
|
alg: { value: '254' },
|
||||||
pubKey: { value: '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' }
|
pubKey: { value: '' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
po response
|
|
||||||
|
|
||||||
expect(response[:results][0][:msg]).to eq('Algorithm is invalid')
|
expect(response[:results][0][:msg]).to eq('Algorithm is invalid')
|
||||||
expect(response[:results][0][:value]).to eq('9')
|
expect(response[:results][0][:value]).to eq('9')
|
||||||
|
@ -405,11 +404,19 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:results][1][:msg]).to eq('Protocol is invalid')
|
expect(response[:results][1][:msg]).to eq('Protocol is invalid')
|
||||||
expect(response[:results][1][:value]).to eq('4')
|
expect(response[:results][1][:value]).to eq('4')
|
||||||
|
|
||||||
expect(response[:results][2][:msg]).to eq('Algorithm is invalid')
|
expect(response[:results][2][:msg]).to eq('Flag is invalid')
|
||||||
expect(response[:results][2][:value]).to eq('10')
|
expect(response[:results][2][:value]).to eq('250')
|
||||||
|
|
||||||
expect(response[:results][3][:msg]).to eq('Protocol is invalid')
|
expect(response[:results][3][:msg]).to eq('Algorithm is invalid')
|
||||||
expect(response[:results][3][:value]).to eq('5')
|
expect(response[:results][3][:value]).to eq('10')
|
||||||
|
|
||||||
|
expect(response[:results][4][:msg]).to eq('Flag is invalid')
|
||||||
|
expect(response[:results][4][:value]).to eq('1')
|
||||||
|
|
||||||
|
expect(response[:results][5][:msg]).to eq('Public key is missing')
|
||||||
|
|
||||||
|
expect(response[:results][6][:msg]).to eq('Protocol is invalid')
|
||||||
|
expect(response[:results][6][:value]).to eq('5')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue