From a863c3c7baa9dd19726678b9079bf9a451acb6b8 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 23 Dec 2019 15:34:13 +0500 Subject: [PATCH] Fix epp domains controller to apply add or rem changes to status From this patch epp domains controller will allow to update domain statuses only if there is only one status - clientHold. This was made to allow usage of new ForceDelete procedures. --- app/controllers/epp/domains_controller.rb | 6 +++ .../epp/domain/update/base_test.rb | 50 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 2b708d66c..1295f558e 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -311,6 +311,7 @@ module Epp def status_editing_disabled return true if Setting.client_status_editing_enabled + return true if check_client_hold return true if params[:parsed_frame].css('status').empty? epp_errors << { code: '2306', @@ -318,6 +319,11 @@ module Epp } end + def check_client_hold + statuses = params[:parsed_frame].css('status').map { |element| element['s'] } + statuses == [::DomainStatus::CLIENT_HOLD] + end + def balance_ok?(operation, period = nil, unit = nil) @domain_pricelist = @domain.pricelist(operation, period.try(:to_i), unit) if @domain_pricelist.try(:price) # checking if price list is not found diff --git a/test/integration/epp/domain/update/base_test.rb b/test/integration/epp/domain/update/base_test.rb index 41c451373..3cdae2d52 100644 --- a/test/integration/epp/domain/update/base_test.rb +++ b/test/integration/epp/domain/update/base_test.rb @@ -303,6 +303,56 @@ class EppDomainUpdateBaseTest < EppTestCase assert @domain.inactive? end + def test_update_domain_allows_add_of_client_hold + request_xml = <<-XML + + + + + + shop.test + + Test + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + @domain.reload + assert_epp_response :completed_successfully + assert_includes(@domain.statuses, DomainStatus::CLIENT_HOLD) + end + + def test_update_domain_allows_remove_of_client_hold + @domain.update!(statuses: [DomainStatus::CLIENT_HOLD]) + + request_xml = <<-XML + + + + + + shop.test + + Test + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + @domain.reload + assert_epp_response :completed_successfully + assert_not_includes(@domain.statuses, DomainStatus::CLIENT_HOLD) + end + private def assert_verification_and_notification_emails