Dnskey removing

This commit is contained in:
Martin Lensment 2014-10-02 14:59:47 +03:00
parent c8863df4c5
commit 4b76e2ceec
4 changed files with 85 additions and 9 deletions

View file

@ -15,6 +15,9 @@ class Dnskey < ActiveRecord::Base
[:protocol, :invalid, { value: { obj: 'protocol', val: protocol } }], [:protocol, :invalid, { value: { obj: 'protocol', val: protocol } }],
[:flags, :invalid, { value: { obj: 'flags', val: flags } }] [:flags, :invalid, { value: { obj: 'flags', val: flags } }]
], ],
'2303' => [
[:base, :dnskey_not_found, { value: { obj: 'pubKey', val: public_key } }]
],
'2306' => [ '2306' => [
[:alg, :blank], [:alg, :blank],
[:protocol, :blank], [:protocol, :blank],

View file

@ -51,6 +51,7 @@ class Epp::EppDomain < Domain
detach_contacts(self.class.parse_contacts_from_frame(parsed_frame)) detach_contacts(self.class.parse_contacts_from_frame(parsed_frame))
detach_nameservers(self.class.parse_nameservers_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_statuses(self.class.parse_statuses_from_frame(parsed_frame))
detach_dnskeys(self.class.parse_dnskeys_from_frame(parsed_frame))
errors.empty? errors.empty?
end end
@ -173,6 +174,20 @@ class Epp::EppDomain < Domain
end end
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 ### ### RENEW ###
def renew(cur_exp_date, period, unit = 'y') def renew(cur_exp_date, period, unit = 'y')

View file

@ -106,6 +106,8 @@ en:
taken: 'Status already exists on this domain' taken: 'Status already exists on this domain'
registrar: registrar:
blank: 'Registrar is missing' blank: 'Registrar is missing'
dnskeys:
not_found: 'Dnskey was not found'
domain: domain:
<<: *epp_domain_ar_attributes <<: *epp_domain_ar_attributes

View file

@ -571,10 +571,30 @@ describe 'EPP Domain', epp: true do
{ hostObj: { value: 'ns2.example.com' } } { hostObj: { value: 'ns2.example.com' } }
] ]
}, },
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' } } }, { contact: { value: 'mak21', attrs: { type: 'tech' } } },
{ status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } },
{ status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } }
] ]
]
}) })
response = epp_request(xml, :xml) response = epp_request(xml, :xml)
@ -600,6 +620,8 @@ describe 'EPP Domain', epp: true do
expect(d.domain_statuses.last.value).to eq('clientUpdateProhibited') expect(d.domain_statuses.last.value).to eq('clientUpdateProhibited')
expect(d.dnskeys.count).to eq(2)
response = epp_request(xml, :xml) response = epp_request(xml, :xml)
expect(response[:results][0][:result_code]).to eq('2302') expect(response[:results][0][:result_code]).to eq('2302')
@ -633,10 +655,30 @@ describe 'EPP Domain', epp: true do
{ hostObj: { value: 'ns2.example.com' } } { hostObj: { value: 'ns2.example.com' } }
] ]
}, },
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' } } }, { contact: { value: 'mak21', attrs: { type: 'tech' } } },
{ status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } },
{ status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } }
] ]
]
}) })
epp_request(xml, :xml) epp_request(xml, :xml)
@ -648,14 +690,28 @@ describe 'EPP Domain', epp: true do
{ hostObj: { value: 'ns1.example.com' } } { hostObj: { value: 'ns1.example.com' } }
] ]
}, },
dnssec: [
{
dnskey: {
flags: { value: '0' },
protocol: { value: '3' },
alg: { value: '5' },
pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' }
}
}
],
_other: [
{ contact: { value: 'mak21', attrs: { type: 'tech' } } }, { contact: { value: 'mak21', attrs: { type: 'tech' } } },
{ status: { value: '', attrs: { s: 'clientHold' } } } { status: { value: '', attrs: { s: 'clientHold' } } }
] ]
]
}) })
d = Domain.last 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.count).to eq(1)
expect(d.domain_statuses.first.value).to eq('clientUpdateProhibited') expect(d.domain_statuses.first.value).to eq('clientUpdateProhibited')