mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Fix some epp tests
This commit is contained in:
parent
a740ed34f3
commit
f63eb66f02
6 changed files with 83 additions and 39 deletions
|
@ -3,12 +3,32 @@ class DelegationSigner < ActiveRecord::Base
|
||||||
has_many :dnskeys
|
has_many :dnskeys
|
||||||
|
|
||||||
validate :validate_dnskeys_uniqueness
|
validate :validate_dnskeys_uniqueness
|
||||||
|
validate :validate_dnskeys_count
|
||||||
|
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{}
|
sg = SettingGroup.domain_validation
|
||||||
|
|
||||||
|
{
|
||||||
|
'2004' => [ # Parameter value range error
|
||||||
|
[:dnskeys, :out_of_range,
|
||||||
|
{
|
||||||
|
min: sg.setting(Setting::DNSKEYS_MIN_COUNT).value,
|
||||||
|
max: sg.setting(Setting::DNSKEYS_MAX_COUNT).value
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_dnskeys_uniqueness
|
def validate_dnskeys_count
|
||||||
|
sg = SettingGroup.domain_validation
|
||||||
|
min, max = sg.setting(:dnskeys_min_count).value.to_i, sg.setting(:dnskeys_max_count).value.to_i
|
||||||
|
return if dnskeys.reject(&:marked_for_destruction?).length.between?(min, max)
|
||||||
|
errors.add(:dnskeys, :out_of_range, { min: min, max: max })
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_dnskeys_uniqueness
|
||||||
validated = []
|
validated = []
|
||||||
list = dnskeys.reject(&:marked_for_destruction?)
|
list = dnskeys.reject(&:marked_for_destruction?)
|
||||||
list.each do |dnskey|
|
list.each do |dnskey|
|
||||||
|
|
|
@ -54,6 +54,7 @@ class Domain < ActiveRecord::Base
|
||||||
validate :validate_tech_contacts_uniqueness
|
validate :validate_tech_contacts_uniqueness
|
||||||
validate :validate_admin_contacts_uniqueness
|
validate :validate_admin_contacts_uniqueness
|
||||||
validate :validate_domain_statuses_uniqueness
|
validate :validate_domain_statuses_uniqueness
|
||||||
|
# validate :validate_dnskeys_uniqueness
|
||||||
validate :validate_nameserver_ips
|
validate :validate_nameserver_ips
|
||||||
|
|
||||||
attr_accessor :owner_contact_typeahead
|
attr_accessor :owner_contact_typeahead
|
||||||
|
@ -158,6 +159,19 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_dnskeys_uniqueness
|
||||||
|
validated = []
|
||||||
|
list = dnskeys.reject(&:marked_for_destruction?)
|
||||||
|
list.each do |dnskey|
|
||||||
|
next if dnskey.public_key.blank?
|
||||||
|
existing = list.select { |x| x.public_key == dnskey.public_key }
|
||||||
|
next unless existing.length > 1
|
||||||
|
validated << dnskey.public_key
|
||||||
|
errors.add(:dnskeys, :invalid) if errors[:dnskeys].blank?
|
||||||
|
dnskey.errors.add(:public_key, :taken)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def validate_period
|
def validate_period
|
||||||
return unless period.present?
|
return unless period.present?
|
||||||
if period_unit == 'd'
|
if period_unit == 'd'
|
||||||
|
|
|
@ -9,4 +9,7 @@ class Setting < ActiveRecord::Base
|
||||||
ALLOW_DS_DATA = 'allow_ds_data'
|
ALLOW_DS_DATA = 'allow_ds_data'
|
||||||
ALLOW_DS_DATA_WITH_KEYS = 'allow_ds_data_with_keys'
|
ALLOW_DS_DATA_WITH_KEYS = 'allow_ds_data_with_keys'
|
||||||
ALLOW_KEY_DATA = 'allow_key_data'
|
ALLOW_KEY_DATA = 'allow_key_data'
|
||||||
|
DNSKEYS_MAX_COUNT = 'dnskeys_max_count'
|
||||||
|
DNSKEYS_MIN_COUNT = 'dnskeys_min_count'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,3 +74,7 @@ xml.epp_head do
|
||||||
|
|
||||||
xml << render('/epp/shared/trID')
|
xml << render('/epp/shared/trID')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
9032
|
||||||
|
72056
|
||||||
|
|
|
@ -112,7 +112,6 @@ en:
|
||||||
dnskeys:
|
dnskeys:
|
||||||
invalid: 'DNS keys are invalid'
|
invalid: 'DNS keys are invalid'
|
||||||
not_found: 'Dnskey was not found'
|
not_found: 'Dnskey was not found'
|
||||||
out_of_range: 'DNS keys count must be between %{min}-%{max}'
|
|
||||||
|
|
||||||
domain:
|
domain:
|
||||||
<<: *epp_domain_ar_attributes
|
<<: *epp_domain_ar_attributes
|
||||||
|
@ -207,6 +206,12 @@ en:
|
||||||
blank: 'Public key is missing'
|
blank: 'Public key is missing'
|
||||||
|
|
||||||
|
|
||||||
|
delegation_signer:
|
||||||
|
attributes:
|
||||||
|
dnskeys:
|
||||||
|
out_of_range: 'DNS keys count must be between %{min}-%{max}'
|
||||||
|
|
||||||
|
|
||||||
attributes:
|
attributes:
|
||||||
epp_domain: &epp_domain_attributes
|
epp_domain: &epp_domain_attributes
|
||||||
name: 'Domain name'
|
name: 'Domain name'
|
||||||
|
|
|
@ -430,24 +430,24 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create a domain with two identical dnskeys' do
|
it 'does not create a domain with two identical dnskeys' do
|
||||||
xml = domain_create_xml({}, {
|
xml = domain_create_xml({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ keyData: {
|
{ keyData: {
|
||||||
flags: { value: '257' },
|
flags: { value: '257' },
|
||||||
protocol: { value: '3' },
|
protocol: { value: '3' },
|
||||||
alg: { value: '3' },
|
alg: { value: '3' },
|
||||||
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
keyData: {
|
keyData: {
|
||||||
flags: { value: '0' },
|
flags: { value: '0' },
|
||||||
protocol: { value: '3' },
|
protocol: { value: '3' },
|
||||||
alg: { value: '5' },
|
alg: { value: '5' },
|
||||||
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
|
|
||||||
|
@ -461,25 +461,23 @@ describe 'EPP Domain', epp: true do
|
||||||
s.value = 1
|
s.value = 1
|
||||||
s.save
|
s.save
|
||||||
|
|
||||||
xml = domain_create_xml({
|
xml = domain_create_xml({}, {
|
||||||
dnssec: [
|
_other: [
|
||||||
{
|
{ keyData: {
|
||||||
dnskey: {
|
flags: { value: '257' },
|
||||||
flags: { value: '257' },
|
protocol: { value: '3' },
|
||||||
protocol: { value: '3' },
|
alg: { value: '3' },
|
||||||
alg: { value: '3' },
|
pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
|
||||||
pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dnskey: {
|
|
||||||
flags: { value: '0' },
|
|
||||||
protocol: { value: '3' },
|
|
||||||
alg: { value: '5' },
|
|
||||||
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
|
{
|
||||||
|
keyData: {
|
||||||
|
flags: { value: '0' },
|
||||||
|
protocol: { value: '3' },
|
||||||
|
alg: { value: '5' },
|
||||||
|
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
||||||
|
}
|
||||||
|
}]
|
||||||
})
|
})
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue