Skip to content

Commit

Permalink
Merge pull request #1977 from internetee/1885-server-release-prohibit…
Browse files Browse the repository at this point in the history
…ed-and-limit-the-effect-of-delete-prohibited

added feature permission for release if domain has status server-rele…
  • Loading branch information
vohmar authored May 18, 2021
2 parents bd93bbe + c22232c commit 6ae96be
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/domain/releasable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def releasable_domains
' AND ? != ALL(coalesce(statuses, array[]::varchar[]))',
Time.zone.today,
Time.zone.today,
DomainStatus::SERVER_DELETE_PROHIBITED)
DomainStatus::SERVER_RELEASE_PROHIBITED)
else
where('(delete_date <= ? OR force_delete_date <= ?)' \
' AND ? != ALL(coalesce(statuses, array[]::varchar[])) AND' \
' ? != ALL(COALESCE(statuses, array[]::varchar[]))',
Time.zone.today,
Time.zone.today,
DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::SERVER_RELEASE_PROHIBITED,
DomainStatus::DELETE_CANDIDATE)
end
end
Expand Down
9 changes: 6 additions & 3 deletions app/models/domain_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class DomainStatus < ApplicationRecord
include EppErrors
belongs_to :domain

SERVER_RELEASE_PROHIBITED = 'serverReleaseProhibited'

# Requests to delete the object MUST be rejected.
CLIENT_DELETE_PROHIBITED = 'clientDeleteProhibited'
SERVER_DELETE_PROHIBITED = 'serverDeleteProhibited'
Expand Down Expand Up @@ -81,7 +83,7 @@ class DomainStatus < ApplicationRecord
INACTIVE, OK, PENDING_CREATE, PENDING_DELETE, PENDING_DELETE_CONFIRMATION, PENDING_RENEW, PENDING_TRANSFER,
PENDING_UPDATE, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED,
SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, FORCE_DELETE,
DELETE_CANDIDATE, EXPIRED, DISPUTED
DELETE_CANDIDATE, EXPIRED, DISPUTED, SERVER_RELEASE_PROHIBITED
].freeze

CLIENT_STATUSES = [
Expand All @@ -92,7 +94,7 @@ class DomainStatus < ApplicationRecord
SERVER_STATUSES = [
SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED,
SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED,
SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED
SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, SERVER_RELEASE_PROHIBITED
].freeze

UPDATE_PROHIBIT_STATES = [
Expand Down Expand Up @@ -157,7 +159,8 @@ def admin_statuses_map
['AdminChangeProhibited', SERVER_ADMIN_CHANGE_PROHIBITED],
['TechChangeProhibited', SERVER_TECH_CHANGE_PROHIBITED],
['UpdateProhibited', SERVER_UPDATE_PROHIBITED],
['DeleteProhibited', SERVER_DELETE_PROHIBITED]
['DeleteProhibited', SERVER_DELETE_PROHIBITED],
['ReleaseProhibited', SERVER_RELEASE_PROHIBITED],
]
end

Expand Down
13 changes: 12 additions & 1 deletion test/models/domain/releasable/auctionable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,21 @@ def test_ignores_domains_with_delete_date_in_the_future
assert_not @domain.domain_name.at_auction?
end

def test_ignores_domains_with_server_delete_prohibited_status
def test_does_not_ignore_domains_with_server_delete_prohibited_status
@domain.update!(delete_date: '2010-07-04', statuses: [DomainStatus::SERVER_DELETE_PROHIBITED])
travel_to Time.zone.parse('2010-07-05')

assert_changes 'Domain.count' do
Domain.release_domains
end

assert @domain.domain_name.at_auction?
end

def test_ignores_domains_with_server_release_prohibited_status
@domain.update!(delete_date: '2010-07-04', statuses: [DomainStatus::SERVER_RELEASE_PROHIBITED])
travel_to Time.zone.parse('2010-07-05')

assert_no_difference 'Domain.count' do
Domain.release_domains
end
Expand Down
12 changes: 11 additions & 1 deletion test/models/domain/releasable/discardable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,23 @@ def test_ignores_already_discarded_domains
end
end

def test_ignores_domains_with_server_delete_prohibited_status
def test_does_not_ignore_domains_with_server_delete_prohibited_status
@domain.update!(delete_date: '2010-07-04', statuses: [DomainStatus::SERVER_DELETE_PROHIBITED])
travel_to Time.zone.parse('2010-07-05')

Domain.release_domains
@domain.reload

assert @domain.discarded?
end

def test_ignores_domains_with_server_release_prohibited_status
@domain.update!(delete_date: '2010-07-04', statuses: [DomainStatus::SERVER_RELEASE_PROHIBITED])
travel_to Time.zone.parse('2010-07-05')

Domain.release_domains
@domain.reload

assert_not @domain.discarded?
end

Expand Down

0 comments on commit 6ae96be

Please sign in to comment.