mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
added abbility for added extenstions prohibited status
This commit is contained in:
parent
f9436062a6
commit
1bb5dddd58
10 changed files with 32 additions and 25 deletions
|
@ -8,9 +8,9 @@ module Api
|
||||||
before_action :authorized_to_manage_locks?
|
before_action :authorized_to_manage_locks?
|
||||||
|
|
||||||
def create
|
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)
|
render json: serialized_domain(@domain)
|
||||||
else
|
else
|
||||||
render json: { errors: [{ base: ['Domain cannot be locked'] }] },
|
render json: { errors: [{ base: ['Domain cannot be locked'] }] },
|
||||||
|
|
|
@ -11,12 +11,16 @@ module Domain::RegistryLockable
|
||||||
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
|
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_registry_lock
|
EXTENSIONS_STATUS = [DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED].freeze
|
||||||
|
|
||||||
|
|
||||||
|
def apply_registry_lock(extensionsProhibited:)
|
||||||
return unless registry_lockable?
|
return unless registry_lockable?
|
||||||
return if locked_by_registrant?
|
return if locked_by_registrant?
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
self.statuses |= LOCK_STATUSES
|
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
|
self.locked_by_registrant_at = Time.zone.now
|
||||||
alert_registrar_lock_changes!(lock: true)
|
alert_registrar_lock_changes!(lock: true)
|
||||||
|
|
||||||
|
@ -44,6 +48,9 @@ module Domain::RegistryLockable
|
||||||
LOCK_STATUSES.each do |domain_status|
|
LOCK_STATUSES.each do |domain_status|
|
||||||
statuses.delete([domain_status])
|
statuses.delete([domain_status])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
statuses.delete([EXTENSIONS_STATUS]) if statuses.include? EXTENSIONS_STATUS
|
||||||
|
|
||||||
self.locked_by_registrant_at = nil
|
self.locked_by_registrant_at = nil
|
||||||
self.statuses = admin_store_statuses_history || []
|
self.statuses = admin_store_statuses_history || []
|
||||||
alert_registrar_lock_changes!(lock: false)
|
alert_registrar_lock_changes!(lock: false)
|
||||||
|
|
|
@ -17,13 +17,13 @@ class RegistrantUser < User
|
||||||
Country.new(alpha2_code)
|
Country.new(alpha2_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
def companies(company_register = nil)
|
def companies(company_register = CompanyRegister::Client.new)
|
||||||
return [] if ident.include?('-')
|
return [] if ident.include?('-')
|
||||||
|
|
||||||
[OpenStruct.new(registration_number: '43344412', company_name: 'TestFirma'),
|
company_register.representation_rights(citizen_personal_code: ident,
|
||||||
OpenStruct.new(registration_number: '12345678', company_name: 'SuperFirma OU')]
|
citizen_country_code: country.alpha3)
|
||||||
end
|
end
|
||||||
|
|
||||||
def contacts(representable: true)
|
def contacts(representable: true)
|
||||||
Contact.registrant_user_contacts(self, representable: representable)
|
Contact.registrant_user_contacts(self, representable: representable)
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cannot_lock_an_already_locked_domain
|
def test_cannot_lock_an_already_locked_domain
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
assert(@domain.locked_by_registrant?)
|
assert(@domain.locked_by_registrant?)
|
||||||
|
|
||||||
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
|
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
|
||||||
|
|
|
@ -22,14 +22,14 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_registrant_locked_domain
|
def test_registrant_locked_domain
|
||||||
refute @domain.locked_by_registrant?
|
refute @domain.locked_by_registrant?
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
assert @domain.locked_by_registrant?
|
assert @domain.locked_by_registrant?
|
||||||
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been locked by registrant")
|
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been locked by registrant")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_registrant_unlocked_domain
|
def test_registrant_unlocked_domain
|
||||||
refute @domain.locked_by_registrant?
|
refute @domain.locked_by_registrant?
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
assert @domain.locked_by_registrant?
|
assert @domain.locked_by_registrant?
|
||||||
@domain.remove_registry_lock
|
@domain.remove_registry_lock
|
||||||
refute @domain.locked_by_registrant?
|
refute @domain.locked_by_registrant?
|
||||||
|
|
|
@ -16,7 +16,7 @@ class SerializersRegistrantApiDomainTest < ActiveSupport::TestCase
|
||||||
assert_not(@json[:locked_by_registrant_at])
|
assert_not(@json[:locked_by_registrant_at])
|
||||||
|
|
||||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
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)
|
serializer_for_locked_domain = Serializers::RegistrantApi::Domain.new(@domain.reload)
|
||||||
new_json = serializer_for_locked_domain.to_json
|
new_json = serializer_for_locked_domain.to_json
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
||||||
PaperTrail.request.whodunnit = @user.id_role_username
|
PaperTrail.request.whodunnit = @user.id_role_username
|
||||||
|
|
||||||
assert_difference '@domain.versions.count', 1 do
|
assert_difference '@domain.versions.count', 1 do
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(@domain.updator, @user)
|
assert_equal(@domain.updator, @user)
|
||||||
|
|
|
@ -18,7 +18,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remove_lockalable_statuses_after_admin_intervention
|
def test_remove_lockalable_statuses_after_admin_intervention
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
assert @domain.locked_by_registrant?
|
assert @domain.locked_by_registrant?
|
||||||
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
|
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
|
||||||
@domain.update(statuses: deleted_status)
|
@domain.update(statuses: deleted_status)
|
||||||
assert_not @domain.locked_by_registrant?
|
assert_not @domain.locked_by_registrant?
|
||||||
|
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
assert @domain.locked_by_registrant?
|
assert @domain.locked_by_registrant?
|
||||||
@domain.remove_registry_lock
|
@domain.remove_registry_lock
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
|
||||||
@domain.save
|
@domain.save
|
||||||
assert @domain.admin_store_statuses_history.include? DomainStatus::SERVER_UPDATE_PROHIBITED
|
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 @domain.locked_by_registrant?
|
||||||
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
|
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_additinal_status_for_locked_domain
|
def test_add_additinal_status_for_locked_domain
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
assert @domain.locked_by_registrant?
|
assert @domain.locked_by_registrant?
|
||||||
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
|
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
|
def test_lockable_domain_if_remove_some_prohibited_status
|
||||||
refute(@domain.locked_by_registrant?)
|
refute(@domain.locked_by_registrant?)
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
check_statuses_lockable_domain
|
check_statuses_lockable_domain
|
||||||
assert(@domain.locked_by_registrant?)
|
assert(@domain.locked_by_registrant?)
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_registry_lock_on_lockable_domain
|
def test_registry_lock_on_lockable_domain
|
||||||
refute(@domain.locked_by_registrant?)
|
refute(@domain.locked_by_registrant?)
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
|
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[DomainStatus::SERVER_UPDATE_PROHIBITED,
|
[DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||||
|
@ -99,21 +99,21 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_registry_lock_cannot_be_applied_twice
|
def test_registry_lock_cannot_be_applied_twice
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
refute(@domain.apply_registry_lock)
|
refute(@domain.apply_registry_lock(extensionsProhibited: false))
|
||||||
assert(@domain.locked_by_registrant?)
|
assert(@domain.locked_by_registrant?)
|
||||||
assert(@domain.locked_by_registrant_at)
|
assert(@domain.locked_by_registrant_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_registry_lock_cannot_be_applied_on_pending_statuses
|
def test_registry_lock_cannot_be_applied_on_pending_statuses
|
||||||
@domain.statuses << DomainStatus::PENDING_RENEW
|
@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?)
|
||||||
refute(@domain.locked_by_registrant_at)
|
refute(@domain.locked_by_registrant_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remove_registry_lock_on_locked_domain
|
def test_remove_registry_lock_on_locked_domain
|
||||||
@domain.apply_registry_lock
|
@domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
|
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[DomainStatus::SERVER_UPDATE_PROHIBITED,
|
[DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||||
|
|
|
@ -17,7 +17,7 @@ class AdminAreaRegistryLockTest < JavaScriptApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_can_remove_registry_lock_from_a_domain
|
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)
|
visit edit_admin_domain_path(@domain)
|
||||||
click_link_or_button('Actions')
|
click_link_or_button('Actions')
|
||||||
|
@ -34,7 +34,7 @@ class AdminAreaRegistryLockTest < JavaScriptApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cannot_remove_registry_lock_from_not_locked_domain
|
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)
|
visit edit_admin_domain_path(@domain)
|
||||||
@domain.remove_registry_lock
|
@domain.remove_registry_lock
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class AdminDomainsTestTest < ApplicationSystemTestCase
|
||||||
refute_text 'Registry lock time 2010-07-05 00:30'
|
refute_text 'Registry lock time 2010-07-05 00:30'
|
||||||
|
|
||||||
lockable_domain = domains(:airport)
|
lockable_domain = domains(:airport)
|
||||||
lockable_domain.apply_registry_lock
|
lockable_domain.apply_registry_lock(extensionsProhibited: false)
|
||||||
|
|
||||||
visit admin_domain_path(lockable_domain)
|
visit admin_domain_path(lockable_domain)
|
||||||
assert_text 'Registry lock time 2010-07-05 00:30'
|
assert_text 'Registry lock time 2010-07-05 00:30'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue