mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 08:43:37 +02:00
Fix dnskey adding
This commit is contained in:
parent
3453b7f4a1
commit
6ab58767c3
5 changed files with 23 additions and 25 deletions
|
@ -27,9 +27,9 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
has_many :domain_transfers, dependent: :delete_all
|
||||
|
||||
has_many :dnskeys, dependent: :delete_all
|
||||
accepts_nested_attributes_for :dnskeys, allow_destroy: true,
|
||||
reject_if: proc { |attrs| attrs[:public_key].blank? }
|
||||
has_many :delegation_signers, dependent: :delete_all
|
||||
# accepts_nested_attributes_for :delegation_signers, allow_destroy: true,
|
||||
# reject_if: proc { |attrs| attrs[:public_key].blank? }
|
||||
|
||||
delegate :code, to: :owner_contact, prefix: true
|
||||
delegate :email, to: :owner_contact, prefix: true
|
||||
|
@ -49,12 +49,12 @@ class Domain < ActiveRecord::Base
|
|||
validate :validate_period
|
||||
validate :validate_nameservers_count
|
||||
validate :validate_admin_contacts_count
|
||||
validate :validate_dnskeys_count
|
||||
#validate :validate_dnskeys_count
|
||||
validate :validate_nameservers_uniqueness
|
||||
validate :validate_tech_contacts_uniqueness
|
||||
validate :validate_admin_contacts_uniqueness
|
||||
validate :validate_domain_statuses_uniqueness
|
||||
validate :validate_dnskeys_uniqueness
|
||||
#validate :validate_dnskeys_uniqueness
|
||||
validate :validate_nameserver_ips
|
||||
|
||||
attr_accessor :owner_contact_typeahead
|
||||
|
|
|
@ -29,12 +29,6 @@ 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' => [
|
||||
|
@ -176,9 +170,9 @@ class Epp::EppDomain < Domain
|
|||
|
||||
def attach_dnskeys(dnssec_data)
|
||||
sg = SettingGroup.dnskeys
|
||||
ds_data_allowed = sg.setting(Setting::ALLOW_DS_DATA) == '0' ? false : true
|
||||
ds_data_with_keys_allowed = sg.setting(Setting::ALLOW_DS_DATA_WITH_KEYS) == '0' ? false : true
|
||||
key_data_allowed = sg.setting(Setting::ALLOW_KEY_DATA) == '0' ? false : true
|
||||
ds_data_allowed = sg.setting(Setting::ALLOW_DS_DATA).value == '0' ? false : true
|
||||
ds_data_with_keys_allowed = sg.setting(Setting::ALLOW_DS_DATA_WITH_KEYS).value == '0' ? false : true
|
||||
key_data_allowed = sg.setting(Setting::ALLOW_KEY_DATA).value == '0' ? false : true
|
||||
|
||||
if dnssec_data[:ds_data].any? && !ds_data_allowed
|
||||
errors.add(:base, :ds_data_not_allowed)
|
||||
|
@ -200,15 +194,11 @@ class Epp::EppDomain < Domain
|
|||
end
|
||||
|
||||
attach_ds({
|
||||
keyTag: SecureRandom.hex(5),
|
||||
key_tag: SecureRandom.hex(5),
|
||||
alg: 3,
|
||||
digestType: sg.setting(Setting::DS_ALGORITHM),
|
||||
digest_type: sg.setting(Setting::DS_ALGORITHM).value,
|
||||
key_data: dnssec_data[:key_data]
|
||||
})
|
||||
|
||||
# dnskey_list.each do |dnskey_attrs|
|
||||
# dnskeys.build(dnskey_attrs)
|
||||
# end
|
||||
end
|
||||
|
||||
def attach_ds(ds_data)
|
||||
|
|
|
@ -3,6 +3,7 @@ class CreateDelegationSigner < ActiveRecord::Migration
|
|||
create_table :delegation_signers do |t|
|
||||
t.integer :domain_id
|
||||
t.string :key_tag
|
||||
t.integer :alg
|
||||
t.integer :digest_type
|
||||
t.string :digest
|
||||
end
|
||||
|
|
|
@ -94,6 +94,7 @@ ActiveRecord::Schema.define(version: 20141009101337) do
|
|||
create_table "delegation_signers", force: true do |t|
|
||||
t.integer "domain_id"
|
||||
t.string "key_tag"
|
||||
t.integer "alg"
|
||||
t.integer "digest_type"
|
||||
t.string "digest"
|
||||
end
|
||||
|
|
|
@ -330,7 +330,7 @@ describe 'EPP Domain', epp: true do
|
|||
{ keyData: {
|
||||
flags: { value: '257' },
|
||||
protocol: { value: '3' },
|
||||
alg: { value: '5' },
|
||||
alg: { value: '3' },
|
||||
pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' }
|
||||
}
|
||||
},
|
||||
|
@ -356,10 +356,16 @@ describe 'EPP Domain', epp: true do
|
|||
epp_request(xml, :xml)
|
||||
d = Domain.first
|
||||
|
||||
expect(d.dnskeys.pluck(:flags)).to match_array([257, 0, 256])
|
||||
expect(d.dnskeys.pluck(:protocol)).to match_array([3, 3, 3])
|
||||
expect(d.dnskeys.pluck(:alg)).to match_array([3, 5, 254])
|
||||
expect(d.dnskeys.pluck(:public_key)).to match_array(%w(
|
||||
ds = d.delegation_signers.first
|
||||
|
||||
expect(ds.key_tag).to_not be_blank
|
||||
expect(ds.alg).to eq(3)
|
||||
expect(ds.digest_type).to eq(SettingGroup.dnskeys.setting(Setting::DS_ALGORITHM).value.to_i)
|
||||
|
||||
expect(ds.dnskeys.pluck(:flags)).to match_array([257, 0, 256])
|
||||
expect(ds.dnskeys.pluck(:protocol)).to match_array([3, 3, 3])
|
||||
expect(ds.dnskeys.pluck(:alg)).to match_array([3, 5, 254])
|
||||
expect(ds.dnskeys.pluck(:public_key)).to match_array(%w(
|
||||
AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8
|
||||
700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f
|
||||
841936717ae427ace63c28d04918569a841936717ae427ace63c28d0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue