Merge remote-tracking branch 'origin/master' into 1739-ns-bulk-change-test-and-whois-update

This commit is contained in:
Karl Erik Õunapuu 2020-12-22 12:52:33 +02:00
commit c1aa286e90
No known key found for this signature in database
GPG key ID: C9DD647298A34764
192 changed files with 5154 additions and 1343 deletions

View file

@ -0,0 +1,40 @@
require 'application_system_test_case'
class AdminBouncedMailAddressesTest < ApplicationSystemTestCase
include ActionView::Helpers::NumberHelper
def setup
@bounced_mail = bounced_mail_addresses(:one)
@original_default_language = Setting.default_language
sign_in users(:admin)
end
def teardown
Setting.default_language = @original_default_language
end
def test_shows_bounced_emails
visit admin_bounced_mail_addresses_path
assert_text @bounced_mail.status
assert_text @bounced_mail.action
assert_text @bounced_mail.diagnostic
assert_text @bounced_mail.email
end
def test_shows_detailed_bounced_email
visit admin_bounced_mail_address_path(@bounced_mail)
assert_text @bounced_mail.status
assert_text @bounced_mail.action
assert_text @bounced_mail.diagnostic
assert_text @bounced_mail.email
assert_text @bounced_mail.message_id
end
def test_deletes_registrar
visit admin_bounced_mail_address_path(@bounced_mail)
click_on 'Destroy'
assert_text 'Bounced mail address was successfully destroyed.'
end
end

View file

@ -1,6 +1,7 @@
require 'application_system_test_case'
class DomainDeleteConfirmsTest < ApplicationSystemTestCase
include ActionMailer::TestHelper
setup do
@user = users(:registrant)
sign_in @user
@ -13,7 +14,9 @@ class DomainDeleteConfirmsTest < ApplicationSystemTestCase
def test_enqueues_approve_job_after_verification
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
click_on 'Confirm domain delete'
perform_enqueued_jobs do
click_on 'Confirm domain delete'
end
assert_text 'Domain registrant change has successfully received.'
@domain.reload
@ -23,7 +26,9 @@ class DomainDeleteConfirmsTest < ApplicationSystemTestCase
def test_enqueues_reject_job_after_verification
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
click_on 'Reject domain delete'
perform_enqueued_jobs do
click_on 'Reject domain delete'
end
assert_text 'Domain registrant change has been rejected successfully.'
@domain.reload

View file

@ -29,6 +29,16 @@ class RegistrarAreaBaseTestTest < ApplicationSystemTestCase
assert_button 'Login'
end
def test_user_can_access_when_ip_is_whitelisted_with_subnet
white_ips(:one).update!(ipv4: '127.0.0.1/32', interfaces: [WhiteIp::REGISTRAR])
Setting.registrar_ip_whitelist_enabled = true
visit new_registrar_user_session_url
assert_no_text 'Access denied from IP 127.0.0.1'
assert_button 'Login'
end
def test_user_can_access_when_ip_is_not_whitelisted_and_whitelist_is_disabled
Setting.registrar_ip_whitelist_enabled = false
WhiteIp.delete_all

View file

@ -0,0 +1,70 @@
require 'application_system_test_case'
class BulkRenewTest < ApplicationSystemTestCase
setup do
@registrar = users(:api_bestnames).registrar
@price = billing_prices(:renew_one_year)
end
def test_shows_domain_list
sign_in users(:api_bestnames)
travel_to Time.zone.parse('2010-07-05 10:30')
visit new_registrar_bulk_change_url
click_link('Bulk renew')
assert_text 'Current balance'
page.has_css?('#registrar_balance', text:
ApplicationController.helpers.number_to_currency(@registrar.balance))
select '1 year', from: 'Period'
click_button 'Filter'
@registrar.domains.pluck(:name).each do |domain_name|
assert_text domain_name
end
end
def test_makes_bulk_renew
sign_in users(:api_bestnames)
travel_to Time.zone.parse('2010-07-05 10:30')
req_body = { domains: ["shop.test", "airport.test", "library.test", "invalid.test"], renew_period: "1y" }
stub_request(:post, "#{ENV['repp_url']}domains/renew/bulk").with(body: req_body)
.to_return(status: 400, body: {
code: 2304,
message: "Domain renew error for invalid.test",
data: {}
}.to_json)
visit new_registrar_bulk_change_url
click_link('Bulk renew')
select '1 year', from: 'Period'
click_button 'Filter'
click_button 'Renew'
assert_text 'Domain renew error for invalid.test'
end
def test_bulk_renew_checks_balance
sign_in users(:api_bestnames)
@price.update(price_cents: 99999999)
travel_to Time.zone.parse('2010-07-05 10:30')
req_body = { domains: ["shop.test", "airport.test", "library.test", "invalid.test"], renew_period: "1y" }
stub_request(:post, "#{ENV['repp_url']}domains/renew/bulk").with(body: req_body)
.to_return(status: 400, body: {
code: 2304,
message: "Not enough funds for renew domains",
data: {}
}.to_json)
visit new_registrar_bulk_change_url
click_link('Bulk renew')
select '1 year', from: 'Period'
click_button 'Filter'
click_button 'Renew'
assert_text 'Not enough funds for renew domains'
end
end

View file

@ -6,14 +6,14 @@ class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
end
def test_transfer_multiple_domains_in_bulk
request_body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
request_body = { data: { domain_transfers: [{ domain_name: 'shop.test', transfer_code: '65078d5' }] } }
headers = { 'Content-type' => Mime[:json] }
request_stub = stub_request(:post, /domain_transfers/).with(body: request_body,
request_stub = stub_request(:post, /domains\/transfer/).with(body: request_body,
headers: headers,
basic_auth: ['test_goodnames', 'testtest'])
.to_return(body: { data: [{
type: 'domain_transfer'
}] }.to_json, status: 200)
.to_return(body: { data: { success: [{ type: 'domain_transfer', domain_name: 'shop.test' }],
failed: []
} }.to_json, status: 200)
visit registrar_domains_url
click_link 'Bulk change'
@ -27,9 +27,9 @@ class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
end
def test_fail_gracefully
body = { errors: [{ title: 'epic fail' }] }.to_json
body = { message: 'epic fail' }.to_json
headers = { 'Content-type' => Mime[:json] }
stub_request(:post, /domain_transfers/).to_return(status: 400, body: body, headers: headers)
stub_request(:post, /domains\/transfer/).to_return(status: 400, body: body, headers: headers)
visit registrar_domains_url
click_link 'Bulk change'

View file

@ -15,10 +15,12 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
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-ns.bestnames.test'}],
affected_domains: ["airport.test", "shop.test"]}.to_json, status: 200)
.to_return(body: { data: {
type: 'nameserver',
id: 'new-ns.bestnames.test',
affected_domains: ["airport.test", "shop.test"]
}
}.to_json, status: 200)
visit registrar_domains_url
click_link 'Bulk change'
@ -38,7 +40,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
def test_fails_gracefully
stub_request(:put, /registrar\/nameservers/).to_return(status: 400,
body: { errors: [{ title: 'epic fail' }] }.to_json,
body: { message: 'epic fail' }.to_json,
headers: { 'Content-type' => Mime[:json] })
visit registrar_domains_url
@ -68,9 +70,9 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
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: [{
.to_return(body: { data: {
type: 'nameserver',
id: 'new-ns.bestnames.test'}],
id: 'new-ns.bestnames.test'},
affected_domains: ["shop.test"]}.to_json, status: 200)
visit registrar_domains_url

View file

@ -9,8 +9,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
request_stub = stub_request(:patch, /domains\/contacts/)
.with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' },
basic_auth: ['test_bestnames', 'testtest'])
.to_return(body: { affected_domains: %w[foo.test bar.test],
skipped_domains: %w[baz.test qux.test] }.to_json,
.to_return(body: { data: { affected_domains: %w[foo.test bar.test],
skipped_domains: %w[baz.test qux.test] } }.to_json,
status: 200)
visit registrar_domains_url
@ -30,7 +30,7 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
def test_fails_gracefully
stub_request(:patch, /domains\/contacts/)
.to_return(status: 400,
body: { error: { message: 'epic fail' } }.to_json,
body: { message: 'epic fail' }.to_json,
headers: { 'Content-type' => Mime[:json] })
visit registrar_domains_url