diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index c4d70c2ee..ad96adc64 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -162,6 +162,9 @@ class Epp::Domain < Domain at[:admin_domain_contacts_attributes] = admin_domain_contacts_attrs(frame, action) at[:tech_domain_contacts_attributes] = tech_domain_contacts_attrs(frame, action) + check_for_same_contacts(at[:admin_domain_contacts_attributes], 'admin') + check_for_same_contacts(at[:tech_domain_contacts_attributes], 'tech') + pw = frame.css('authInfo > pw').text at[:transfer_code] = pw if pw.present? @@ -176,6 +179,11 @@ class Epp::Domain < Domain at end + def check_for_same_contacts(contacts, contact_type) + return unless contacts.uniq.count != contacts.count + + add_epp_error('2306', contact_type, nil, %i[domain_contacts invalid]) + end # Adding legal doc to domain and # if something goes wrong - raise Rollback error diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index c0cef74b8..cbbd8a57d 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -120,34 +120,33 @@ class EppDomainCreateBaseTest < EppTestCase registrant = contact.becomes(Registrant) request_xml = <<-XML - - - - - - #{name} - #{registrant.code} - #{contact.code} - #{contact.code} - #{contact.code} - #{contact.code} - - - - - #{'test' * 2000} - - - - - XML + + + + + + #{name} + #{registrant.code} + #{contact.code} + #{contact.code} + #{contact.code} + #{contact.code} + + + + + #{'test' * 2000} + + + + + XML - - - assert_no_difference 'Domain.count' do - post epp_create_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + assert_no_difference 'Domain.count' do + post epp_create_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end + assert_epp_response :parameter_value_policy_error end @@ -180,7 +179,7 @@ class EppDomainCreateBaseTest < EppTestCase XML - + assert_no_difference 'Domain.count' do post epp_create_path, params: { frame: request_xml },