mirror of
https://github.com/internetee/registry.git
synced 2025-07-02 17:23:34 +02:00
Contact removing on domain update, displaying errors
This commit is contained in:
parent
a7de74eb82
commit
755bfc9a24
4 changed files with 50 additions and 6 deletions
|
@ -61,7 +61,10 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def detach_objects(ph, parsed_frame)
|
def detach_objects(ph, 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))
|
||||||
|
|
||||||
|
errors.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach_owner_contact(code)
|
def attach_owner_contact(code)
|
||||||
|
@ -120,10 +123,39 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def detach_contacts(contact_list)
|
||||||
|
to_delete = []
|
||||||
|
contact_list.each do |k, v|
|
||||||
|
v.each do |x|
|
||||||
|
contact = domain_contacts.joins(:contact).where(contacts: {code: x[:contact]})
|
||||||
|
if contact.blank?
|
||||||
|
errors.add(:domain_contacts, {
|
||||||
|
obj: 'contact',
|
||||||
|
val: x[:contact],
|
||||||
|
msg: errors.generate_message(:domain_contacts, :not_found)
|
||||||
|
})
|
||||||
|
else
|
||||||
|
to_delete << contact
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.domain_contacts.delete(to_delete)
|
||||||
|
end
|
||||||
|
|
||||||
def detach_nameservers(ns_list)
|
def detach_nameservers(ns_list)
|
||||||
to_delete = []
|
to_delete = []
|
||||||
ns_list.each do |ns_attrs|
|
ns_list.each do |ns_attrs|
|
||||||
to_delete << self.nameservers.where(ns_attrs)
|
nameserver = self.nameservers.where(ns_attrs)
|
||||||
|
if nameserver.blank?
|
||||||
|
errors.add(:nameservers, {
|
||||||
|
obj: 'hostObj',
|
||||||
|
val: ns_attrs[:hostname],
|
||||||
|
msg: errors.generate_message(:nameservers, :not_found)
|
||||||
|
})
|
||||||
|
else
|
||||||
|
to_delete << nameserver
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.nameservers.delete(to_delete)
|
self.nameservers.delete(to_delete)
|
||||||
|
@ -199,7 +231,8 @@ class Domain < ActiveRecord::Base
|
||||||
],
|
],
|
||||||
'2303' => [ # Object does not exist
|
'2303' => [ # Object does not exist
|
||||||
[:owner_contact, :epp_registrant_not_found],
|
[:owner_contact, :epp_registrant_not_found],
|
||||||
[:domain_contacts, :not_found]
|
[:domain_contacts, :not_found],
|
||||||
|
[:nameservers, :not_found]
|
||||||
],
|
],
|
||||||
'2200' => [
|
'2200' => [
|
||||||
[:auth_info, :wrong_pw]
|
[:auth_info, :wrong_pw]
|
||||||
|
|
|
@ -50,6 +50,7 @@ en:
|
||||||
blank: 'Admin contact is missing'
|
blank: 'Admin contact is missing'
|
||||||
nameservers:
|
nameservers:
|
||||||
out_of_range: 'Nameservers count must be between %{min}-%{max}'
|
out_of_range: 'Nameservers count must be between %{min}-%{max}'
|
||||||
|
not_found: 'Nameserver was not found'
|
||||||
period:
|
period:
|
||||||
out_of_range: 'Period must add up to 1, 2 or 3 years'
|
out_of_range: 'Period must add up to 1, 2 or 3 years'
|
||||||
auth_info:
|
auth_info:
|
||||||
|
|
|
@ -285,13 +285,23 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
d = Domain.last
|
d = Domain.last
|
||||||
|
|
||||||
new_ns = d.nameservers.find_by(hostname: 'ns1.example.com')
|
|
||||||
expect(new_ns).to be_truthy
|
|
||||||
|
|
||||||
response = epp_request('domains/update_remove_objects.xml')
|
response = epp_request('domains/update_remove_objects.xml')
|
||||||
|
|
||||||
rem_ns = d.nameservers.find_by(hostname: 'ns1.example.com')
|
rem_ns = d.nameservers.find_by(hostname: 'ns1.example.com')
|
||||||
expect(rem_ns).to be_falsey
|
expect(rem_ns).to be_falsey
|
||||||
|
|
||||||
|
rem_cnt = d.tech_contacts.find_by(code: 'mak21')
|
||||||
|
expect(rem_cnt).to be_falsey
|
||||||
|
|
||||||
|
response = epp_request('domains/update_remove_objects.xml')
|
||||||
|
|
||||||
|
expect(response[:results][0][:result_code]).to eq('2303')
|
||||||
|
expect(response[:results][0][:msg]).to eq('Contact was not found')
|
||||||
|
expect(response[:results][0][:value]).to eq('mak21')
|
||||||
|
|
||||||
|
expect(response[:results][1][:result_code]).to eq('2303')
|
||||||
|
expect(response[:results][1][:msg]).to eq('Nameserver was not found')
|
||||||
|
expect(response[:results][1][:value]).to eq('ns1.example.com')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<domain:ns>
|
<domain:ns>
|
||||||
<domain:hostObj>ns1.example.com</domain:hostObj>
|
<domain:hostObj>ns1.example.com</domain:hostObj>
|
||||||
</domain:ns>
|
</domain:ns>
|
||||||
<domain:contact type="tech">sh8013</domain:contact>
|
<domain:contact type="tech">mak21</domain:contact>
|
||||||
<domain:status s="clientHold"/>
|
<domain:status s="clientHold"/>
|
||||||
</domain:rem>
|
</domain:rem>
|
||||||
</domain:update>
|
</domain:update>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue