mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 13:15:40 +02:00
Merge pull request #2161 from internetee/2158-nameserver-bulk-addition
REPP: bulk nameservers addition
This commit is contained in:
commit
61df405560
12 changed files with 191 additions and 34 deletions
|
@ -32,7 +32,8 @@ class Registrar
|
||||||
end
|
end
|
||||||
|
|
||||||
def compose_notice_message(res)
|
def compose_notice_message(res)
|
||||||
notices = ["#{t('.replaced')}. #{t('.affected_domains')}: " \
|
action_text = params[:old_hostname].blank? ? t('.added') : t('.replaced')
|
||||||
|
notices = ["#{action_text}. #{t('.affected_domains')}: " \
|
||||||
"#{res[:data][:affected_domains].join(', ')}"]
|
"#{res[:data][:affected_domains].join(', ')}"]
|
||||||
|
|
||||||
notices << "#{t('.skipped_domains')}: #{res[:data][:skipped_domains].join(', ')}" if res[:data][:skipped_domains]
|
notices << "#{t('.skipped_domains')}: #{res[:data][:skipped_domains].join(', ')}" if res[:data][:skipped_domains]
|
||||||
|
@ -42,7 +43,7 @@ class Registrar
|
||||||
|
|
||||||
def csv_list_empty_guard
|
def csv_list_empty_guard
|
||||||
notice = 'CSV scoped domain list seems empty. Make sure that domains are added and ' \
|
notice = 'CSV scoped domain list seems empty. Make sure that domains are added and ' \
|
||||||
'"domain_name" header is present.'
|
'"Domain" header is present.'
|
||||||
redirect_to(registrar_domains_url, flash: { notice: notice })
|
redirect_to(registrar_domains_url, flash: { notice: notice })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,9 +53,9 @@ class Registrar
|
||||||
domains = []
|
domains = []
|
||||||
csv = CSV.read(params[:puny_file].path, headers: true)
|
csv = CSV.read(params[:puny_file].path, headers: true)
|
||||||
|
|
||||||
return [] if csv['domain_name'].blank?
|
return [] if csv['Domain'].blank?
|
||||||
|
|
||||||
csv.map { |b| domains << b['domain_name'] }
|
csv.map { |b| domains << b['Domain'] }
|
||||||
|
|
||||||
domains.compact
|
domains.compact
|
||||||
rescue CSV::MalformedCSVError
|
rescue CSV::MalformedCSVError
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Repp
|
||||||
desc 'bulk nameserver change'
|
desc 'bulk nameserver change'
|
||||||
param :data, Hash, required: true, desc: 'Object holding nameserver changes' do
|
param :data, Hash, required: true, desc: 'Object holding nameserver changes' do
|
||||||
param :type, String, required: true, desc: 'Always set as "nameserver"'
|
param :type, String, required: true, desc: 'Always set as "nameserver"'
|
||||||
param :id, String, required: true, desc: 'Hostname of replacable nameserver'
|
param :id, String, required: false, desc: 'Hostname of replacable nameserver'
|
||||||
param :domains, Array, required: false, desc: 'Array of domain names qualified for ' \
|
param :domains, Array, required: false, desc: 'Array of domain names qualified for ' \
|
||||||
'nameserver replacement'
|
'nameserver replacement'
|
||||||
param :attributes, Hash, required: true, desc: 'Object holding new nameserver values' do
|
param :attributes, Hash, required: true, desc: 'Object holding new nameserver values' do
|
||||||
|
@ -17,11 +17,16 @@ module Repp
|
||||||
param :ipv6, Array, of: String, required: false, desc: 'Array of fixed IPv6 addresses'
|
param :ipv6, Array, of: String, required: false, desc: 'Array of fixed IPv6 addresses'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def update
|
|
||||||
affected, errored = current_user.registrar
|
def update # rubocop:disable Metrics/MethodLength
|
||||||
.replace_nameservers(hostname,
|
affected, errored = if hostname.present?
|
||||||
hostname_params[:data][:attributes],
|
current_user.registrar.replace_nameservers(hostname,
|
||||||
domains: domains_from_params)
|
hostname_params[:data][:attributes],
|
||||||
|
domains: domains_from_params)
|
||||||
|
else
|
||||||
|
current_user.registrar.add_nameservers(hostname_params[:data][:attributes],
|
||||||
|
domains: domains_from_params)
|
||||||
|
end
|
||||||
|
|
||||||
render_success(data: data_format_for_success(affected, errored))
|
render_success(data: data_format_for_success(affected, errored))
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
|
@ -47,7 +52,7 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def hostname_params
|
def hostname_params
|
||||||
params.require(:data).require(%i[type id])
|
params.require(:data).require(%i[type])
|
||||||
params.require(:data).require(:attributes).require([:hostname])
|
params.require(:data).require(:attributes).require([:hostname])
|
||||||
|
|
||||||
params.permit(data: [
|
params.permit(data: [
|
||||||
|
@ -58,10 +63,12 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def hostname
|
def hostname
|
||||||
hostname_params[:data][:id]
|
hostname_params[:data][:id] || nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_nameserver_existance
|
def verify_nameserver_existance
|
||||||
|
return true if hostname.blank?
|
||||||
|
|
||||||
current_user.registrar.nameservers.find_by!(hostname: hostname)
|
current_user.registrar.nameservers.find_by!(hostname: hostname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Domain::BulkUpdatable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
def bulk_update_prohibited?
|
def bulk_update_prohibited?
|
||||||
discarded? || statuses_blocks_update?
|
statuses_blocks_update?
|
||||||
end
|
end
|
||||||
|
|
||||||
def statuses_blocks_update?
|
def statuses_blocks_update?
|
||||||
|
|
|
@ -43,6 +43,7 @@ class Registrar < ApplicationRecord
|
||||||
after_commit :update_whois_records
|
after_commit :update_whois_records
|
||||||
def update_whois_records
|
def update_whois_records
|
||||||
return true unless changed? && (changes.keys & WHOIS_TRIGGERS).present?
|
return true unless changed? && (changes.keys & WHOIS_TRIGGERS).present?
|
||||||
|
|
||||||
RegenerateRegistrarWhoisesJob.perform_later id
|
RegenerateRegistrarWhoisesJob.perform_later id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -159,10 +160,7 @@ class Registrar < ApplicationRecord
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
new_nameserver = Nameserver.new
|
create_nameserver(origin.domain, new_attributes)
|
||||||
new_nameserver.domain = origin.domain
|
|
||||||
new_nameserver.attributes = new_attributes
|
|
||||||
new_nameserver.save!
|
|
||||||
|
|
||||||
domain_scope.delete_if { |i| i == idn || i == puny }
|
domain_scope.delete_if { |i| i == idn || i == puny }
|
||||||
domain_list << idn
|
domain_list << idn
|
||||||
|
@ -175,6 +173,37 @@ class Registrar < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_nameservers(new_attributes, domains: [])
|
||||||
|
transaction do
|
||||||
|
return if domains.empty?
|
||||||
|
|
||||||
|
approved_list = domain_list_processing(domains: domains, new_attributes: new_attributes)
|
||||||
|
|
||||||
|
self.domains.where(name: approved_list).find_each(&:update_whois_record) if approved_list.any?
|
||||||
|
[approved_list.uniq.sort, (domains - approved_list).uniq.sort]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def domain_list_processing(domains:, new_attributes:)
|
||||||
|
approved_list = []
|
||||||
|
domains.each do |domain_name|
|
||||||
|
domain = self.domains.find_by('name = ? OR name_puny = ?', domain_name, domain_name)
|
||||||
|
|
||||||
|
next if domain.blank? || domain_not_updatable?(hostname: new_attributes[:hostname], domain: domain)
|
||||||
|
|
||||||
|
create_nameserver(domain, new_attributes)
|
||||||
|
approved_list << domain_name
|
||||||
|
end
|
||||||
|
approved_list
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_nameserver(domain, attributes)
|
||||||
|
new_nameserver = Nameserver.new
|
||||||
|
new_nameserver.domain = domain
|
||||||
|
new_nameserver.attributes = attributes
|
||||||
|
new_nameserver.save!
|
||||||
|
end
|
||||||
|
|
||||||
def vat_country=(country)
|
def vat_country=(country)
|
||||||
self.address_country_code = country.alpha2
|
self.address_country_code = country.alpha2
|
||||||
end
|
end
|
||||||
|
@ -198,6 +227,7 @@ class Registrar < ApplicationRecord
|
||||||
|
|
||||||
def billing_email
|
def billing_email
|
||||||
return contact_email if self[:billing_email].blank?
|
return contact_email if self[:billing_email].blank?
|
||||||
|
|
||||||
self[:billing_email]
|
self[:billing_email]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-md-2 control-label">
|
<div class="col-md-2 control-label">
|
||||||
<%= label_tag :old_hostname %>
|
<%= label_tag :old_hostname, t('.old_hostname') %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<%= text_field_tag :old_hostname, params[:old_hostname], required: true,
|
<%= text_field_tag :old_hostname, params[:old_hostname], required: false,
|
||||||
class: 'form-control' %>
|
class: 'form-control' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -32,8 +32,9 @@ en:
|
||||||
ident data ie for updating contact information.
|
ident data ie for updating contact information.
|
||||||
|
|
||||||
nameserver_form:
|
nameserver_form:
|
||||||
|
old_hostname: Old hostname (optional)
|
||||||
ip_hint: One IP per line
|
ip_hint: One IP per line
|
||||||
replace_btn: Replace nameserver
|
replace_btn: Replace/Add nameserver
|
||||||
help_btn: Toggle help
|
help_btn: Toggle help
|
||||||
help: >-
|
help: >-
|
||||||
Replace nameserver specified in the "old hostname" with the one in "new hostname" with
|
Replace nameserver specified in the "old hostname" with the one in "new hostname" with
|
||||||
|
|
|
@ -3,5 +3,6 @@ en:
|
||||||
nameservers:
|
nameservers:
|
||||||
update:
|
update:
|
||||||
replaced: Nameserver have been successfully replaced
|
replaced: Nameserver have been successfully replaced
|
||||||
|
added: Nameserver have been successfully added
|
||||||
affected_domains: Affected domains
|
affected_domains: Affected domains
|
||||||
skipped_domains: Untouched domains
|
skipped_domains: Untouched domains
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
domain_name
|
Domain
|
||||||
shop.test
|
shop.test
|
||||||
|
|
|
|
@ -38,7 +38,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_skip_discarded_domains
|
def test_skip_discarded_domains
|
||||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
domains(:airport).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||||
|
|
||||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||||
new_contact_id: @admin_new.code },
|
new_contact_id: @admin_new.code },
|
||||||
|
@ -61,8 +61,8 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_return_skipped_domains_in_alphabetical_order
|
def test_return_skipped_domains_in_alphabetical_order
|
||||||
domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
domains(:airport).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||||
|
|
||||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||||
new_contact_id: @admin_new.code },
|
new_contact_id: @admin_new.code },
|
||||||
|
|
|
@ -12,7 +12,7 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_skip_discarded_domains
|
def test_skip_discarded_domains
|
||||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
domains(:airport).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||||
|
|
||||||
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
|
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
|
||||||
new_contact_id: 'john-001' },
|
new_contact_id: 'john-001' },
|
||||||
|
@ -33,8 +33,8 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_return_skipped_domains_in_alphabetical_order
|
def test_return_skipped_domains_in_alphabetical_order
|
||||||
domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
domains(:airport).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||||
|
|
||||||
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
|
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
|
||||||
new_contact_id: 'john-001' },
|
new_contact_id: 'john-001' },
|
||||||
|
|
|
@ -34,6 +34,57 @@ class ReppV1RegistrarNameserversTest < ActionDispatch::IntegrationTest
|
||||||
assert json[:data][:affected_domains].include? 'shop.test'
|
assert json[:data][:affected_domains].include? 'shop.test'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_add_nameserver_values
|
||||||
|
nameserver = nameservers(:shop_ns1)
|
||||||
|
payload = {
|
||||||
|
"data": {
|
||||||
|
"type": 'nameserver',
|
||||||
|
"domains": ['shop.test'],
|
||||||
|
"attributes": {
|
||||||
|
"hostname": "#{nameserver.hostname}.testtest",
|
||||||
|
"ipv4": ['2.2.2.2']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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}.testtest", ipv4: ['2.2.2.2'] }, json[:data][:attributes])
|
||||||
|
assert json[:data][:affected_domains].include? 'shop.test'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_add_nameserver_values_to_array_of_domains
|
||||||
|
nameserver = nameservers(:shop_ns1)
|
||||||
|
airport_domain = domains(:airport)
|
||||||
|
airport_domain.update(statuses: [DomainStatus::FORCE_DELETE,
|
||||||
|
DomainStatus::SERVER_RENEW_PROHIBITED,
|
||||||
|
DomainStatus::SERVER_TRANSFER_PROHIBITED])
|
||||||
|
payload = {
|
||||||
|
"data": {
|
||||||
|
"type": 'nameserver',
|
||||||
|
"domains": ['shop.test', 'airport.test'],
|
||||||
|
"attributes": {
|
||||||
|
"hostname": "#{nameserver.hostname}.arraytest",
|
||||||
|
"ipv4": ['2.2.2.2']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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}.arraytest", ipv4: ['2.2.2.2'] }, json[:data][:attributes])
|
||||||
|
assert json[:data][:affected_domains].include? 'shop.test'
|
||||||
|
assert json[:data][:affected_domains].include? 'airport.test'
|
||||||
|
end
|
||||||
|
|
||||||
def test_fails_to_update_if_prohibited
|
def test_fails_to_update_if_prohibited
|
||||||
domain = domains(:shop)
|
domain = domains(:shop)
|
||||||
domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED])
|
domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED])
|
||||||
|
|
|
@ -31,7 +31,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
||||||
fill_in 'New hostname', with: 'new-ns.bestnames.test'
|
fill_in 'New hostname', with: 'new-ns.bestnames.test'
|
||||||
fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
|
fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
|
||||||
fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
|
fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
|
||||||
click_on 'Replace nameserver'
|
click_on 'Replace/Add nameserver'
|
||||||
|
|
||||||
assert_requested request_stub
|
assert_requested request_stub
|
||||||
assert_current_path registrar_domains_path
|
assert_current_path registrar_domains_path
|
||||||
|
@ -52,7 +52,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
||||||
fill_in 'New hostname', with: 'new hostname'
|
fill_in 'New hostname', with: 'new hostname'
|
||||||
fill_in 'ipv4', with: 'ipv4'
|
fill_in 'ipv4', with: 'ipv4'
|
||||||
fill_in 'ipv6', with: 'ipv6'
|
fill_in 'ipv6', with: 'ipv6'
|
||||||
click_on 'Replace nameserver'
|
click_on 'Replace/Add nameserver'
|
||||||
|
|
||||||
assert_text 'epic fail'
|
assert_text 'epic fail'
|
||||||
assert_field 'Old hostname', with: 'old hostname'
|
assert_field 'Old hostname', with: 'old hostname'
|
||||||
|
@ -63,7 +63,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
||||||
|
|
||||||
def test_replaces_nameservers_only_for_scoped_domains
|
def test_replaces_nameservers_only_for_scoped_domains
|
||||||
request_body = { data: { type: 'nameserver',
|
request_body = { data: { type: 'nameserver',
|
||||||
id: 'ns1.bestnames.test',
|
id: 'ns1.bestnames.test',
|
||||||
domains: ['shop.test'],
|
domains: ['shop.test'],
|
||||||
attributes: { hostname: 'new-ns.bestnames.test',
|
attributes: { hostname: 'new-ns.bestnames.test',
|
||||||
ipv4: %w[192.0.2.55 192.0.2.56],
|
ipv4: %w[192.0.2.55 192.0.2.56],
|
||||||
|
@ -87,7 +87,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
||||||
fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
|
fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
|
||||||
attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_ns_replacement.csv').to_s
|
attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_ns_replacement.csv').to_s
|
||||||
|
|
||||||
click_on 'Replace nameserver'
|
click_on 'Replace/Add nameserver'
|
||||||
|
|
||||||
assert_requested request_stub
|
assert_requested request_stub
|
||||||
assert_current_path registrar_domains_path
|
assert_current_path registrar_domains_path
|
||||||
|
@ -109,10 +109,76 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
||||||
attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'invalid_domains_for_ns_replacement.csv').to_s
|
attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'invalid_domains_for_ns_replacement.csv').to_s
|
||||||
|
|
||||||
assert_no_changes -> { nameserver.hostname } do
|
assert_no_changes -> { nameserver.hostname } do
|
||||||
click_on 'Replace nameserver'
|
click_on 'Replace/Add nameserver'
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_current_path registrar_domains_path
|
assert_current_path registrar_domains_path
|
||||||
assert_text 'CSV scoped domain list seems empty. Make sure that domains are added and "domain_name" header is present.'
|
assert_text 'CSV scoped domain list seems empty. Make sure that domains are added and "Domain" header is present.'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_adding_current_registrar_nameservers
|
||||||
|
request_body = { data: { type: 'nameserver',
|
||||||
|
id: '',
|
||||||
|
domains: [],
|
||||||
|
attributes: { hostname: 'new-ns2.bestnames.test',
|
||||||
|
ipv4: %w[192.0.2.55 192.0.2.56],
|
||||||
|
ipv6: %w[2001:db8::55 2001:db8::56] } } }
|
||||||
|
request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
|
||||||
|
headers: { 'Content-type' => Mime[:json] },
|
||||||
|
basic_auth: ['test_goodnames', 'testtest'])
|
||||||
|
.to_return(body: { data: {
|
||||||
|
type: 'nameserver',
|
||||||
|
id: 'new-ns2.bestnames.test',
|
||||||
|
affected_domains: ["airport.test", "shop.test"],
|
||||||
|
skipped_domains: []
|
||||||
|
}
|
||||||
|
}.to_json, status: 200)
|
||||||
|
|
||||||
|
visit registrar_domains_url
|
||||||
|
click_link 'Bulk change'
|
||||||
|
click_link 'Nameserver'
|
||||||
|
|
||||||
|
fill_in 'New hostname', with: 'new-ns2.bestnames.test'
|
||||||
|
fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
|
||||||
|
fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
|
||||||
|
click_on 'Replace/Add nameserver'
|
||||||
|
|
||||||
|
assert_requested request_stub
|
||||||
|
assert_current_path registrar_domains_path
|
||||||
|
assert_text 'Nameserver have been successfully added'
|
||||||
|
assert_text 'Affected domains: airport.test, shop.test'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_adding_nameservers_only_for_scoped_domains
|
||||||
|
request_body = { data: { type: 'nameserver',
|
||||||
|
id: '',
|
||||||
|
domains: ['shop.test'],
|
||||||
|
attributes: { hostname: 'new-ns1.bestnames.test',
|
||||||
|
ipv4: %w[192.0.2.55 192.0.2.56],
|
||||||
|
ipv6: %w[2001:db8::55 2001:db8::56] } } }
|
||||||
|
request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
|
||||||
|
headers: { 'Content-type' => Mime[:json] },
|
||||||
|
basic_auth: ['test_goodnames', 'testtest'])
|
||||||
|
.to_return(body: { data: {
|
||||||
|
type: 'nameserver',
|
||||||
|
id: 'new-ns1.bestnames.test',
|
||||||
|
affected_domains: ["shop.test"],
|
||||||
|
skipped_domains: []}}.to_json, status: 200)
|
||||||
|
|
||||||
|
visit registrar_domains_url
|
||||||
|
click_link 'Bulk change'
|
||||||
|
click_link 'Nameserver'
|
||||||
|
|
||||||
|
fill_in 'New hostname', with: 'new-ns1.bestnames.test'
|
||||||
|
fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
|
||||||
|
fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
|
||||||
|
attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_ns_replacement.csv').to_s
|
||||||
|
|
||||||
|
click_on 'Replace/Add nameserver'
|
||||||
|
|
||||||
|
assert_requested request_stub
|
||||||
|
assert_current_path registrar_domains_path
|
||||||
|
assert_text 'Nameserver have been successfully added'
|
||||||
|
assert_text 'Affected domains: shop.test'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue