mirror of
https://github.com/internetee/registry.git
synced 2025-07-12 14:08:17 +02:00
Validate DNS keys count
This commit is contained in:
parent
9519538744
commit
39ebabf064
10 changed files with 70 additions and 9 deletions
|
@ -32,6 +32,10 @@ class Client::DomainsController < ClientController
|
|||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@domain.all_dependencies_valid?
|
||||
end
|
||||
|
||||
def edit
|
||||
build_associations
|
||||
end
|
||||
|
@ -70,7 +74,7 @@ class Client::DomainsController < ClientController
|
|||
nameservers_attributes: [:id, :hostname, :ipv4, :ipv6, :_destroy],
|
||||
domain_contacts_attributes: [:id, :contact_type, :contact_id, :value_typeahead, :_destroy],
|
||||
domain_statuses_attributes: [:id, :value, :description, :_destroy],
|
||||
dnskeys_attributes: [:id, :flags, :alg, :protocol, :public_key]
|
||||
dnskeys_attributes: [:id, :flags, :alg, :protocol, :public_key, :_destroy]
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ class Domain < ActiveRecord::Base
|
|||
validate :validate_period
|
||||
validate :validate_nameservers_count
|
||||
validate :validate_admin_contacts_count
|
||||
validate :validate_dnskeys_count
|
||||
validate :validate_nameservers_uniqueness
|
||||
validate :validate_tech_contacts_uniqueness
|
||||
validate :validate_admin_contacts_uniqueness
|
||||
|
@ -95,6 +96,13 @@ class Domain < ActiveRecord::Base
|
|||
errors.add(:admin_contacts, :out_of_range) if admin_contacts_count.zero?
|
||||
end
|
||||
|
||||
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_nameservers_uniqueness
|
||||
validated = []
|
||||
nameservers.reject(&:marked_for_destruction?).each do |ns|
|
||||
|
@ -176,6 +184,7 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
def all_dependencies_valid?
|
||||
validate_nameservers_count
|
||||
validate_dnskeys_count
|
||||
validate_admin_contacts_count
|
||||
|
||||
errors.empty?
|
||||
|
|
|
@ -29,6 +29,12 @@ class Epp::EppDomain < Domain
|
|||
max: domain_validation_sg.setting(:ns_max_count).value
|
||||
}
|
||||
],
|
||||
[:dnskeys, :out_of_range,
|
||||
{
|
||||
min: domain_validation_sg.setting(:dnskeys_min_count).value,
|
||||
max: domain_validation_sg.setting(:dnskeys_max_count).value
|
||||
}
|
||||
],
|
||||
[:period, :out_of_range, { value: { obj: 'period', val: period } }]
|
||||
],
|
||||
'2200' => [
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
class NsSet < ActiveRecord::Base
|
||||
belongs_to :registrar
|
||||
has_many :domains
|
||||
has_and_belongs_to_many :nameservers
|
||||
end
|
|
@ -14,7 +14,7 @@
|
|||
.row
|
||||
.col-md-4
|
||||
.form-group
|
||||
= key_fields.label :flags, t('shared.flag')
|
||||
= key_fields.label :flags
|
||||
= key_fields.text_field :flags, class: 'form-control'
|
||||
.col-md-4
|
||||
.form-group
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue