mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
Merge pull request #1886 from internetee/1882-domain-renew-removes-serverupdateprohibited-status-epp
Test: added test for bulk renew ehrn domain has renew prohibited status
This commit is contained in:
commit
134ace00ed
2 changed files with 48 additions and 2 deletions
|
@ -247,7 +247,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :version_domain_versions do
|
||||
resources :version_domain_versions, path: '/domain_versions' do
|
||||
collection do
|
||||
get 'search' => 'domain_versions#search', via: [:get, :post], as: :search
|
||||
end
|
||||
|
@ -259,7 +259,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :version_contact_versions do
|
||||
resources :version_contact_versions, path: '/contact_versions' do
|
||||
collection do
|
||||
get 'search' => 'contact_versions#search', via: [:get, :post], as: :search
|
||||
end
|
||||
|
|
|
@ -60,6 +60,20 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
|
|||
assert_equal domain.statuses, [DomainStatus::CLIENT_UPDATE_PROHIBITED, DomainStatus::SERVER_UPDATE_PROHIBITED]
|
||||
end
|
||||
|
||||
def test_multi_domains_сannot_be_renewed_with_renew_prohibited_status
|
||||
array_domains = [domains(:shop), domains(:airport)]
|
||||
payload = {
|
||||
"domains": array_domains.pluck(:name),
|
||||
"renew_period": "1y"
|
||||
}
|
||||
|
||||
array_domains.each do |domain|
|
||||
set_status_for_domain(domain, [DomainStatus::CLIENT_RENEW_PROHIBITED, DomainStatus::SERVER_RENEW_PROHIBITED])
|
||||
end
|
||||
|
||||
assert_renew_prohibited_domains(array_domains, payload)
|
||||
end
|
||||
|
||||
def test_throws_error_when_domain_not_renewable
|
||||
payload = {
|
||||
"domains": [
|
||||
|
@ -111,4 +125,36 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 2005, json[:code]
|
||||
assert_equal 'Invalid renew period', json[:message]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_status_for_domain(domain, statuses)
|
||||
domain.update(statuses: statuses)
|
||||
|
||||
if statuses.size > 1
|
||||
statuses.each do |status|
|
||||
assert domain.statuses.include? status
|
||||
end
|
||||
else
|
||||
assert domain.statuses.include? statuses
|
||||
end
|
||||
end
|
||||
|
||||
def bulk_renew(payload)
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def assert_renew_prohibited_domains(domains, payload)
|
||||
assert_no_changes -> { Domain.where(name: domains).pluck(:valid_to) } do
|
||||
json = bulk_renew(payload)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2002, json[:code]
|
||||
assert domains.all? do |domain|
|
||||
json[:message].include? "Domain renew error for #{domain.name}"
|
||||
end
|
||||
assert json[:data].empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue