diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb index 151314b21..72788abc6 100644 --- a/app/models/dnskey.rb +++ b/app/models/dnskey.rb @@ -15,6 +15,9 @@ class Dnskey < ActiveRecord::Base [:protocol, :invalid, { value: { obj: 'protocol', val: protocol } }], [:flags, :invalid, { value: { obj: 'flags', val: flags } }] ], + '2303' => [ + [:base, :dnskey_not_found, { value: { obj: 'pubKey', val: public_key } }] + ], '2306' => [ [:alg, :blank], [:protocol, :blank], diff --git a/app/models/epp/epp_domain.rb b/app/models/epp/epp_domain.rb index c3785f21c..91a0d8774 100644 --- a/app/models/epp/epp_domain.rb +++ b/app/models/epp/epp_domain.rb @@ -51,6 +51,7 @@ class Epp::EppDomain < Domain detach_contacts(self.class.parse_contacts_from_frame(parsed_frame)) detach_nameservers(self.class.parse_nameservers_from_frame(parsed_frame)) detach_statuses(self.class.parse_statuses_from_frame(parsed_frame)) + detach_dnskeys(self.class.parse_dnskeys_from_frame(parsed_frame)) errors.empty? end @@ -173,6 +174,20 @@ class Epp::EppDomain < Domain end end + def detach_dnskeys(dnskey_list) + to_delete = [] + dnskey_list.each do |x| + dnskey = dnskeys.where(public_key: x[:public_key]) + if dnskey.blank? + add_epp_error('2303', 'pubKey', x[:public_key], [:dnskeys, :not_found]) + else + to_delete << dnskey + end + end + + dnskeys.delete(to_delete) + end + ### RENEW ### def renew(cur_exp_date, period, unit = 'y') diff --git a/config/locales/en.yml b/config/locales/en.yml index 65a19f359..6ce32585b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -106,6 +106,8 @@ en: taken: 'Status already exists on this domain' registrar: blank: 'Registrar is missing' + dnskeys: + not_found: 'Dnskey was not found' domain: <<: *epp_domain_ar_attributes diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index b23c9158f..8a5d9f1f7 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -571,9 +571,29 @@ describe 'EPP Domain', epp: true do { hostObj: { value: 'ns2.example.com' } } ] }, - { contact: { value: 'mak21', attrs: { type: 'tech' } } }, - { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, - { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } + dnssec: [ + { + dnskey: { + flags: { value: '0' }, + protocol: { value: '3' }, + alg: { value: '5' }, + pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } + } + }, + { + dnskey: { + flags: { value: '256' }, + protocol: { value: '3' }, + alg: { value: '254' }, + pubKey: { value: '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' } + } + } + ], + _other: [ + { contact: { value: 'mak21', attrs: { type: 'tech' } } }, + { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, + { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } + ] ] }) @@ -600,6 +620,8 @@ describe 'EPP Domain', epp: true do expect(d.domain_statuses.last.value).to eq('clientUpdateProhibited') + expect(d.dnskeys.count).to eq(2) + response = epp_request(xml, :xml) expect(response[:results][0][:result_code]).to eq('2302') @@ -633,9 +655,29 @@ describe 'EPP Domain', epp: true do { hostObj: { value: 'ns2.example.com' } } ] }, - { contact: { value: 'mak21', attrs: { type: 'tech' } } }, - { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, - { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } + dnssec: [ + { + dnskey: { + flags: { value: '0' }, + protocol: { value: '3' }, + alg: { value: '5' }, + pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } + } + }, + { + dnskey: { + flags: { value: '256' }, + protocol: { value: '3' }, + alg: { value: '254' }, + pubKey: { value: '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' } + } + } + ], + _other: [ + { contact: { value: 'mak21', attrs: { type: 'tech' } } }, + { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, + { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } + ] ] }) @@ -648,14 +690,28 @@ describe 'EPP Domain', epp: true do { hostObj: { value: 'ns1.example.com' } } ] }, - { contact: { value: 'mak21', attrs: { type: 'tech' } } }, - { status: { value: '', attrs: { s: 'clientHold' } } } + dnssec: [ + { + dnskey: { + flags: { value: '0' }, + protocol: { value: '3' }, + alg: { value: '5' }, + pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } + } + } + ], + _other: [ + { contact: { value: 'mak21', attrs: { type: 'tech' } } }, + { status: { value: '', attrs: { s: 'clientHold' } } } + ] ] }) d = Domain.last + expect(d.dnskeys.count).to eq(2) - epp_request(xml, :xml) + response = epp_request(xml, :xml) + expect(d.dnskeys.count).to eq(1) expect(d.domain_statuses.count).to eq(1) expect(d.domain_statuses.first.value).to eq('clientUpdateProhibited')