mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Do not transfer contact if contact is already under new registrar
This commit is contained in:
parent
9f9bffae57
commit
33e5e0ab72
2 changed files with 38 additions and 3 deletions
|
@ -413,6 +413,8 @@ class Epp::Domain < Domain
|
|||
end
|
||||
|
||||
def transfer_owner_contact(registrar_id)
|
||||
return if owner_contact.registrar_id == registrar_id
|
||||
|
||||
is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', owner_contact_id, id).count > 0
|
||||
if owner_contact.domains_owned.count > 1 || is_other_domains_contact
|
||||
# copy contact
|
||||
|
@ -429,15 +431,13 @@ class Epp::Domain < Domain
|
|||
oc.generate_code
|
||||
oc.registrar_id = registrar_id
|
||||
oc.save!
|
||||
|
||||
self.owner_contact = oc
|
||||
end
|
||||
end
|
||||
|
||||
def transfer_domain_contacts(registrar_id)
|
||||
copied_ids = []
|
||||
contacts.each do |c|
|
||||
next if copied_ids.include?(c.id)
|
||||
next if copied_ids.include?(c.id) || c.registrar_id == registrar_id
|
||||
|
||||
is_other_domains_contact = DomainContact.where('contact_id = ? AND domain_id != ?', c.id, id).count > 0
|
||||
# if contact used to be owner contact but was copied, then contact must be transferred
|
||||
|
|
|
@ -1105,6 +1105,41 @@ describe 'EPP Domain', epp: true do
|
|||
domain.domain_contacts.where(contact_id: domain.owner_contact_id).count.should == 1
|
||||
end
|
||||
|
||||
it 'does not transfer contacts if they are already under new registrar' do
|
||||
domain.contacts.each do |c|
|
||||
c.registrar_id = @registrar2.id
|
||||
c.save
|
||||
end
|
||||
|
||||
domain.owner_contact.registrar_id = @registrar2.id
|
||||
domain.owner_contact.save
|
||||
|
||||
original_oc_id = domain.owner_contact_id
|
||||
original_oc_code = domain.owner_contact.code
|
||||
original_contacts_codes = domain.contacts.pluck(:code)
|
||||
|
||||
pw = domain.auth_info
|
||||
xml = domain_transfer_xml({
|
||||
name: { value: domain.name },
|
||||
authInfo: { pw: { value: pw } }
|
||||
})
|
||||
|
||||
login_as :registrar2 do
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:msg].should == 'Command completed successfully'
|
||||
response[:result_code].should == '1000'
|
||||
end
|
||||
|
||||
domain.reload
|
||||
|
||||
domain.owner_contact.id.should == original_oc_id
|
||||
domain.owner_contact.code.should == original_oc_code
|
||||
domain.owner_contact.registrar_id.should == @registrar2.id
|
||||
|
||||
original_contacts_codes.should == domain.contacts.pluck(:code)
|
||||
|
||||
end
|
||||
|
||||
it 'should not creates transfer without password' do
|
||||
xml = domain_transfer_xml({
|
||||
name: { value: domain.name }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue