mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Add check if UpdateProhibited to nameserver bulk update
This commit is contained in:
parent
7063aa1210
commit
d3525acffe
2 changed files with 32 additions and 1 deletions
|
@ -153,7 +153,7 @@ class Registrar < ApplicationRecord
|
|||
puny = origin.domain.name_puny
|
||||
next unless domains.include?(idn) || domains.include?(puny) || domains.empty?
|
||||
|
||||
if origin.domain.nameservers.where(hostname: new_attributes[:hostname]).any?
|
||||
if domain_not_updatable?(hostname: new_attributes[:hostname], domain: origin.domain)
|
||||
failed_list << idn
|
||||
next
|
||||
end
|
||||
|
@ -202,6 +202,10 @@ class Registrar < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def domain_not_updatable?(hostname:, domain:)
|
||||
domain.nameservers.where(hostname: hostname).any? || domain.bulk_update_prohibited?
|
||||
end
|
||||
|
||||
def set_defaults
|
||||
self.language = Setting.default_language unless language
|
||||
end
|
||||
|
|
|
@ -34,6 +34,33 @@ class ReppV1RegistrarNameserversTest < ActionDispatch::IntegrationTest
|
|||
assert json[:data][:affected_domains].include? 'shop.test'
|
||||
end
|
||||
|
||||
def test_fails_to_update_if_prohibited
|
||||
domain = domains(:shop)
|
||||
domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED])
|
||||
nameserver = nameservers(:shop_ns1)
|
||||
payload = {
|
||||
"data": {
|
||||
"id": nameserver.hostname,
|
||||
"type": "nameserver",
|
||||
"attributes": {
|
||||
"hostname": "#{nameserver.hostname}.test",
|
||||
"ipv4": ["1.1.1.1"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
put '/repp/v1/registrar/nameservers', headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
assert_equal({ hostname: "#{nameserver.hostname}.test", ipv4: ["1.1.1.1"] }, json[:data][:attributes])
|
||||
assert_equal({ hostname: "#{nameserver.hostname}.test", ipv4: ["1.1.1.1"] }, json[:data][:attributes])
|
||||
assert json[:data][:affected_domains].include? 'airport.test'
|
||||
assert json[:data][:skipped_domains].include? 'shop.test'
|
||||
end
|
||||
|
||||
def test_nameserver_with_hostname_must_exist
|
||||
payload = {
|
||||
"data": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue