From 8efb6b3d99f3fcb2d3fc5b5344798b6053313e20 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Wed, 4 Nov 2026 11:53:56 +0200 Subject: [PATCH] Compare full identity (code, type, country) on registrant change Domain update treated a registrant as unchanged when only ident matched, skipping verification for entities with the same code in another country or of another type. Use Contact#identical_to? instead (#2977) Co-Authored-By: Claude Sonnet 5.5 --- app/interactions/actions/domain_update.rb | 2 +- .../epp/domain/update/base_test.rb | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/app/interactions/actions/domain_update.rb b/app/interactions/actions/domain_update.rb index 59a02f3761..144884b542 100644 --- a/app/interactions/actions/domain_update.rb +++ b/app/interactions/actions/domain_update.rb @@ -66,7 +66,7 @@ def assign_new_registrant def replace_domain_registrant(new_registrant) return if domain.registrant == new_registrant - @changes_registrant = true if domain.registrant.ident != new_registrant.ident + @changes_registrant = true unless domain.registrant.identical_to?(new_registrant) if @changes_registrant && domain.registrant_change_prohibited? domain.add_epp_error(2304, 'status', DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED, I18n.t(:object_status_prohibits_operation)) diff --git a/test/integration/epp/domain/update/base_test.rb b/test/integration/epp/domain/update/base_test.rb index 17acd9bacb..e60c44d166 100644 --- a/test/integration/epp/domain/update/base_test.rb +++ b/test/integration/epp/domain/update/base_test.rb @@ -517,6 +517,14 @@ def test_domain_should_not_padding_if_registrant_update_with_same_ident refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE end + def test_asks_verification_when_registrant_has_same_ident_but_different_country_code + assert_registrant_change_verification_asked(ident_country_code: 'LV') + end + + def test_asks_verification_when_registrant_has_same_ident_but_different_ident_type + assert_registrant_change_verification_asked(ident_type: 'org') + end + def test_skips_verification_when_provided_registrant_is_the_same_as_current_one Setting.request_confirmation_on_registrant_change_enabled = true @@ -1185,4 +1193,44 @@ def test_does_not_allow_underage_admin_contact def assert_verification_and_notification_emails assert_emails 2 end + + def assert_registrant_change_verification_asked(different_attrs) + Setting.request_confirmation_on_registrant_change_enabled = true + + current = @domain.registrant + new_registrant = contacts(:william) + new_registrant.update_columns( + { ident: current.ident, ident_type: current.ident_type, + ident_country_code: current.ident_country_code }.merge(different_attrs) + ) + + request_xml = <<-XML + + + + + + #{@domain.name} + + #{new_registrant.code} + + + + + + #{'test' * 2000} + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + @domain.reload + + assert_epp_response :completed_successfully_action_pending + assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE + assert_equal current, @domain.registrant + end end