Merge pull request #2161 from internetee/2158-nameserver-bulk-addition

REPP: bulk nameservers addition
This commit is contained in:
Timo Võhmar 2021-09-29 18:41:18 +03:00 committed by GitHub
commit 61df405560
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 191 additions and 34 deletions

View file

@ -1,2 +1,2 @@
domain_name
Domain
shop.test

1 domain_name Domain
2 shop.test shop.test

View file

@ -38,7 +38,7 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest
end
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,
new_contact_id: @admin_new.code },
@ -61,8 +61,8 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest
end
def test_return_skipped_domains_in_alphabetical_order
domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
domains(:airport).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
new_contact_id: @admin_new.code },

View file

@ -12,7 +12,7 @@ class APIDomainContactsTest < ApplicationIntegrationTest
end
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',
new_contact_id: 'john-001' },
@ -33,8 +33,8 @@ class APIDomainContactsTest < ApplicationIntegrationTest
end
def test_return_skipped_domains_in_alphabetical_order
domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
domains(:airport).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'john-001' },

View file

@ -34,6 +34,57 @@ class ReppV1RegistrarNameserversTest < ActionDispatch::IntegrationTest
assert json[:data][:affected_domains].include? 'shop.test'
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
domain = domains(:shop)
domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED])

View file

@ -31,7 +31,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
fill_in 'New hostname', with: 'new-ns.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 nameserver'
click_on 'Replace/Add nameserver'
assert_requested request_stub
assert_current_path registrar_domains_path
@ -52,7 +52,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
fill_in 'New hostname', with: 'new hostname'
fill_in 'ipv4', with: 'ipv4'
fill_in 'ipv6', with: 'ipv6'
click_on 'Replace nameserver'
click_on 'Replace/Add nameserver'
assert_text 'epic fail'
assert_field 'Old hostname', with: 'old hostname'
@ -63,7 +63,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
def test_replaces_nameservers_only_for_scoped_domains
request_body = { data: { type: 'nameserver',
id: 'ns1.bestnames.test',
id: 'ns1.bestnames.test',
domains: ['shop.test'],
attributes: { hostname: 'new-ns.bestnames.test',
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"
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_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
assert_no_changes -> { nameserver.hostname } do
click_on 'Replace nameserver'
click_on 'Replace/Add nameserver'
end
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_current_path registrar_domains_path
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