mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 01:33:36 +02:00
Additional validations for keyrelay
This commit is contained in:
parent
857182df0e
commit
4f10cccdfa
4 changed files with 46 additions and 1 deletions
|
@ -9,6 +9,7 @@ class Keyrelay < ActiveRecord::Base
|
|||
delegate :name, to: :domain, prefix: true
|
||||
|
||||
validates :expiry_relative, duration_iso8601: true
|
||||
validates :key_data_public_key, :key_data_flags, :key_data_protocol, :key_data_alg, :auth_info_pw, presence: true
|
||||
|
||||
validate :validate_expiry_relative_xor_expiry_absolute
|
||||
|
||||
|
@ -18,7 +19,12 @@ class Keyrelay < ActiveRecord::Base
|
|||
[:expiry_relative, :unknown_pattern, { value: { obj: 'relative', val: expiry_relative } }]
|
||||
],
|
||||
'2003' => [
|
||||
[:base, :only_one_parameter_allowed, { param_1: 'relative', param_2: 'absolute' }]
|
||||
[:base, :only_one_parameter_allowed, { param_1: 'relative', param_2: 'absolute' }],
|
||||
[:key_data_public_key, :blank],
|
||||
[:key_data_flags, :blank],
|
||||
[:key_data_protocol, :blank],
|
||||
[:key_data_alg, :blank],
|
||||
[:auth_info_pw, :blank]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
|
|
@ -210,6 +210,17 @@ en:
|
|||
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
|
||||
expiry_relative:
|
||||
unknown_pattern: 'Expiry relative must be compatible to ISO 8601'
|
||||
key_data_public_key:
|
||||
blank: 'Public key is missing'
|
||||
key_data_flags:
|
||||
blank: 'Flag is missing'
|
||||
key_data_protocol:
|
||||
blank: 'Protocol is missing'
|
||||
key_data_alg:
|
||||
blank: 'Algorithm is missing'
|
||||
auth_info_pw:
|
||||
blank: 'Password is missing'
|
||||
|
||||
|
||||
attributes:
|
||||
epp_domain: &epp_domain_attributes
|
||||
|
|
|
@ -41,6 +41,29 @@ describe 'EPP Keyrelay', epp: true do
|
|||
expect(zone.messages.queued.count).to eq(1)
|
||||
end
|
||||
|
||||
it 'returns an error when parameters are missing' do
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: 'example.ee' },
|
||||
keyData: {
|
||||
flags: { value: '' },
|
||||
protocol: { value: '3' },
|
||||
alg: { value: '8' },
|
||||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||
},
|
||||
authInfo: {
|
||||
pw: { value: domain.auth_info }
|
||||
},
|
||||
expiry: {
|
||||
relative: { value: 'Invalid Expiry' }
|
||||
}
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
expect(response[:msg]).to eq('Required parameter missing: flags')
|
||||
|
||||
expect(zone.messages.queued.count).to eq(0)
|
||||
end
|
||||
|
||||
it 'returns an error on invalid relative expiry' do
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: 'example.ee' },
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
Fabricator(:keyrelay) do
|
||||
pa_date { DateTime.now }
|
||||
expiry_relative 'P1W'
|
||||
key_data_public_key 'abc'
|
||||
key_data_flags 0
|
||||
key_data_protocol 3
|
||||
key_data_alg 3
|
||||
auth_info_pw 'abc'
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue