Revert "Merge pull request #1902 from internetee/1900-removing-registry-lock-should-not-remove-statuses-set-prior-to-setting-it"

This reverts commit f6fcf15fff, reversing
changes made to 26618a3c90.
This commit is contained in:
Alex Sherman 2021-04-14 12:31:26 +05:00
parent c1dba6c8f6
commit eac7dd352b
14 changed files with 10 additions and 172 deletions

View file

@ -2,12 +2,10 @@ module Domains
module CancelForceDelete
class RemoveForceDeleteStatuses < Base
def execute
domain_statuses = [DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED,
DomainStatus::CLIENT_HOLD]
rejected_statuses = domain.statuses.reject { |a| domain_statuses.include? a }
domain.statuses = rejected_statuses
domain.statuses.delete(DomainStatus::FORCE_DELETE)
domain.statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED)
domain.statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
domain.statuses.delete(DomainStatus::CLIENT_HOLD)
domain.save(validate: false)
end
end

View file

@ -2,10 +2,8 @@ module Domains
module CancelForceDelete
class RestoreStatusesBeforeForceDelete < Base
def execute
# domain.statuses = domain.statuses_before_force_delete
domain.statuses = domain.force_delete_domain_statuses_history || []
domain.statuses = domain.statuses_before_force_delete
domain.statuses_before_force_delete = nil
domain.force_delete_domain_statuses_history = nil
domain.save(validate: false)
end
end

View file

@ -6,7 +6,6 @@ module Domains
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
def execute
domain.force_delete_domain_statuses_history = domain.statuses
domain.statuses_before_force_delete = domain.statuses
domain.statuses |= STATUSES_TO_SET
domain.save(validate: false)

View file

@ -1,10 +1,6 @@
module Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
extend ActiveSupport::Concern
FORCE_DELETE_STATUSES = [DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
included do
store_accessor :force_delete_data,
:force_delete_type,
@ -56,7 +52,6 @@ module Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
def cancel_force_delete
Domains::CancelForceDelete::CancelForceDelete.run(domain: self)
# self.statuses = force_delete_domain_statuses_history
end
def outzone_date

View file

@ -36,10 +36,9 @@ module Domain::RegistryLockable
transaction do
LOCK_STATUSES.each do |domain_status|
statuses.delete([domain_status])
statuses.delete(domain_status)
end
self.locked_by_registrant_at = nil
self.statuses = admin_store_statuses_history || []
alert_registrar_lock_changes!(lock: false)
save!

View file

@ -12,18 +12,10 @@ class Domain < ApplicationRecord
include Domain::Disputable
include Domain::BulkUpdatable
LOCK_STATUSES = [DomainStatus::SERVER_UPDATE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
attr_accessor :roles
attr_accessor :legal_document_id
store_accessor :json_statuses_history,
:force_delete_domain_statuses_history,
:admin_store_statuses_history
alias_attribute :on_hold_time, :outzone_at
alias_attribute :outzone_time, :outzone_at
alias_attribute :auth_info, :transfer_code # Old attribute name; for PaperTrail
@ -559,23 +551,8 @@ class Domain < ApplicationRecord
statuses.include?(DomainStatus::FORCE_DELETE)
end
def update_unless_locked_by_registrant(update)
update(admin_store_statuses_history: update) unless locked_by_registrant?
end
def update_not_by_locked_statuses(update)
return unless locked_by_registrant?
result = update.reject { |status| LOCK_STATUSES.include? status }
update(admin_store_statuses_history: result)
end
# special handling for admin changing status
def admin_status_update(update)
update_unless_locked_by_registrant(update)
update_not_by_locked_statuses(update)
# check for deleted status
statuses.each do |s|
unless update.include? s

View file

@ -1,13 +0,0 @@
class TransferDomainStatusesBeforeForceDeleteToJsonHistory < ActiveRecord::Migration[6.0]
def up
domains = Domain.where.not(statuses_before_force_delete: nil)
domains.each do |domain|
domain.force_delete_domain_statuses_history = domain.statuses_before_force_delete
domain.save
end
end
def down
# raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -1,13 +0,0 @@
class TransferDataFromDomainStatusesToAdminStatusHistory < ActiveRecord::Migration[6.0]
def up
domains = Domain.all.select { |d| !d.locked_by_registrant?}
domains.each do |domain|
domain.admin_store_statuses_history = domain.statuses
domain.save
end
end
def down
# raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -1,2 +1 @@
# encoding: UTF-8
DataMigrate::Data.define(version: 20210405081552)
DataMigrate::Data.define(version: 20201007104651)

View file

@ -1,6 +0,0 @@
class AddJsonStatusesHistoryFieldToDomain < ActiveRecord::Migration[6.0]
def change
add_column :domains, :json_statuses_history, :jsonb
add_index :domains, :json_statuses_history, using: :gin
end
end

View file

@ -843,8 +843,7 @@ CREATE TABLE public.domains (
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
locked_by_registrant_at timestamp without time zone,
force_delete_start timestamp without time zone,
force_delete_data public.hstore,
json_statuses_history jsonb
force_delete_data public.hstore
);
@ -4125,17 +4124,6 @@ CREATE INDEX index_domain_transfers_on_domain_id ON public.domain_transfers USIN
CREATE INDEX index_domains_on_delete_date ON public.domains USING btree (delete_date);
-- Name: index_domains_on_json_statuses_history; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_domains_on_json_statuses_history ON public.domains USING gin (json_statuses_history);
--
-- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: -
--
-- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@ -5313,5 +5301,4 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200916125326'),
('20200917104213'),
('20210215101019'),
('20200921084356'),
('20210405100631');
('20200921084356');

View file

@ -12,29 +12,6 @@ class ForceDeleteTest < ActionMailer::TestCase
Truemail.configure.default_validation_type = @old_validation_type
end
def test_restore_domain_statuses_after_soft_force_delete
@domain.update(statuses: [DomainStatus::SERVER_RENEW_PROHIBITED])
@domain.schedule_force_delete(type: :soft)
assert @domain.force_delete_scheduled?
assert @domain.force_delete_domain_statuses_history.include? DomainStatus::SERVER_RENEW_PROHIBITED
@domain.cancel_force_delete
assert @domain.statuses.include? DomainStatus::SERVER_RENEW_PROHIBITED
end
def test_clear_force_delete_domain_statuses_history
@domain.update(statuses: [DomainStatus::SERVER_RENEW_PROHIBITED])
@domain.schedule_force_delete(type: :soft)
assert @domain.force_delete_scheduled?
assert @domain.force_delete_domain_statuses_history.include? DomainStatus::SERVER_RENEW_PROHIBITED
@domain.cancel_force_delete
assert_nil @domain.force_delete_domain_statuses_history
end
def test_schedules_force_delete_fast_track
assert_not @domain.force_delete_scheduled?
travel_to Time.zone.parse('2010-07-05')

View file

@ -3,6 +3,7 @@ require 'test_helper'
class DomainRegistryLockableTest < ActiveSupport::TestCase
def setup
super
@domain = domains(:airport)
end
@ -32,56 +33,6 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
assert_not(@domain.locked_by_registrant?)
end
def test_remove_lockalable_statuses_after_admin_intervention
@domain.apply_registry_lock
assert @domain.locked_by_registrant?
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
deleted_status = @domain.statuses - [DomainStatus::SERVER_DELETE_PROHIBITED]
@domain.update(statuses: deleted_status)
assert_not @domain.locked_by_registrant?
@domain.apply_registry_lock
assert @domain.locked_by_registrant?
@domain.remove_registry_lock
assert_not @domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED
assert_not @domain.statuses.include? DomainStatus::SERVER_TRANSFER_PROHIBITED
assert_not @domain.statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
end
def test_restore_domain_statuses_after_unlock
@domain.statuses = [DomainStatus::SERVER_UPDATE_PROHIBITED]
@domain.admin_store_statuses_history = [DomainStatus::SERVER_UPDATE_PROHIBITED]
@domain.save
assert @domain.admin_store_statuses_history.include? DomainStatus::SERVER_UPDATE_PROHIBITED
@domain.apply_registry_lock
assert @domain.locked_by_registrant?
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
@domain.remove_registry_lock
assert @domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED
assert_not @domain.statuses.include? DomainStatus::SERVER_TRANSFER_PROHIBITED
assert_not @domain.statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
end
def test_add_additinal_status_for_locked_domain
@domain.apply_registry_lock
assert @domain.locked_by_registrant?
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
@domain.statuses += [DomainStatus::SERVER_RENEW_PROHIBITED]
@domain.admin_store_statuses_history = [DomainStatus::SERVER_RENEW_PROHIBITED]
@domain.save
@domain.remove_registry_lock
assert @domain.statuses.include? DomainStatus::SERVER_RENEW_PROHIBITED
assert_not @domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED
assert_not @domain.statuses.include? DomainStatus::SERVER_TRANSFER_PROHIBITED
assert_not @domain.statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
end
def test_registry_lock_on_lockable_domain
refute(@domain.locked_by_registrant?)
@domain.apply_registry_lock

View file

@ -27,16 +27,6 @@ class DomainTest < ActiveSupport::TestCase
assert domains(:invalid).invalid?
end
def test_valid_domain_statuses_history
@domain.force_delete_domain_statuses_history = [DomainStatus::SERVER_UPDATE_PROHIBITED, DomainStatus::SERVER_TRANSFER_PROHIBITED]
@domain.admin_store_statuses_history = [DomainStatus::SERVER_UPDATE_PROHIBITED]
assert @domain.valid?
assert @domain.json_statuses_history['force_delete_domain_statuses_history'].include? 'serverUpdateProhibited'
assert @domain.json_statuses_history['force_delete_domain_statuses_history'].include? 'serverTransferProhibited'
assert_equal @domain.json_statuses_history['admin_store_statuses_history'], ['serverUpdateProhibited']
end
# https://www.internet.ee/domeenid/ee-domeenireeglid#domeeninimede-registreerimine
def test_validates_name_format
assert_equal dns_zones(:one).origin, 'test'