mirror of
https://github.com/internetee/registry.git
synced 2025-08-12 04:29:33 +02:00
Merge branch 'master' of github.com:internetee/registry
Conflicts: app/models/registrar.rb db/schema.rb
This commit is contained in:
commit
c14452e756
13 changed files with 128 additions and 25 deletions
|
@ -32,6 +32,10 @@ class Client::DomainsController < ClientController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@domain.all_dependencies_valid?
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
build_associations
|
build_associations
|
||||||
end
|
end
|
||||||
|
@ -70,7 +74,7 @@ class Client::DomainsController < ClientController
|
||||||
nameservers_attributes: [:id, :hostname, :ipv4, :ipv6, :_destroy],
|
nameservers_attributes: [:id, :hostname, :ipv4, :ipv6, :_destroy],
|
||||||
domain_contacts_attributes: [:id, :contact_type, :contact_id, :value_typeahead, :_destroy],
|
domain_contacts_attributes: [:id, :contact_type, :contact_id, :value_typeahead, :_destroy],
|
||||||
domain_statuses_attributes: [:id, :value, :description, :_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
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ class Domain < ActiveRecord::Base
|
||||||
validate :validate_period
|
validate :validate_period
|
||||||
validate :validate_nameservers_count
|
validate :validate_nameservers_count
|
||||||
validate :validate_admin_contacts_count
|
validate :validate_admin_contacts_count
|
||||||
|
validate :validate_dnskeys_count
|
||||||
validate :validate_nameservers_uniqueness
|
validate :validate_nameservers_uniqueness
|
||||||
validate :validate_tech_contacts_uniqueness
|
validate :validate_tech_contacts_uniqueness
|
||||||
validate :validate_admin_contacts_uniqueness
|
validate :validate_admin_contacts_uniqueness
|
||||||
|
@ -95,11 +96,19 @@ class Domain < ActiveRecord::Base
|
||||||
errors.add(:admin_contacts, :out_of_range) if admin_contacts_count.zero?
|
errors.add(:admin_contacts, :out_of_range) if admin_contacts_count.zero?
|
||||||
end
|
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
|
def validate_nameservers_uniqueness
|
||||||
validated = []
|
validated = []
|
||||||
nameservers.reject(&:marked_for_destruction?).each do |ns|
|
list = nameservers.reject(&:marked_for_destruction?)
|
||||||
|
list.each do |ns|
|
||||||
next if ns.hostname.blank?
|
next if ns.hostname.blank?
|
||||||
existing = nameservers.reject(&:marked_for_destruction?).select { |x| x.hostname == ns.hostname }
|
existing = list.select { |x| x.hostname == ns.hostname }
|
||||||
next unless existing.length > 1
|
next unless existing.length > 1
|
||||||
validated << ns.hostname
|
validated << ns.hostname
|
||||||
errors.add(:nameservers, :invalid) if errors[:nameservers].blank?
|
errors.add(:nameservers, :invalid) if errors[:nameservers].blank?
|
||||||
|
@ -139,9 +148,10 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def validate_domain_statuses_uniqueness
|
def validate_domain_statuses_uniqueness
|
||||||
validated = []
|
validated = []
|
||||||
domain_statuses.reject(&:marked_for_destruction?).each do |status|
|
list = domain_statuses.reject(&:marked_for_destruction?)
|
||||||
|
list.each do |status|
|
||||||
next if status.value.blank?
|
next if status.value.blank?
|
||||||
existing = domain_statuses.select { |x| x.value == status.value }
|
existing = list.select { |x| x.value == status.value }
|
||||||
next unless existing.length > 1
|
next unless existing.length > 1
|
||||||
validated << status.value
|
validated << status.value
|
||||||
errors.add(:domain_statuses, :invalid) if errors[:domain_statuses].blank?
|
errors.add(:domain_statuses, :invalid) if errors[:domain_statuses].blank?
|
||||||
|
@ -151,9 +161,10 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def validate_dnskeys_uniqueness
|
def validate_dnskeys_uniqueness
|
||||||
validated = []
|
validated = []
|
||||||
dnskeys.reject(&:marked_for_destruction?).each do |dnskey|
|
list = dnskeys.reject(&:marked_for_destruction?)
|
||||||
|
list.each do |dnskey|
|
||||||
next if dnskey.public_key.blank?
|
next if dnskey.public_key.blank?
|
||||||
existing = dnskeys.select { |x| x.public_key == dnskey.public_key }
|
existing = list.select { |x| x.public_key == dnskey.public_key }
|
||||||
next unless existing.length > 1
|
next unless existing.length > 1
|
||||||
validated << dnskey.public_key
|
validated << dnskey.public_key
|
||||||
errors.add(:dnskeys, :invalid) if errors[:dnskeys].blank?
|
errors.add(:dnskeys, :invalid) if errors[:dnskeys].blank?
|
||||||
|
@ -176,6 +187,7 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def all_dependencies_valid?
|
def all_dependencies_valid?
|
||||||
validate_nameservers_count
|
validate_nameservers_count
|
||||||
|
validate_dnskeys_count
|
||||||
validate_admin_contacts_count
|
validate_admin_contacts_count
|
||||||
|
|
||||||
errors.empty?
|
errors.empty?
|
||||||
|
|
|
@ -29,6 +29,12 @@ class Epp::EppDomain < Domain
|
||||||
max: domain_validation_sg.setting(:ns_max_count).value
|
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 } }]
|
[:period, :out_of_range, { value: { obj: 'period', val: period } }]
|
||||||
],
|
],
|
||||||
'2200' => [
|
'2200' => [
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
class NsSet < ActiveRecord::Base
|
|
||||||
belongs_to :registrar
|
|
||||||
has_many :domains
|
|
||||||
has_and_belongs_to_many :nameservers
|
|
||||||
end
|
|
|
@ -1,10 +1,9 @@
|
||||||
class Registrar < ActiveRecord::Base
|
class Registrar < ActiveRecord::Base
|
||||||
belongs_to :country
|
belongs_to :country
|
||||||
has_many :domains, :dependent => :restrict_with_error
|
has_many :domains, :dependent => :restrict_with_error
|
||||||
has_many :ns_sets
|
has_many :contacts, :dependent => :restrict_with_error
|
||||||
has_many :epp_users
|
has_many :epp_users, :dependent => :restrict_with_error
|
||||||
has_many :users
|
has_many :users, :dependent => :restrict_with_error
|
||||||
has_many :contacts
|
|
||||||
|
|
||||||
validates :name, :reg_no, :address, :country, presence: true
|
validates :name, :reg_no, :address, :country, presence: true
|
||||||
validates :name, :reg_no, uniqueness: true
|
validates :name, :reg_no, uniqueness: true
|
||||||
|
|
|
@ -19,5 +19,5 @@
|
||||||
%tfoot
|
%tfoot
|
||||||
- @domain.errors.messages[:nameservers].each do |x|
|
- @domain.errors.messages[:nameservers].each do |x|
|
||||||
%tr
|
%tr
|
||||||
%td{colspan: 4}= x
|
%td{colspan: 3}= x
|
||||||
|
|
||||||
|
|
|
@ -44,3 +44,40 @@
|
||||||
|
|
||||||
%dt= t('shared.billing_address')
|
%dt= t('shared.billing_address')
|
||||||
%dd= @registrar.billing_address
|
%dd= @registrar.billing_address
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
#users.panel.panel-default
|
||||||
|
.panel-heading.clearfix
|
||||||
|
= t('shared.users')
|
||||||
|
.table-responsive
|
||||||
|
%table.table.table-hover.table-bordered.table-condensed
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th{class: 'col-xs-3'}= t('shared.username')
|
||||||
|
%th{class: 'col-xs-3'}= t('shared.email')
|
||||||
|
%th{class: 'col-xs-3'}= t('shared.identity_code')
|
||||||
|
%th{class: 'col-xs-3'}= t('shared.admin')
|
||||||
|
%tbody
|
||||||
|
- @registrar.users.each do |x|
|
||||||
|
%tr
|
||||||
|
%td= link_to(x, [:admin, x])
|
||||||
|
%td= x.email
|
||||||
|
%td= x.identity_code
|
||||||
|
%td= x.admin
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
#epp-users.panel.panel-default
|
||||||
|
.panel-heading.clearfix
|
||||||
|
= t('shared.epp_users')
|
||||||
|
.table-responsive
|
||||||
|
%table.table.table-hover.table-bordered.table-condensed
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th{class: 'col-xs-6'}= t('shared.username')
|
||||||
|
%th{class: 'col-xs-6'}= t('shared.active')
|
||||||
|
%tbody
|
||||||
|
- @registrar.epp_users.each do |x|
|
||||||
|
%tr
|
||||||
|
%td= link_to(x, [:admin, x])
|
||||||
|
%td= x.active
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
.row
|
.row
|
||||||
.col-md-4
|
.col-md-4
|
||||||
.form-group
|
.form-group
|
||||||
= key_fields.label :flags, t('shared.flag')
|
= key_fields.label :flags
|
||||||
= key_fields.text_field :flags, class: 'form-control'
|
= key_fields.text_field :flags, class: 'form-control'
|
||||||
.col-md-4
|
.col-md-4
|
||||||
.form-group
|
.form-group
|
||||||
|
|
13
bin/robot
13
bin/robot
|
@ -2,6 +2,7 @@
|
||||||
#
|
#
|
||||||
# Build and run everything for automatic tests
|
# Build and run everything for automatic tests
|
||||||
#
|
#
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# cd to Rails root directory
|
# cd to Rails root directory
|
||||||
|
@ -11,7 +12,12 @@ git pull origin master
|
||||||
git reset --hard
|
git reset --hard
|
||||||
unset GIT_DIR GIT_WORK_TREE
|
unset GIT_DIR GIT_WORK_TREE
|
||||||
|
|
||||||
setuser app bundle install --deployment
|
# run rubocop
|
||||||
|
echo "RUBOCOP_RESULTS"
|
||||||
|
rubocop
|
||||||
|
echo "END_OF_RUBOCOP_RESULTS"
|
||||||
|
|
||||||
|
bundle install --deployment
|
||||||
|
|
||||||
# cp config/secrets-example.yml config/secrets.yml
|
# cp config/secrets-example.yml config/secrets.yml
|
||||||
# create manually config/database.yml
|
# create manually config/database.yml
|
||||||
|
@ -26,11 +32,6 @@ echo "GIT_LAST_COMMITS"
|
||||||
git log origin/master -n 15 --pretty=oneline | sed -r '/^.{40} Merge branch/d' | sed -r 's/^.{40}/Latests: /'
|
git log origin/master -n 15 --pretty=oneline | sed -r '/^.{40} Merge branch/d' | sed -r 's/^.{40}/Latests: /'
|
||||||
echo "END_OF_GIT_LAST_COMMITS"
|
echo "END_OF_GIT_LAST_COMMITS"
|
||||||
|
|
||||||
# run rubocop
|
|
||||||
echo "RUBOCOP_RESULTS"
|
|
||||||
rubocop
|
|
||||||
echo "END_OF_RUBOCOP_RESULTS"
|
|
||||||
|
|
||||||
# run tests
|
# run tests
|
||||||
echo "TEST_RESULTS"
|
echo "TEST_RESULTS"
|
||||||
RAILS_ENV=test ROBOT=true bundle exec rake test
|
RAILS_ENV=test ROBOT=true bundle exec rake test
|
||||||
|
|
|
@ -109,6 +109,7 @@ 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
|
||||||
|
@ -211,6 +212,11 @@ en:
|
||||||
nameservers: 'Nameservers'
|
nameservers: 'Nameservers'
|
||||||
domain:
|
domain:
|
||||||
<<: *epp_domain_attributes
|
<<: *epp_domain_attributes
|
||||||
|
dnskey:
|
||||||
|
flags: 'Flag'
|
||||||
|
protocol: 'Protocol'
|
||||||
|
alg: 'Algorithm'
|
||||||
|
public_key: 'Public key'
|
||||||
|
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
|
@ -242,6 +248,8 @@ en:
|
||||||
codes:
|
codes:
|
||||||
ns_min_count: 'Nameserver minimum count'
|
ns_min_count: 'Nameserver minimum count'
|
||||||
ns_max_count: 'Nameserver maximum count'
|
ns_max_count: 'Nameserver maximum count'
|
||||||
|
dnskeys_min_count: 'DNS keys minimum count'
|
||||||
|
dnskeys_max_count: 'DNS keys maximum count'
|
||||||
|
|
||||||
shared:
|
shared:
|
||||||
code: 'Code'
|
code: 'Code'
|
||||||
|
|
7
db/migrate/20141006124904_add_dnskey_range_validation.rb
Normal file
7
db/migrate/20141006124904_add_dnskey_range_validation.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class AddDnskeyRangeValidation < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
sg = SettingGroup.find_by(code: 'domain_validation')
|
||||||
|
sg.settings << Setting.create(code: 'dnskeys_min_count'.underscore, value: '0')
|
||||||
|
sg.settings << Setting.create(code: 'dnskeys_max_count'.underscore, value: '9')
|
||||||
|
end
|
||||||
|
end
|
|
@ -447,6 +447,38 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:msg]).to eq('Public key already exists')
|
expect(response[:msg]).to eq('Public key already exists')
|
||||||
expect(response[:results][0][:value]).to eq('700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f')
|
expect(response[:results][0][:value]).to eq('700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'validated dnskeys count' do
|
||||||
|
s = Setting.find_by(code: 'dnskeys_max_count')
|
||||||
|
s.value = 1
|
||||||
|
s.save
|
||||||
|
|
||||||
|
xml = domain_create_xml({
|
||||||
|
dnssec: [
|
||||||
|
{
|
||||||
|
dnskey: {
|
||||||
|
flags: { value: '257' },
|
||||||
|
protocol: { value: '3' },
|
||||||
|
alg: { value: '3' },
|
||||||
|
pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dnskey: {
|
||||||
|
flags: { value: '0' },
|
||||||
|
protocol: { value: '3' },
|
||||||
|
alg: { value: '5' },
|
||||||
|
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
response = epp_request(xml, :xml)
|
||||||
|
|
||||||
|
expect(response[:result_code]).to eq('2004')
|
||||||
|
expect(response[:msg]).to eq('DNS keys count must be between 0-1')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with juridical persion as an owner' do
|
context 'with juridical persion as an owner' do
|
||||||
|
|
|
@ -13,7 +13,9 @@ Fabricator(:domain_validation_setting_group, from: :setting_group) do
|
||||||
settings do
|
settings do
|
||||||
[
|
[
|
||||||
Fabricate(:setting, code: 'ns_min_count', value: 1),
|
Fabricate(:setting, code: 'ns_min_count', value: 1),
|
||||||
Fabricate(:setting, code: 'ns_max_count', value: 13)
|
Fabricate(:setting, code: 'ns_max_count', value: 13),
|
||||||
|
Fabricate(:setting, code: 'dnskeys_min_count', value: 0),
|
||||||
|
Fabricate(:setting, code: 'dnskeys_max_count', value: 9)
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue