From 851a2d6a2aa154171653615241985998578e9bad Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 6 Jan 2020 16:58:55 +0500 Subject: [PATCH] Allow ForceDelete status not to block domain update --- app/models/domain.rb | 15 +++++++++------ app/models/epp/domain.rb | 3 ++- test/integration/epp/domain/update/base_test.rb | 4 +++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index c14d1bc4d..50f41c38a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -116,12 +116,15 @@ class Domain < ApplicationRecord attr_accessor :is_admin - validate :check_permissions, :unless => :is_admin - def check_permissions - return unless force_delete_scheduled? - errors.add(:base, I18n.t(:object_status_prohibits_operation)) - false - end + # Removed to comply new ForceDelete procedure + # at https://github.com/internetee/registry/issues/1428#issuecomment-570561967 + # + # validate :check_permissions, :unless => :is_admin + # def check_permissions + # return unless force_delete_scheduled? + # errors.add(:base, I18n.t(:object_status_prohibits_operation)) + # false + # end validates :nameservers, domain_nameserver: { min: -> { Setting.ns_min_count }, diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 176e5710d..dc80b2e40 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -9,7 +9,8 @@ class Epp::Domain < Domain def manage_permissions return if is_admin # this bad hack for 109086524, refactor later return true if is_transfer || is_renewal - return unless update_prohibited? || delete_prohibited? + return unless update_prohibited? + stat = (statuses & (DomainStatus::UPDATE_PROHIBIT_STATES + DomainStatus::DELETE_PROHIBIT_STATES)).first add_epp_error('2304', 'status', stat, I18n.t(:object_status_prohibits_operation)) throw(:abort) diff --git a/test/integration/epp/domain/update/base_test.rb b/test/integration/epp/domain/update/base_test.rb index 3cdae2d52..9e533a501 100644 --- a/test/integration/epp/domain/update/base_test.rb +++ b/test/integration/epp/domain/update/base_test.rb @@ -328,7 +328,9 @@ class EppDomainUpdateBaseTest < EppTestCase end def test_update_domain_allows_remove_of_client_hold - @domain.update!(statuses: [DomainStatus::CLIENT_HOLD]) + @domain.update!(statuses: [DomainStatus::CLIENT_HOLD, DomainStatus::FORCE_DELETE, + DomainStatus::SERVER_RENEW_PROHIBITED, + DomainStatus::SERVER_TRANSFER_PROHIBITED]) request_xml = <<-XML