Skip to content

Commit

Permalink
Revert "Merge pull request #1902 from internetee/1900-removing-regist…
Browse files Browse the repository at this point in the history
…ry-lock-should-not-remove-statuses-set-prior-to-setting-it"

This reverts commit f6fcf15, reversing
changes made to 26618a3.
  • Loading branch information
yulgolem committed Apr 14, 2021
1 parent c1dba6c commit eac7dd3
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/interactions/domains/force_delete/prepare_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class PrepareDomain < Base
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)
Expand Down
5 changes: 0 additions & 5 deletions app/models/concerns/domain/force_delete.rb
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -56,7 +52,6 @@ def schedule_force_delete(type: :fast_track, notify_by_email: false, reason: nil

def cancel_force_delete
Domains::CancelForceDelete::CancelForceDelete.run(domain: self)
# self.statuses = force_delete_domain_statuses_history
end

def outzone_date
Expand Down
3 changes: 1 addition & 2 deletions app/models/concerns/domain/registry_lockable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ def remove_registry_lock

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!
Expand Down
23 changes: 0 additions & 23 deletions app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -559,23 +551,8 @@ def delete_prohibited?
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
Expand Down

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# encoding: UTF-8
DataMigrate::Data.define(version: 20210405081552)
DataMigrate::Data.define(version: 20201007104651)

This file was deleted.

17 changes: 2 additions & 15 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);


Expand Down Expand Up @@ -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:
--
Expand Down Expand Up @@ -5313,5 +5301,4 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200916125326'),
('20200917104213'),
('20210215101019'),
('20200921084356'),
('20210405100631');
('20200921084356');
23 changes: 0 additions & 23 deletions test/models/domain/force_delete_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
51 changes: 1 addition & 50 deletions test/models/domain/registry_lockable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class DomainRegistryLockableTest < ActiveSupport::TestCase
def setup
super

@domain = domains(:airport)
end

Expand Down Expand Up @@ -32,56 +33,6 @@ def test_lockable_domain_if_remove_some_prohibited_status
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
Expand Down
10 changes: 0 additions & 10 deletions test/models/domain_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ def test_invalid_fixture_is_invalid
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'
Expand Down

0 comments on commit eac7dd3

Please sign in to comment.