mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 09:21:43 +02:00
Merge pull request #1814 from internetee/add-guard-clause-to-mass-nameserver-change
Bulk NS change: Verify CSV integrity
This commit is contained in:
commit
22351c9053
12 changed files with 180 additions and 61 deletions
1
test/fixtures/files/invalid_domains_for_ns_replacement.csv
vendored
Normal file
1
test/fixtures/files/invalid_domains_for_ns_replacement.csv
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
shop.test
|
|
42
test/interactions/do_request_test.rb
Normal file
42
test/interactions/do_request_test.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DoRequestTest < ActiveSupport::TestCase
|
||||
|
||||
setup do
|
||||
WebMock.disable_net_connect!
|
||||
|
||||
@uri = URI.parse("#{ENV['repp_url']}registrar/nameservers")
|
||||
@request = Net::HTTP::Put.new(@uri, 'Content-Type' => 'application/json')
|
||||
@nameserver = nameservers(:shop_ns1)
|
||||
@domain = domains(:shop)
|
||||
@user = users(:api_bestnames)
|
||||
|
||||
@request.body = { data: { type: 'nameserver', id: @nameserver.hostname,
|
||||
domains: ["shop.test"],
|
||||
attributes: { hostname: 'new-ns.bestnames.test',
|
||||
ipv4: '192.0.2.55',
|
||||
ipv6: '2001:db8::55' } } }.to_json
|
||||
@request.basic_auth(@user.username, @user.plain_text_password)
|
||||
end
|
||||
|
||||
def test_request_occurs
|
||||
stub_request(:put, "http://epp:3000/repp/v1/registrar/nameservers").
|
||||
with(
|
||||
body: "{\"data\":{\"type\":\"nameserver\",\"id\":\"ns1.bestnames.test\",\"domains\":[\"shop.test\"],\"attributes\":{\"hostname\":\"new-ns.bestnames.test\",\"ipv4\":\"192.0.2.55\",\"ipv6\":\"2001:db8::55\"}}}",
|
||||
headers: {
|
||||
'Accept'=>'*/*',
|
||||
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
||||
'Authorization'=>'Basic dGVzdF9iZXN0bmFtZXM6dGVzdHRlc3Q=',
|
||||
'Content-Type'=>'application/json',
|
||||
'Host'=>'epp:3000',
|
||||
'User-Agent'=>'Ruby'
|
||||
}).
|
||||
to_return(status: 200, body: ["shop.test"], headers: {})
|
||||
|
||||
action = Actions::DoRequest.new(@request, @uri)
|
||||
response = action.call
|
||||
|
||||
assert_equal response.body, ["shop.test"]
|
||||
assert_equal response.code, "200"
|
||||
end
|
||||
end
|
|
@ -94,4 +94,25 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
|||
assert_text 'Nameserver have been successfully replaced'
|
||||
assert_text 'Affected domains: shop.test'
|
||||
end
|
||||
|
||||
def test_replaces_nameservers_with_invalid_domains_list
|
||||
nameserver = nameservers(:shop_ns1)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
click_link 'Nameserver'
|
||||
|
||||
fill_in 'Old hostname', with: nameserver.hostname
|
||||
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"
|
||||
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'
|
||||
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.'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue