added abbility for added extenstions prohibited status

This commit is contained in:
olegphenomenon 2021-09-21 16:45:09 +03:00
parent f9436062a6
commit 1bb5dddd58
10 changed files with 32 additions and 25 deletions

View file

@ -8,9 +8,9 @@ module Api
before_action :authorized_to_manage_locks?
def create
p "============"
extensionsProhibited = params[:extensionsProhibited]
if @domain.apply_registry_lock
if @domain.apply_registry_lock(extensionsProhibited: extensionsProhibited.to_s.downcase == "true")
render json: serialized_domain(@domain)
else
render json: { errors: [{ base: ['Domain cannot be locked'] }] },

View file

@ -11,12 +11,16 @@ module Domain::RegistryLockable
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
end
def apply_registry_lock
EXTENSIONS_STATUS = [DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED].freeze
def apply_registry_lock(extensionsProhibited:)
return unless registry_lockable?
return if locked_by_registrant?
transaction do
self.statuses |= LOCK_STATUSES
self.statuses |= EXTENSIONS_STATUS if Feature.obj_and_extensions_statuses_enabled? and extensionsProhibited
self.locked_by_registrant_at = Time.zone.now
alert_registrar_lock_changes!(lock: true)
@ -44,6 +48,9 @@ module Domain::RegistryLockable
LOCK_STATUSES.each do |domain_status|
statuses.delete([domain_status])
end
statuses.delete([EXTENSIONS_STATUS]) if statuses.include? EXTENSIONS_STATUS
self.locked_by_registrant_at = nil
self.statuses = admin_store_statuses_history || []
alert_registrar_lock_changes!(lock: false)

View file

@ -17,11 +17,11 @@ class RegistrantUser < User
Country.new(alpha2_code)
end
def companies(company_register = nil)
def companies(company_register = CompanyRegister::Client.new)
return [] if ident.include?('-')
[OpenStruct.new(registration_number: '43344412', company_name: 'TestFirma'),
OpenStruct.new(registration_number: '12345678', company_name: 'SuperFirma OU')]
company_register.representation_rights(citizen_personal_code: ident,
citizen_country_code: country.alpha3)
end
def contacts(representable: true)

View file

@ -47,7 +47,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
end
def test_cannot_lock_an_already_locked_domain
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert(@domain.locked_by_registrant?)
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',

View file

@ -22,14 +22,14 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
def test_registrant_locked_domain
refute @domain.locked_by_registrant?
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert @domain.locked_by_registrant?
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been locked by registrant")
end
def test_registrant_unlocked_domain
refute @domain.locked_by_registrant?
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert @domain.locked_by_registrant?
@domain.remove_registry_lock
refute @domain.locked_by_registrant?

View file

@ -16,7 +16,7 @@ class SerializersRegistrantApiDomainTest < ActiveSupport::TestCase
assert_not(@json[:locked_by_registrant_at])
travel_to Time.zone.parse('2010-07-05 10:30')
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
serializer_for_locked_domain = Serializers::RegistrantApi::Domain.new(@domain.reload)
new_json = serializer_for_locked_domain.to_json

View file

@ -31,7 +31,7 @@ class DomainVersionTest < ActiveSupport::TestCase
PaperTrail.request.whodunnit = @user.id_role_username
assert_difference '@domain.versions.count', 1 do
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
end
assert_equal(@domain.updator, @user)

View file

@ -18,7 +18,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
end
def test_remove_lockalable_statuses_after_admin_intervention
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert @domain.locked_by_registrant?
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
@ -26,7 +26,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
@domain.update(statuses: deleted_status)
assert_not @domain.locked_by_registrant?
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert @domain.locked_by_registrant?
@domain.remove_registry_lock
@ -41,7 +41,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
@domain.save
assert @domain.admin_store_statuses_history.include? DomainStatus::SERVER_UPDATE_PROHIBITED
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert @domain.locked_by_registrant?
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
@ -52,7 +52,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
end
def test_add_additinal_status_for_locked_domain
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert @domain.locked_by_registrant?
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
@ -69,7 +69,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
def test_lockable_domain_if_remove_some_prohibited_status
refute(@domain.locked_by_registrant?)
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
check_statuses_lockable_domain
assert(@domain.locked_by_registrant?)
@ -85,7 +85,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
def test_registry_lock_on_lockable_domain
refute(@domain.locked_by_registrant?)
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert_equal(
[DomainStatus::SERVER_UPDATE_PROHIBITED,
@ -99,21 +99,21 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
end
def test_registry_lock_cannot_be_applied_twice
@domain.apply_registry_lock
refute(@domain.apply_registry_lock)
@domain.apply_registry_lock(extensionsProhibited: false)
refute(@domain.apply_registry_lock(extensionsProhibited: false))
assert(@domain.locked_by_registrant?)
assert(@domain.locked_by_registrant_at)
end
def test_registry_lock_cannot_be_applied_on_pending_statuses
@domain.statuses << DomainStatus::PENDING_RENEW
refute(@domain.apply_registry_lock)
refute(@domain.apply_registry_lock(extensionsProhibited: false))
refute(@domain.locked_by_registrant?)
refute(@domain.locked_by_registrant_at)
end
def test_remove_registry_lock_on_locked_domain
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
assert_equal(
[DomainStatus::SERVER_UPDATE_PROHIBITED,

View file

@ -17,7 +17,7 @@ class AdminAreaRegistryLockTest < JavaScriptApplicationSystemTestCase
end
def test_can_remove_registry_lock_from_a_domain
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
visit edit_admin_domain_path(@domain)
click_link_or_button('Actions')
@ -34,7 +34,7 @@ class AdminAreaRegistryLockTest < JavaScriptApplicationSystemTestCase
end
def test_cannot_remove_registry_lock_from_not_locked_domain
@domain.apply_registry_lock
@domain.apply_registry_lock(extensionsProhibited: false)
visit edit_admin_domain_path(@domain)
@domain.remove_registry_lock

View file

@ -20,7 +20,7 @@ class AdminDomainsTestTest < ApplicationSystemTestCase
refute_text 'Registry lock time 2010-07-05 00:30'
lockable_domain = domains(:airport)
lockable_domain.apply_registry_lock
lockable_domain.apply_registry_lock(extensionsProhibited: false)
visit admin_domain_path(lockable_domain)
assert_text 'Registry lock time 2010-07-05 00:30'