mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
Merge branch 'master' of https://github.com/internetee/registry into 39-registrant-confirmation-should-not-be-asked
This commit is contained in:
commit
169318cd13
249 changed files with 3620 additions and 2725 deletions
|
@ -35,7 +35,6 @@ class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
|
|||
|
||||
def setup
|
||||
DatabaseCleaner.start
|
||||
|
||||
super
|
||||
|
||||
Capybara.current_driver = :chrome
|
||||
|
|
8
test/fixtures/contact_requests.yml
vendored
Normal file
8
test/fixtures/contact_requests.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
new:
|
||||
whois_record_id: 1
|
||||
email: aaa@bbb.com
|
||||
name: Testname
|
||||
status: new
|
||||
secret: somesecret
|
||||
valid_to: 2010-07-05
|
||||
|
39
test/integration/admin_area/account_activities_test.rb
Normal file
39
test/integration/admin_area/account_activities_test.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase
|
||||
# /admin/account_activities
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
@original_default_language = Setting.default_language
|
||||
end
|
||||
|
||||
def test_show_account_activities_page
|
||||
account_activities(:one).update(sum: "123.00")
|
||||
visit admin_account_activities_path
|
||||
assert_text 'Account activities'
|
||||
end
|
||||
|
||||
def test_default_url_params
|
||||
account_activities(:one).update(sum: "123.00")
|
||||
visit admin_root_path
|
||||
click_link_or_button 'Settings', match: :first
|
||||
find(:xpath, "//ul/li/a[text()='Account activities']").click
|
||||
|
||||
assert has_current_path?(admin_account_activities_path(created_after: 'today'))
|
||||
end
|
||||
|
||||
def test_download_account_activity
|
||||
now = Time.zone.parse('2010-07-05 08:00')
|
||||
travel_to now
|
||||
account_activities(:one).update(sum: "123.00")
|
||||
|
||||
get admin_account_activities_path(format: :csv)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal "text/csv", response.headers['Content-Type']
|
||||
assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
||||
response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
end
|
101
test/integration/admin_area/admin_users_test.rb
Normal file
101
test/integration/admin_area/admin_users_test.rb
Normal file
|
@ -0,0 +1,101 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||
include Devise::Test::IntegrationHelpers
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
setup do
|
||||
WebMock.allow_net_connect!
|
||||
@original_default_language = Setting.default_language
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_create_new_admin_user
|
||||
createNewAdminUser(true)
|
||||
end
|
||||
|
||||
def test_create_with_invalid_data_new_admin_user
|
||||
createNewAdminUser(false)
|
||||
end
|
||||
|
||||
def test_edit_successfully_exist_record
|
||||
createNewAdminUser(true)
|
||||
|
||||
visit admin_admin_users_path
|
||||
click_on 'test_user_name'
|
||||
|
||||
assert_text 'General'
|
||||
click_on 'Edit'
|
||||
|
||||
fill_in 'Password', with: 'test_password'
|
||||
fill_in 'Password confirmation', with: 'test_password'
|
||||
|
||||
click_on 'Save'
|
||||
assert_text 'Record updated'
|
||||
end
|
||||
|
||||
def test_edit_exist_record_with_invalid_data
|
||||
createNewAdminUser(true)
|
||||
|
||||
visit admin_admin_users_path
|
||||
click_on 'test_user_name'
|
||||
|
||||
assert_text 'General'
|
||||
click_on 'Edit'
|
||||
|
||||
fill_in 'Password', with: 'test_password'
|
||||
fill_in 'Password confirmation', with: 'test_password2'
|
||||
|
||||
click_on 'Save'
|
||||
assert_text 'Failed to update record'
|
||||
end
|
||||
|
||||
def test_delete_exist_record
|
||||
createNewAdminUser(true)
|
||||
|
||||
visit admin_admin_users_path
|
||||
click_on 'test_user_name'
|
||||
assert_text 'General'
|
||||
click_on 'Delete'
|
||||
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Record deleted'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def createNewAdminUser(valid)
|
||||
visit admin_admin_users_path
|
||||
click_on 'New admin user'
|
||||
|
||||
fill_in 'Username', with: 'test_user_name'
|
||||
# If valid=true creating valid user, if else, then with invalid data
|
||||
if valid
|
||||
fill_in 'Password', with: 'test_password'
|
||||
fill_in 'Password confirmation', with: 'test_password'
|
||||
else
|
||||
fill_in 'Password', with: 'test_password'
|
||||
fill_in 'Password confirmation', with: 'test_password2'
|
||||
end
|
||||
fill_in 'Identity code', with: '38903110313'
|
||||
fill_in 'Email', with: 'oleg@tester.ee'
|
||||
|
||||
select 'Estonia', from: 'admin_user_country_code', match: :first
|
||||
|
||||
select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]")
|
||||
select_element.click
|
||||
|
||||
option_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]")
|
||||
option_element.click
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
if valid
|
||||
assert_text 'Record created'
|
||||
else
|
||||
assert_text 'Failed to create record'
|
||||
end
|
||||
end
|
||||
end
|
68
test/integration/admin_area/blocked_domains_test.rb
Normal file
68
test/integration/admin_area/blocked_domains_test.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
|
||||
# /admin/blocked_domains
|
||||
class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||
setup do
|
||||
WebMock.allow_net_connect!
|
||||
sign_in users(:admin)
|
||||
@domain = domains(:shop)
|
||||
@blocked_domain = blocked_domains(:one)
|
||||
end
|
||||
|
||||
def test_page_successfully_loaded
|
||||
visit_admin_blocked_domains_path
|
||||
end
|
||||
|
||||
def test_add_into_blocked_list
|
||||
visit_admin_blocked_domains_path
|
||||
add_domain_into_blocked_list(true)
|
||||
end
|
||||
|
||||
def test_add_into_blocked_list_same_domain
|
||||
visit_admin_blocked_domains_path
|
||||
add_domain_into_blocked_list(true)
|
||||
add_domain_into_blocked_list(false)
|
||||
end
|
||||
|
||||
def test_delete_domain_from_blocked_list
|
||||
visit_admin_blocked_domains_path
|
||||
add_domain_into_blocked_list(true)
|
||||
|
||||
click_link_or_button 'Delete', match: :first
|
||||
|
||||
# Accept to delete in modal window
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Domain deleted!'
|
||||
end
|
||||
|
||||
def test_find_blocked_domain_from_blocked_list
|
||||
visit_admin_blocked_domains_path
|
||||
add_domain_into_blocked_list(true)
|
||||
|
||||
fill_in 'Name', with: @domain.name
|
||||
find(:xpath, "//span[@class='glyphicon glyphicon-search']").click
|
||||
|
||||
assert_text @domain.name
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def visit_admin_blocked_domains_path
|
||||
visit admin_blocked_domains_path
|
||||
assert_text 'Blocked domains'
|
||||
end
|
||||
|
||||
def add_domain_into_blocked_list(value)
|
||||
click_on 'New blocked domain'
|
||||
assert_text 'Add domain to blocked list'
|
||||
|
||||
fill_in 'Name', with: @domain.name
|
||||
click_on 'Save'
|
||||
|
||||
return assert_text 'Domain added!' if value
|
||||
return assert_text 'Failed to add domain!'
|
||||
end
|
||||
end
|
71
test/integration/admin_area/certificates_test.rb
Normal file
71
test/integration/admin_area/certificates_test.rb
Normal file
|
@ -0,0 +1,71 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||
|
||||
setup do
|
||||
WebMock.allow_net_connect!
|
||||
sign_in users(:admin)
|
||||
|
||||
@apiuser = users(:api_bestnames)
|
||||
@certificate = certificates(:api)
|
||||
@certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST-----\nMIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl\nMRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI\nSGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx\nIsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ\nDr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD\nFiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp\nHH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX\nlR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL\nBQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF\nsP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU\nZ/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U\nwIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie\nAB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW\n2w9PGO061z+tntdRcKQGuEpnIr9U5Vs=\n-----END CERTIFICATE REQUEST-----\n")
|
||||
end
|
||||
|
||||
def test_show_certificate_info
|
||||
show_certificate_info
|
||||
end
|
||||
|
||||
def test_destroy_certificate
|
||||
show_certificate_info
|
||||
find(:xpath, "//a[text()='Delete']").click
|
||||
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Record deleted'
|
||||
end
|
||||
|
||||
def test_download_csr
|
||||
get download_csr_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 'application/octet-stream', response.headers['Content-Type']
|
||||
assert_equal "attachment; filename=\"test_bestnames.csr.pem\"; filename*=UTF-8''test_bestnames.csr.pem", response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
|
||||
def test_download_crt
|
||||
get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 'application/octet-stream', response.headers['Content-Type']
|
||||
assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
|
||||
def test_failed_to_revoke_certificate
|
||||
show_certificate_info
|
||||
|
||||
find(:xpath, "//a[text()='Revoke this certificate']").click
|
||||
assert_text 'Failed to update record'
|
||||
end
|
||||
|
||||
def test_new_api_user
|
||||
visit new_admin_registrar_api_user_path(registrar_id: registrars(:bestnames).id)
|
||||
|
||||
fill_in 'Username', with: 'testapiuser'
|
||||
fill_in 'Password', with: 'secretpassword'
|
||||
fill_in 'Identity code', with: '60305062718'
|
||||
|
||||
click_on 'Create API user'
|
||||
|
||||
assert_text 'API user has been successfully created'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def show_certificate_info
|
||||
visit admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id)
|
||||
assert_text 'Certificates'
|
||||
end
|
||||
end
|
52
test/integration/admin_area/epp_logs_test.rb
Normal file
52
test/integration/admin_area/epp_logs_test.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
# admin_epp_logs_path
|
||||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminEppLogsIntegrationTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_visit_epp_logs_page
|
||||
visit admin_epp_logs_path
|
||||
assert_text 'EPP log'
|
||||
end
|
||||
|
||||
def test_show_epp_log_page
|
||||
visit admin_epp_logs_path
|
||||
send_epp_request_hello
|
||||
visit admin_epp_logs_path
|
||||
|
||||
find(:xpath, "//tbody/tr/td/a", match: :first).click
|
||||
assert_text 'Details'
|
||||
end
|
||||
|
||||
def test_dates_sort
|
||||
Capybara.exact = true
|
||||
visit admin_epp_logs_path
|
||||
send_epp_request_hello
|
||||
visit admin_epp_logs_path
|
||||
|
||||
find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click
|
||||
find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click
|
||||
|
||||
epp_log_date = find(:xpath, "//table/tbody/tr/td[6]", match: :first).text(:all)
|
||||
date_now = Date.today.to_s(:db)
|
||||
|
||||
assert_match /#{date_now}/, epp_log_date
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def send_epp_request_hello
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<hello/>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
get epp_hello_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=non-existent' }
|
||||
end
|
||||
end
|
|
@ -6,6 +6,27 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
|
|||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_create_new_invoice
|
||||
visit new_admin_invoice_path
|
||||
|
||||
assert_text 'Create new invoice'
|
||||
select 'Best Names', from: 'deposit_registrar_id', match: :first
|
||||
fill_in 'Amount', with: '1000'
|
||||
click_on 'Save'
|
||||
|
||||
assert_equal page.status_code, 200
|
||||
end
|
||||
|
||||
def test_visit_list_of_invoices_pages
|
||||
visit admin_invoices_path
|
||||
assert_text 'Invoices'
|
||||
end
|
||||
|
||||
def test_visit_invoice_page
|
||||
visit admin_invoices_path(id: @invoice.id)
|
||||
assert_text "Invoice no. #{@invoice.number}"
|
||||
end
|
||||
|
||||
def test_downloads_invoice
|
||||
assert_equal 1, @invoice.number
|
||||
|
||||
|
|
60
test/integration/admin_area/pending_delete_test.rb
Normal file
60
test/integration/admin_area/pending_delete_test.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaPendingDeleteIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||
setup do
|
||||
WebMock.allow_net_connect!
|
||||
sign_in users(:admin)
|
||||
|
||||
@domain = domains(:shop)
|
||||
@token = '123456'
|
||||
|
||||
@domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION],
|
||||
registrant_verification_asked_at: Time.zone.now - 1.day,
|
||||
registrant_verification_token: @token)
|
||||
end
|
||||
|
||||
def test_accept_pending_delete
|
||||
visit edit_admin_domain_path(id: @domain.id)
|
||||
|
||||
click_on 'Accept'
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Pending was successfully applied.'
|
||||
end
|
||||
|
||||
def test_accept_pending_delete_no_success
|
||||
@domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION],
|
||||
registrant_verification_asked_at: Time.zone.now - 1.day,
|
||||
registrant_verification_token: nil)
|
||||
|
||||
visit edit_admin_domain_path(id: @domain.id)
|
||||
|
||||
click_on 'Accept'
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Not success'
|
||||
end
|
||||
|
||||
def test_reject_panding_delete
|
||||
visit edit_admin_domain_path(id: @domain.id)
|
||||
|
||||
click_on 'Reject'
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Pending was successfully removed.'
|
||||
end
|
||||
|
||||
def test_accept_pending_delete_no_success
|
||||
@domain.update!(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION],
|
||||
registrant_verification_asked_at: Time.zone.now - 1.day,
|
||||
registrant_verification_token: nil)
|
||||
|
||||
visit edit_admin_domain_path(id: @domain.id)
|
||||
|
||||
click_on 'Reject'
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Not success'
|
||||
end
|
||||
end
|
96
test/integration/admin_area/pending_update_test.rb
Normal file
96
test/integration/admin_area/pending_update_test.rb
Normal file
|
@ -0,0 +1,96 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaPendingUpdateIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||
|
||||
setup do
|
||||
WebMock.allow_net_connect!
|
||||
sign_in users(:admin)
|
||||
|
||||
@domain = domains(:hospital)
|
||||
|
||||
@new_registrant = contacts(:jack)
|
||||
@user = users(:api_bestnames)
|
||||
@token = '123456'
|
||||
|
||||
@domain.update!(statuses: [DomainStatus::PENDING_UPDATE],
|
||||
registrant_verification_asked_at: Time.zone.now - 1.day,
|
||||
registrant_verification_token: @token)
|
||||
end
|
||||
|
||||
def test_accept_pending_update
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update(pending_json: pending_json)
|
||||
@domain.reload
|
||||
|
||||
visit edit_admin_domain_path(id: @domain.id)
|
||||
|
||||
click_on 'Accept'
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Pending was successfully applied.'
|
||||
end
|
||||
|
||||
def test_accept_pending_update_no_success
|
||||
@domain.update!(statuses: [DomainStatus::PENDING_UPDATE],
|
||||
registrant_verification_asked_at: Time.zone.now - 1.day,
|
||||
registrant_verification_token: nil)
|
||||
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id,
|
||||
}
|
||||
|
||||
@domain.update(pending_json: pending_json)
|
||||
@domain.reload
|
||||
|
||||
visit edit_admin_domain_path(id: @domain.id)
|
||||
|
||||
click_on 'Accept'
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
assert_text 'Not success'
|
||||
end
|
||||
|
||||
def test_reject_panding_update
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id,
|
||||
}
|
||||
|
||||
@domain.update(pending_json: pending_json)
|
||||
@domain.reload
|
||||
|
||||
visit edit_admin_domain_path(id: @domain.id)
|
||||
|
||||
click_on 'Reject'
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
assert_text 'Pending was successfully removed.'
|
||||
end
|
||||
|
||||
def test_accept_pending_update_no_success
|
||||
@domain.update!(statuses: [DomainStatus::PENDING_UPDATE],
|
||||
registrant_verification_asked_at: Time.zone.now - 1.day,
|
||||
registrant_verification_token: nil)
|
||||
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id,
|
||||
}
|
||||
|
||||
@domain.update(pending_json: pending_json)
|
||||
@domain.reload
|
||||
|
||||
visit edit_admin_domain_path(id: @domain.id)
|
||||
|
||||
click_on 'Reject'
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
assert_text 'Not success'
|
||||
end
|
||||
end
|
|
@ -17,4 +17,4 @@ class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest
|
|||
|
||||
assert_equal new_iban, @registrar.iban
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
23
test/integration/admin_area/repp_logs_test.rb
Normal file
23
test/integration/admin_area/repp_logs_test.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaReppLogsIntegrationTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_repp_logs_page
|
||||
visit admin_repp_logs_path
|
||||
assert_text 'REPP log'
|
||||
end
|
||||
|
||||
def test_show_repp_log_page
|
||||
visit admin_repp_logs_path
|
||||
get repp_v1_contacts_path
|
||||
visit admin_repp_logs_path
|
||||
|
||||
find(:xpath, "//tbody/tr/td/a", match: :first).click
|
||||
|
||||
assert_text 'REPP log'
|
||||
end
|
||||
end
|
39
test/integration/admin_area/reserved_domains_test.rb
Normal file
39
test/integration/admin_area/reserved_domains_test.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaReservedDomainsIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||
|
||||
setup do
|
||||
WebMock.allow_net_connect!
|
||||
@original_default_language = Setting.default_language
|
||||
sign_in users(:admin)
|
||||
|
||||
@reserved_domain = reserved_domains(:one)
|
||||
end
|
||||
|
||||
def test_remove_reserved_domain
|
||||
visit admin_reserved_domains_path
|
||||
click_link_or_button 'Delete', match: :first
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Domain deleted!'
|
||||
end
|
||||
|
||||
def test_add_invalid_domain
|
||||
visit admin_reserved_domains_path
|
||||
click_on 'New reserved domain'
|
||||
fill_in "Name", with: "@##@$"
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Failed to add domain!'
|
||||
end
|
||||
|
||||
def test_update_reserved_domain
|
||||
visit admin_reserved_domains_path
|
||||
click_link_or_button 'Edit Pw', match: :first
|
||||
fill_in 'Password', with: '12345678'
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Domain updated!'
|
||||
end
|
||||
end
|
94
test/integration/admin_area/white_ips_test.rb
Normal file
94
test/integration/admin_area/white_ips_test.rb
Normal file
|
@ -0,0 +1,94 @@
|
|||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaWhiteIpsIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||
|
||||
setup do
|
||||
WebMock.allow_net_connect!
|
||||
sign_in users(:admin)
|
||||
|
||||
@registrar = registrars(:bestnames)
|
||||
@white_ip = white_ips(:one)
|
||||
end
|
||||
|
||||
def test_visit_new_whitelisted_ip_page
|
||||
visit_new_whitelisted_ip_page
|
||||
end
|
||||
|
||||
def test_create_new_whitelisted_ip
|
||||
visit_new_whitelisted_ip_page
|
||||
fill_in 'IPv4', with: "127.0.0.1"
|
||||
fill_in 'IPv6', with: "::ffff:192.0.2.1"
|
||||
|
||||
find(:css, "#white_ip_interfaces_api").set(true)
|
||||
find(:css, "#white_ip_interfaces_registrar").set(true)
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Record created'
|
||||
end
|
||||
|
||||
def test_failed_to_create_new_whitelisted_ip
|
||||
visit_new_whitelisted_ip_page
|
||||
fill_in 'IPv4', with: "asdadadad.asd"
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Failed to create record'
|
||||
end
|
||||
|
||||
def test_visit_edit_whitelisted_ip_page
|
||||
visit_edit_whitelisted_ip_page
|
||||
end
|
||||
|
||||
def test_update_whitelisted_ip
|
||||
visit_info_whitelisted_ip_page
|
||||
click_on 'Edit'
|
||||
|
||||
fill_in 'IPv4', with: "127.0.0.2"
|
||||
find(:css, "#white_ip_interfaces_api").set(false)
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Record updated'
|
||||
end
|
||||
|
||||
def test_failed_to_update_whitelisted_ip
|
||||
visit_info_whitelisted_ip_page
|
||||
click_on 'Edit'
|
||||
fill_in 'IPv4', with: "asdadad#"
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Failed to update record'
|
||||
end
|
||||
|
||||
def test_visit_info_whitelisted_ip_page
|
||||
visit_info_whitelisted_ip_page
|
||||
end
|
||||
|
||||
def test_delete_whitelisted_ip
|
||||
visit_info_whitelisted_ip_page
|
||||
click_on 'Delete'
|
||||
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Record deleted'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def visit_new_whitelisted_ip_page
|
||||
visit new_admin_registrar_white_ip_path(registrar_id: @registrar.id)
|
||||
assert_text 'New whitelisted IP'
|
||||
end
|
||||
|
||||
def visit_edit_whitelisted_ip_page
|
||||
visit edit_admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id)
|
||||
assert_text 'Edit white IP'
|
||||
end
|
||||
|
||||
def visit_info_whitelisted_ip_page
|
||||
visit admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id)
|
||||
assert_text 'White IP'
|
||||
end
|
||||
end
|
153
test/integration/api/domain_admin_contacts_test.rb
Normal file
153
test/integration/api/domain_admin_contacts_test.rb
Normal file
|
@ -0,0 +1,153 @@
|
|||
require 'test_helper'
|
||||
|
||||
class APIDomainAdminContactsTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@admin_current = domains(:shop).admin_contacts.find_by(code: 'jane-001')
|
||||
domain = domains(:airport)
|
||||
domain.admin_contacts << @admin_current
|
||||
@admin_new = contacts(:william)
|
||||
|
||||
@admin_new.update(ident: @admin_current.ident,
|
||||
ident_type: @admin_current.ident_type,
|
||||
ident_country_code: @admin_current.ident_country_code)
|
||||
end
|
||||
|
||||
def test_replace_all_admin_contacts_when_ident_data_doesnt_match
|
||||
@admin_new.update(ident: '777' ,
|
||||
ident_type: 'priv',
|
||||
ident_country_code: 'LV')
|
||||
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal ({ code: 2304, message: 'Admin contacts must be identical', data: {} }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_replace_all_admin_contacts_of_the_current_registrar
|
||||
assert @admin_new.identical_to?(@admin_current)
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_nil domains(:shop).admin_contacts.find_by(code: @admin_current.code)
|
||||
assert domains(:shop).admin_contacts.find_by(code: @admin_new.code)
|
||||
assert domains(:airport).admin_contacts.find_by(code: @admin_new.code)
|
||||
end
|
||||
|
||||
def test_skip_discarded_domains
|
||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).admin_contacts.find_by(code: @admin_current.code)
|
||||
end
|
||||
|
||||
def test_return_affected_domains_in_alphabetical_order
|
||||
domain = domains(:airport)
|
||||
domain.admin_contacts = [@admin_current]
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000, message: 'Command completed successfully', data: { affected_domains: %w[airport.test shop.test],
|
||||
skipped_domains: [] }}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_return_skipped_domains_in_alphabetical_order
|
||||
domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal %w[airport.test shop.test], JSON.parse(response.body,
|
||||
symbolize_names: true)[:data][:skipped_domains]
|
||||
end
|
||||
|
||||
def test_keep_other_admin_contacts_intact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).admin_contacts.find_by(code: 'john-001')
|
||||
end
|
||||
|
||||
def test_keep_tech_contacts_intact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).tech_contacts.find_by(code: 'william-001')
|
||||
end
|
||||
|
||||
def test_restrict_contacts_to_the_current_registrar
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: 'william-002' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :not_found
|
||||
assert_equal ({ code: 2303, message: 'Object does not exist' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_non_existent_current_contact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'non-existent',
|
||||
new_contact_id: @admin_new.code},
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :not_found
|
||||
assert_equal ({ code: 2303, message: 'Object does not exist' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_non_existent_new_contact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: 'non-existent' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :not_found
|
||||
assert_equal ({code: 2303, message: 'Object does not exist'}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_disallow_invalid_new_contact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: 'invalid' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ code: 2304, message: 'New contact must be valid', data: {} }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_admin_bulk_changed_when_domain_update_prohibited
|
||||
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
domains(:airport).admin_contacts = [@admin_current]
|
||||
|
||||
shop_admin_contact = Contact.find_by(code: 'jane-001')
|
||||
assert domains(:shop).admin_contacts.include?(shop_admin_contact)
|
||||
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: { affected_domains: ["airport.test"],
|
||||
skipped_domains: ["shop.test"] }}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def http_auth_key
|
||||
ActionController::HttpAuthentication::Basic.encode_credentials('test_bestnames', 'testtest')
|
||||
end
|
||||
end
|
|
@ -107,6 +107,24 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
|||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_tech_bulk_changed_when_domain_update_prohibited
|
||||
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
|
||||
shop_tech_contact = Contact.find_by(code: 'william-001')
|
||||
assert domains(:shop).tech_contacts.include?(shop_tech_contact)
|
||||
|
||||
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: { affected_domains: ["airport.test"],
|
||||
skipped_domains: ["shop.test"] }}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def http_auth_key
|
||||
|
|
|
@ -63,6 +63,23 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
|
||||
end
|
||||
|
||||
def test_bulk_transfer_if_domain_has_update_prohibited_status
|
||||
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: { success: [],
|
||||
failed: [{ type: "domain_transfer",
|
||||
domain_name: "shop.test",
|
||||
errors: [{:code=>"2304", :msg=>"Object status prohibits operation"}] }],
|
||||
}}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request_params
|
||||
|
|
|
@ -104,6 +104,25 @@ class APINameserversPutTest < ApplicationIntegrationTest
|
|||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_bulk_namesaervers_if_domain_update_prohibited
|
||||
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
|
||||
params = { data: { type: 'nameserver', id: domains(:shop).nameservers.hostnames[0],
|
||||
attributes: { hostname: 'ns55.bestnames.test' } } }
|
||||
put '/repp/v1/registrar/nameservers', params: params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: { type: "nameserver",
|
||||
id: "ns55.bestnames.test",
|
||||
attributes: {hostname: "ns55.bestnames.test"},
|
||||
affected_domains: ["airport.test"],
|
||||
skipped_domains: ["shop.test"]}}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_unauthenticated
|
||||
put '/repp/v1/registrar/nameservers'
|
||||
assert_response 401
|
||||
|
|
|
@ -57,6 +57,15 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
|
|||
assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||
end
|
||||
|
||||
def test_gets_contact_domain_links_when_requested
|
||||
get "/api/v1/registrant/contacts/#{@contact.uuid}?links=true", headers: @auth_headers
|
||||
|
||||
expected_links = @contact.domains.uniq.map { |d| { name: d.name, id: d.uuid }}
|
||||
assert_response :ok
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_empty expected_links - response_json[:links]
|
||||
end
|
||||
private
|
||||
|
||||
def auth_token
|
||||
|
|
|
@ -5,9 +5,10 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:hospital)
|
||||
@domain = domains(:airport)
|
||||
@registrant = @domain.registrant
|
||||
@user = users(:registrant)
|
||||
domains(:metro).tech_domain_contacts.update(contact_id: @registrant.id)
|
||||
@auth_headers = { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
|
||||
|
@ -19,7 +20,14 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
|
||||
assert_equal('hospital.test', domain[:name])
|
||||
assert_equal('5edda1a5-3548-41ee-8b65-6d60daf85a37', domain[:id])
|
||||
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, domain[:registrant])
|
||||
assert_equal({:name=>"John",
|
||||
:id=>"eb2f2766-b44c-4e14-9f16-32ab1a7cb957",
|
||||
:ident=>"1234", :ident_type=>"priv",
|
||||
:ident_country_code=>"US",
|
||||
:phone=>"+555.555",
|
||||
:email=>"john@inbox.test",
|
||||
:org=>false},
|
||||
domain[:registrant])
|
||||
assert_equal([{name: 'John',
|
||||
id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957',
|
||||
email: 'john@inbox.test'}],
|
||||
|
@ -57,6 +65,46 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
|
||||
end
|
||||
|
||||
def test_return_domain_list_with_registrants_and_admins
|
||||
domains(:hospital).admin_domain_contacts.update(contact_id: contacts(:william).id)
|
||||
domains(:hospital).update(registrant: contacts(:william).becomes(Registrant))
|
||||
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0 }
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_json[:domains].each do |x|
|
||||
if x[:registrant][:org] == false
|
||||
x[:tech_contacts].each do |s|
|
||||
assert_not s[:name].include?(@registrant.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_return_domain_list_with_registrants_and_admins_tech
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0, 'tech' => true }
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_json[:domains].each do |x|
|
||||
if x[:name] == 'metro.test'
|
||||
x[:tech_contacts].each do |s|
|
||||
assert s[:name].include?(@registrant.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_domains_total_if_an_incomplete_list_is_returned
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0 }
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal response_json[:domains].length, response_json[:count]
|
||||
assert_equal response_json[:total], 5
|
||||
end
|
||||
|
||||
def test_root_accepts_limit_and_offset_parameters
|
||||
get '/api/v1/registrant/domains', params: { 'limit' => 2, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
|
|
|
@ -130,7 +130,15 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal({ name: 'Best Names', website: 'https://bestnames.test' }, response_json[:registrar])
|
||||
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, response_json[:registrant])
|
||||
assert_equal({:name=>"John",
|
||||
:id=>"eb2f2766-b44c-4e14-9f16-32ab1a7cb957",
|
||||
:ident=>"1234",
|
||||
:ident_type=>"priv",
|
||||
:ident_country_code=>"US",
|
||||
:phone=>"+555.555",
|
||||
:email=>"john@inbox.test",
|
||||
:org=>false},
|
||||
response_json[:registrant])
|
||||
assert_equal([{name: 'Jane',
|
||||
id: '9db3de62-2414-4487-bee2-d5c155567768',
|
||||
email: 'jane@mail.test'
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
|||
|
||||
class BouncesApiV1CreateTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@api_key = "Basic #{ENV['api_shared_key']}"
|
||||
@api_key = "Basic #{ENV['rwhois_bounces_api_shared_key']}"
|
||||
@headers = { "Authorization": "#{@api_key}" }
|
||||
@json_body = { "data": valid_bounce_request }.as_json
|
||||
end
|
||||
|
|
68
test/integration/api/v1/contact_requests_test.rb
Normal file
68
test/integration/api/v1/contact_requests_test.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ApiV1ContactRequestTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@api_key = "Basic #{ENV['rwhois_internal_api_shared_key']}"
|
||||
@headers = { "Authorization": "#{@api_key}" }
|
||||
@json_create = { "contact_request": valid_contact_request_create }.as_json
|
||||
@json_update = { "contact_request": valid_contact_request_update }.as_json
|
||||
@contact_request = contact_requests(:new)
|
||||
end
|
||||
|
||||
def test_authorizes_api_request
|
||||
post api_v1_contact_requests_path, params: @json_create, headers: @headers
|
||||
assert_response :created
|
||||
|
||||
invalid_headers = { "Authorization": "Basic invalid_api_key" }
|
||||
post api_v1_contact_requests_path, params: @json_create, headers: invalid_headers
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
def test_saves_new_contact_request
|
||||
request_body = @json_create.dup
|
||||
random_mail = "#{rand(10000..99999)}@registry.test"
|
||||
request_body['contact_request']['email'] = random_mail
|
||||
|
||||
post api_v1_contact_requests_path, params: request_body, headers: @headers
|
||||
assert_response :created
|
||||
|
||||
contact_request = ContactRequest.last
|
||||
assert_equal contact_request.email, random_mail
|
||||
assert ContactRequest::STATUS_NEW, contact_request.status
|
||||
end
|
||||
|
||||
def test_updates_existing_contact_request
|
||||
request_body = @json_update.dup
|
||||
|
||||
put api_v1_contact_request_path(@contact_request.id), params: request_body, headers: @headers
|
||||
assert_response :ok
|
||||
|
||||
@contact_request.reload
|
||||
assert ContactRequest::STATUS_CONFIRMED, @contact_request.status
|
||||
end
|
||||
|
||||
def test_not_updates_if_status_error
|
||||
request_body = @json_update.dup
|
||||
request_body['contact_request']['status'] = 'some_error_status'
|
||||
|
||||
put api_v1_contact_request_path(@contact_request.id), params: request_body, headers: @headers
|
||||
assert_response 400
|
||||
|
||||
@contact_request.reload
|
||||
assert ContactRequest::STATUS_NEW, @contact_request.status
|
||||
end
|
||||
|
||||
def valid_contact_request_create
|
||||
{
|
||||
"email": "aaa@bbb.com",
|
||||
"whois_record_id": "1",
|
||||
"name": "test"
|
||||
}.as_json
|
||||
end
|
||||
|
||||
def valid_contact_request_update
|
||||
{
|
||||
"status": "#{ContactRequest::STATUS_CONFIRMED}",
|
||||
}.as_json
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
require 'test_helper'
|
||||
require 'auth_token/auth_token_creator'
|
||||
require 'json'
|
||||
|
||||
CompanyRegisterClientStub = Struct.new(:any_method) do
|
||||
def representation_rights(citizen_personal_code:, citizen_country_code:)
|
||||
|
@ -55,6 +56,42 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
|
|||
assert_equal '1234', response_json.first[:ident][:code]
|
||||
end
|
||||
|
||||
def test_out_of_range_limit
|
||||
get api_v1_registrant_contacts_path + "?limit=300", as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
text_response = JSON.pretty_generate(response_json[:errors][0][:limit][0])
|
||||
|
||||
assert_equal text_response, '"parameter is out of range"'
|
||||
end
|
||||
|
||||
def test_negative_offset
|
||||
get api_v1_registrant_contacts_path + "?offset=-300", as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
text_response = JSON.pretty_generate(response_json[:errors][0][:offset][0])
|
||||
|
||||
assert_equal text_response, '"parameter is out of range"'
|
||||
end
|
||||
|
||||
def test_show_valid_contact
|
||||
get api_v1_registrant_contacts_path + "/eb2f2766-b44c-4e14-9f16-32ab1a7cb957", as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
text_response = response_json[:name]
|
||||
|
||||
assert_equal @contact[:name], text_response
|
||||
end
|
||||
|
||||
def test_show_invalid_contact
|
||||
get api_v1_registrant_contacts_path + "/435", as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
text_response = response_json[:errors][0][:base][0]
|
||||
|
||||
assert_equal text_response, 'Contact not found'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def delete_direct_contact
|
||||
|
|
|
@ -4,11 +4,12 @@ require 'auth_token/auth_token_creator'
|
|||
class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@contact = contacts(:john)
|
||||
@contact_org = contacts(:acme_ltd)
|
||||
|
||||
@original_address_processing = Setting.address_processing
|
||||
@original_fax_enabled_setting = ENV['fax_enabled']
|
||||
|
||||
@user = users(:registrant)
|
||||
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
@ -90,6 +91,32 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
@contact.address
|
||||
end
|
||||
|
||||
def test_update_address_when_enabled_without_address_params
|
||||
Setting.address_processing = true
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
@contact.reload
|
||||
assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
|
||||
@contact.address
|
||||
end
|
||||
|
||||
def test_update_address_when_enabled_without_address_params
|
||||
Setting.address_processing = true
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
@contact.reload
|
||||
assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
|
||||
@contact.address
|
||||
end
|
||||
|
||||
def test_address_is_optional_when_enabled
|
||||
Setting.address_processing = true
|
||||
@contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US')
|
||||
|
@ -211,6 +238,21 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_org_disclosed_attributes
|
||||
patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
|
||||
err_msg = "Legal person's data is visible by default and cannot be concealed. Please remove this parameter."
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_msg = response_json[:errors][0][:disclosed_attributes][0]
|
||||
|
||||
assert_equal err_msg, response_msg
|
||||
end
|
||||
|
||||
def test_unmanaged_contact_cannot_be_updated
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
@contact.update!(ident: '12345')
|
||||
|
|
|
@ -26,7 +26,7 @@ class EppContactCheckBaseTest < EppTestCase
|
|||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'john-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_contact_is_available
|
||||
|
@ -52,7 +52,8 @@ class EppContactCheckBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_contact_is_unavailable
|
||||
assert_equal 'john-001', @contact.code
|
||||
@contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase)
|
||||
assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -98,9 +99,61 @@ class EppContactCheckBaseTest < EppTestCase
|
|||
assert_equal 3, response_xml.xpath('//contact:cd', contact: xml_schema).size
|
||||
end
|
||||
|
||||
def test_check_contact_with_prefix
|
||||
@contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase)
|
||||
assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<check>
|
||||
<contact:check xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>BESTNAMES:JOHN-001</contact:id>
|
||||
</contact:check>
|
||||
</check>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_check_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_check_contact_without_prefix
|
||||
@contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase)
|
||||
assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<check>
|
||||
<contact:check xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>JOHN-001</contact:id>
|
||||
</contact:check>
|
||||
</check>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_check_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def xml_schema
|
||||
'https://epp.tld.ee/schema/contact-ee-1.1.xsd'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,60 @@ class EppContactDeleteBaseTest < EppTestCase
|
|||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_delete_contact_with_server_delete_prohibited
|
||||
contact = deletable_contact
|
||||
contact.update(statuses: Contact::SERVER_DELETE_PROHIBITED)
|
||||
assert contact.statuses.include? Contact::SERVER_DELETE_PROHIBITED
|
||||
|
||||
contact.update_columns(code: contact.code.upcase)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<delete>
|
||||
<contact:delete xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>#{contact.code.upcase}</contact:id>
|
||||
</contact:delete>
|
||||
</delete>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
assert Contact.exists?(id: contact.id)
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_delete_contact_with_client_delete_prohibited
|
||||
contact = deletable_contact
|
||||
contact.update(statuses: Contact::CLIENT_DELETE_PROHIBITED)
|
||||
assert contact.statuses.include? Contact::CLIENT_DELETE_PROHIBITED
|
||||
|
||||
contact.update_columns(code: contact.code.upcase)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<delete>
|
||||
<contact:delete xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>#{contact.code.upcase}</contact:id>
|
||||
</contact:delete>
|
||||
</delete>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
assert Contact.exists?(id: contact.id)
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_undeletable_cannot_be_deleted
|
||||
contact = contacts(:john)
|
||||
assert_not contact.deletable?
|
||||
|
@ -61,4 +115,4 @@ class EppContactDeleteBaseTest < EppTestCase
|
|||
DomainContact.delete_all
|
||||
contacts(:john)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,6 +44,58 @@ class EppContactInfoBaseTest < EppTestCase
|
|||
contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_get_info_about_contact_with_prefix
|
||||
@contact.update_columns(code: 'TEST:JOHN-001')
|
||||
assert @contact.code, 'TEST:JOHN-001'
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<info>
|
||||
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>TEST:JOHN-001</contact:id>
|
||||
</contact:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_info_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'TEST:JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal '+555.555', response_xml.at_xpath('//contact:voice', contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_get_info_about_contact_without_prefix
|
||||
@contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase)
|
||||
assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<info>
|
||||
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>JOHN-001</contact:id>
|
||||
</contact:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_info_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal '+555.555', response_xml.at_xpath('//contact:voice', contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_hides_password_and_name_when_current_registrar_is_not_sponsoring
|
||||
non_sponsoring_registrar = registrars(:goodnames)
|
||||
@contact.update!(registrar: non_sponsoring_registrar)
|
||||
|
|
|
@ -2,6 +2,51 @@ require 'test_helper'
|
|||
|
||||
class EppDomainCreateBaseTest < EppTestCase
|
||||
|
||||
def test_illegal_chars_in_dns_key
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
contact = contacts(:john)
|
||||
registrant = contact.becomes(Registrant)
|
||||
|
||||
pub_key = "AwEAAddt2AkLf\n
|
||||
\n
|
||||
YGKgiEZB5SmIF8E\n
|
||||
vrjxNMH6HtxW\rEA4RJ9Ao6LCWheg8"
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{registrant.code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<secDNS:create xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
|
||||
<secDNS:keyData>
|
||||
<secDNS:flags>257</secDNS:flags>
|
||||
<secDNS:protocol>3</secDNS:protocol>
|
||||
<secDNS:alg>8</secDNS:alg>
|
||||
<secDNS:pubKey>#{pub_key}</secDNS:pubKey>
|
||||
</secDNS:keyData>
|
||||
</secDNS:create>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
assert_no_difference 'Domain.count' do
|
||||
post epp_create_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
assert_epp_response :parameter_value_syntax_error
|
||||
end
|
||||
|
||||
|
||||
def test_not_registers_domain_without_legaldoc
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
|
@ -31,6 +76,230 @@ class EppDomainCreateBaseTest < EppTestCase
|
|||
assert_epp_response :required_parameter_missing
|
||||
end
|
||||
|
||||
def test_create_domain_with_unique_contact
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
contact = contacts(:john)
|
||||
registrant = contact.becomes(Registrant)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{registrant.code}</domain:registrant>
|
||||
<domain:contact type="admin">#{contacts(:jane).code}</domain:contact>
|
||||
<domain:contact type="tech">#{contacts(:william).code}</domain:contact>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_difference 'Domain.count' do
|
||||
post epp_create_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
|
||||
def test_create_domain_with_array_of_not_unique_admins_and_techs
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
contact = contacts(:john)
|
||||
registrant = contact.becomes(Registrant)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{registrant.code}</domain:registrant>
|
||||
<domain:contact type="admin">#{contact.code}</domain:contact>
|
||||
<domain:contact type="admin">#{contact.code}</domain:contact>
|
||||
<domain:contact type="tech">#{contact.code}</domain:contact>
|
||||
<domain:contact type="tech">#{contact.code}</domain:contact>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post epp_create_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
assert_epp_response :parameter_value_policy_error
|
||||
end
|
||||
|
||||
def test_create_domain_with_array_of_not_unique_admins
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
contact = contacts(:john)
|
||||
registrant = contact.becomes(Registrant)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{registrant.code}</domain:registrant>
|
||||
<domain:contact type="admin">#{contact.code}</domain:contact>
|
||||
<domain:contact type="admin">#{contact.code}</domain:contact>
|
||||
<domain:contact type="tech">#{contact.code}</domain:contact>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post epp_create_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
assert_epp_response :parameter_value_policy_error
|
||||
end
|
||||
|
||||
def test_create_domain_with_array_of_not_unique_techs
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
contact = contacts(:john)
|
||||
registrant = contact.becomes(Registrant)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{registrant.code}</domain:registrant>
|
||||
<domain:contact type="admin">#{contact.code}</domain:contact>
|
||||
<domain:contact type="tech">#{contact.code}</domain:contact>
|
||||
<domain:contact type="tech">#{contact.code}</domain:contact>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post epp_create_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
assert_epp_response :parameter_value_policy_error
|
||||
end
|
||||
|
||||
def test_create_domain_with_array_of_not_unique_admin_but_tech_another_one
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
contact = contacts(:john)
|
||||
registrant = contact.becomes(Registrant)
|
||||
contact_two = contacts(:william)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{registrant.code}</domain:registrant>
|
||||
<domain:contact type="admin">#{contact.code}</domain:contact>
|
||||
<domain:contact type="admin">#{contact.code}</domain:contact>
|
||||
<domain:contact type="tech">#{contact_two.code}</domain:contact>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post epp_create_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
assert_epp_response :parameter_value_policy_error
|
||||
end
|
||||
|
||||
def test_create_domain_with_array_of_not_unique_techs_but_admin_another_one
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
contact = contacts(:john)
|
||||
registrant = contact.becomes(Registrant)
|
||||
contact_two = contacts(:william)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{registrant.code}</domain:registrant>
|
||||
<domain:contact type="admin">#{contact_two.code}</domain:contact>
|
||||
<domain:contact type="tech">#{contact.code}</domain:contact>
|
||||
<domain:contact type="tech">#{contact.code}</domain:contact>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post epp_create_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
assert_epp_response :parameter_value_policy_error
|
||||
end
|
||||
|
||||
def test_registers_new_domain_with_required_attributes
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
|
|
|
@ -133,6 +133,40 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_deletes_on_update_prohibited
|
||||
assert_equal 'shop.test', @domain.name
|
||||
@domain.update(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
Setting.request_confirmation_on_domain_deletion_enabled = false
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<delete>
|
||||
<domain:delete xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
assert_not @domain.pending_delete_confirmation?
|
||||
assert_no_emails
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_skips_registrant_confirmation_when_required_but_already_verified_by_registrar
|
||||
assert_equal 'shop.test', @domain.name
|
||||
Setting.request_confirmation_on_domain_deletion_enabled = true
|
||||
|
|
|
@ -3,6 +3,7 @@ require 'test_helper'
|
|||
class EppDomainTransferRequestTest < EppTestCase
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
@contact = contacts(:jane)
|
||||
@new_registrar = registrars(:goodnames)
|
||||
@original_transfer_wait_time = Setting.transfer_wait_time
|
||||
Setting.transfer_wait_time = 0
|
||||
|
@ -12,6 +13,95 @@ class EppDomainTransferRequestTest < EppTestCase
|
|||
Setting.transfer_wait_time = @original_transfer_wait_time
|
||||
end
|
||||
|
||||
def test_transfer_domain_with_contacts_if_registrant_and_tech_are_shared
|
||||
@domain.tech_domain_contacts[0].update!(contact_id: @domain.registrant.id)
|
||||
|
||||
@domain.tech_domain_contacts[1].delete
|
||||
@domain.reload
|
||||
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
@domain.reload
|
||||
|
||||
tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id)
|
||||
|
||||
assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 1
|
||||
assert_equal tech.registrar_id, @domain.registrar.id
|
||||
end
|
||||
|
||||
def test_transfer_domain_with_contacts_if_registrant_and_admin_are_shared
|
||||
@domain.admin_domain_contacts[0].update!(contact_id: @domain.registrant.id)
|
||||
@domain.tech_domain_contacts[0].update!(contact_id: @contact.id)
|
||||
|
||||
@domain.tech_domain_contacts[1].delete
|
||||
@domain.reload
|
||||
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
@domain.reload
|
||||
|
||||
admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id)
|
||||
|
||||
assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 1
|
||||
assert_equal admin.registrar_id, @domain.registrar.id
|
||||
end
|
||||
|
||||
def test_transfer_domain_with_contacts_if_admin_and_tech_are_shared
|
||||
@domain.admin_domain_contacts[0].update!(contact_id: @contact.id)
|
||||
@domain.tech_domain_contacts[0].update!(contact_id: @contact.id)
|
||||
|
||||
@domain.tech_domain_contacts[1].delete
|
||||
@domain.reload
|
||||
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
@domain.reload
|
||||
|
||||
admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id)
|
||||
tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id)
|
||||
|
||||
result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count)
|
||||
assert result_hash[admin.original_id], 2
|
||||
|
||||
assert_equal admin.registrar_id, @domain.registrar.id
|
||||
assert_equal tech.registrar_id, @domain.registrar.id
|
||||
end
|
||||
|
||||
def test_transfer_domain_with_contacts_if_admin_and_tech_and_registrant_are_shared
|
||||
@domain.tech_domain_contacts[0].update!(contact_id: @domain.registrant.id)
|
||||
@domain.admin_domain_contacts[0].update!(contact_id: @domain.registrant.id)
|
||||
|
||||
@domain.tech_domain_contacts[1].delete
|
||||
@domain.reload
|
||||
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
@domain.reload
|
||||
|
||||
admin = Contact.find_by(id: @domain.admin_domain_contacts[0].contact_id)
|
||||
tech = Contact.find_by(id: @domain.tech_domain_contacts[0].contact_id)
|
||||
|
||||
assert_equal @domain.contacts.where(original_id: @domain.registrant.original_id).count, 2
|
||||
|
||||
result_hash = @domain.contacts.pluck(:original_id).group_by(&:itself).transform_values(&:count)
|
||||
assert result_hash[@domain.registrant.original_id], 2
|
||||
|
||||
assert_equal admin.registrar_id, @domain.registrar.id
|
||||
assert_equal tech.registrar_id, @domain.registrar.id
|
||||
end
|
||||
|
||||
def test_transfers_domain_at_once
|
||||
post epp_transfer_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
|
|
@ -63,6 +63,27 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_prohibited_domain_cannot_be_updated
|
||||
@domain.update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_does_not_return_server_delete_prohibited_status_when_pending_update_status_is_set
|
||||
@domain.update!(statuses: [DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::PENDING_UPDATE])
|
||||
|
@ -124,6 +145,46 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
assert_verification_and_notification_emails
|
||||
end
|
||||
|
||||
def test_domain_should_doesnt_have_pending_update_when_updated_registrant_with_same_idents_data
|
||||
assert_not @domain.statuses.include? "pendingUpdate"
|
||||
|
||||
old_registrant = @domain.registrant
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
|
||||
new_registrant.update(ident: old_registrant.ident)
|
||||
new_registrant.update(ident_country_code: old_registrant.ident_country_code)
|
||||
new_registrant.update(ident_type: old_registrant.ident_type)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:chg>
|
||||
<domain:registrant verified="no">#{new_registrant.code}</domain:registrant>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
@domain.reload
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
assert_equal @domain.registrant, new_registrant
|
||||
assert_not @domain.statuses.include? "pendingUpdate"
|
||||
end
|
||||
|
||||
def test_requires_verification_from_current_registrant_when_not_yet_verified_by_registrar
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william)
|
||||
|
|
|
@ -26,6 +26,31 @@ class EppPollTest < EppTestCase
|
|||
assert_equal 'Your domain has been updated', xml_doc.at_css('msgQ msg').text
|
||||
end
|
||||
|
||||
def test_does_not_drop_error_if_old_version
|
||||
version = Version::DomainVersion.last
|
||||
@notification.update(attached_obj_type: 'DomainVersion', attached_obj_id: version.id)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<poll op="req"/>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
assert_nothing_raised do
|
||||
post epp_poll_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully_ack_to_dequeue
|
||||
assert_equal 2.to_s, xml_doc.at_css('msgQ')[:count]
|
||||
assert_equal @notification.id.to_s, xml_doc.at_css('msgQ')[:id]
|
||||
assert_equal Time.zone.parse('2010-07-05').utc.xmlschema, xml_doc.at_css('msgQ qDate').text
|
||||
assert_equal 'Your domain has been updated', xml_doc.at_css('msgQ msg').text
|
||||
end
|
||||
|
||||
def test_return_action_data_when_present
|
||||
@notification.update!(action: actions(:contact_update))
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantAreaContactsIntegrationTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@registrant = users(:registrant)
|
||||
sign_in @registrant
|
||||
end
|
||||
|
||||
def test_can_view_other_domain_contacts
|
||||
secondary_contact = contacts(:jane)
|
||||
|
||||
visit registrant_domain_path(@domain)
|
||||
assert_text secondary_contact.name
|
||||
click_link secondary_contact.name
|
||||
assert_text @domain.name
|
||||
assert_text secondary_contact.email
|
||||
end
|
||||
end
|
|
@ -1,30 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantAreaDomainDeleteConfirmationIntegrationTest < ActionDispatch::IntegrationTest
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_notifies_registrant_by_email_when_accepted
|
||||
@domain.update!(registrant_verification_asked_at: Time.zone.now,
|
||||
registrant_verification_token: 'test',
|
||||
statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
|
||||
patch registrant_domain_delete_confirm_path(@domain, token: 'test', confirmed: true)
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
|
||||
def test_notifies_registrant_by_email_when_rejected
|
||||
@domain.update!(registrant_verification_asked_at: Time.zone.now,
|
||||
registrant_verification_token: 'test',
|
||||
statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
|
||||
patch registrant_domain_delete_confirm_path(@domain, token: 'test', rejected: true)
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantAreaDomainsIntegrationTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
sign_in users(:registrant)
|
||||
end
|
||||
|
||||
def test_downloads_list_as_csv
|
||||
get registrant_domains_path(format: :csv)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
|
||||
assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
|
||||
def test_downloads_list_as_pdf
|
||||
get registrant_domains_path(format: :pdf)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal Mime[:pdf], response.headers['Content-Type']
|
||||
assert_equal "attachment; filename=\"domains.pdf\"; filename*=UTF-8''domains.pdf", response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
end
|
|
@ -2,6 +2,7 @@ require 'test_helper'
|
|||
|
||||
class ReppV1BalanceTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
@registrar = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@registrar.username}:#{@registrar.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
@ -19,4 +20,32 @@ class ReppV1BalanceTest < ActionDispatch::IntegrationTest
|
|||
assert_equal @registrar.registrar.cash_account.balance.to_s, json[:data][:balance]
|
||||
assert_equal @registrar.registrar.cash_account.currency, json[:data][:currency]
|
||||
end
|
||||
|
||||
def test_can_query_balance_with_details
|
||||
# Create new billable action to get activity
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: { domains: ['shop.test'], renew_period: '1y' }
|
||||
|
||||
started_from = "2010-07-05"
|
||||
end_to = DateTime.current.to_date.to_s(:db)
|
||||
|
||||
get "/repp/v1/accounts/balance?detailed=true", headers: @auth_headers
|
||||
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 @registrar.registrar.cash_account.balance.to_s, json[:data][:balance]
|
||||
assert_equal @registrar.registrar.cash_account.currency, json[:data][:currency]
|
||||
entry = json[:data][:transactions].last
|
||||
assert_equal @registrar.registrar.cash_account.account_activities.last.created_at, entry[:created_at]
|
||||
assert_equal @registrar.registrar.cash_account.account_activities.last.description, entry[:description]
|
||||
assert_equal 'debit', entry[:type]
|
||||
assert_equal @registrar.registrar.cash_account.account_activities.last.sum.to_s, entry[:sum]
|
||||
assert_equal @registrar.registrar.cash_account.account_activities.last.new_balance.to_s, entry[:balance]
|
||||
|
||||
json[:data][:transactions].map do |trans|
|
||||
assert trans[:created_at].to_date.to_s(:db) >= started_from
|
||||
assert trans[:created_at].to_date.to_s(:db) >= end_to
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,6 +37,29 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_keeps_update_prohibited_status
|
||||
domain = domains(:shop)
|
||||
domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED, DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
payload = {
|
||||
"domains": [
|
||||
'shop.test'
|
||||
],
|
||||
"renew_period": "1y"
|
||||
}
|
||||
|
||||
assert_changes -> { Domain.find_by(name: 'shop.test').valid_to } do
|
||||
post "/repp/v1/domains/renew/bulk", 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 json[:data][:updated_domains].include? 'shop.test'
|
||||
end
|
||||
domain.reload
|
||||
assert_equal domain.statuses, [DomainStatus::CLIENT_UPDATE_PROHIBITED, DomainStatus::SERVER_UPDATE_PROHIBITED]
|
||||
end
|
||||
|
||||
def test_throws_error_when_domain_not_renewable
|
||||
payload = {
|
||||
"domains": [
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -21,7 +21,7 @@ class ReppV1RetainedDomainsTest < ActionDispatch::IntegrationTest
|
|||
status: 'reserved',
|
||||
punycode_name: 'reserved.test' }]
|
||||
|
||||
assert_equal response_json[:domains], expected_objects
|
||||
assert_empty response_json[:domains] - expected_objects
|
||||
end
|
||||
|
||||
def test_get_index_with_type_parameter
|
||||
|
@ -77,7 +77,7 @@ class ReppV1RetainedDomainsTest < ActionDispatch::IntegrationTest
|
|||
status: 'disputed',
|
||||
punycode_name: 'reserved.test' }]
|
||||
|
||||
assert_equal response_json[:domains], expected_objects
|
||||
assert_empty response_json[:domains] - expected_objects
|
||||
end
|
||||
|
||||
def test_etags_cache
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require "test_helper"
|
||||
|
||||
class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
@ -19,6 +18,22 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
|||
super
|
||||
end
|
||||
|
||||
def test_registrant_locked_domain
|
||||
refute @domain.locked_by_registrant?
|
||||
@domain.apply_registry_lock
|
||||
assert @domain.locked_by_registrant?
|
||||
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been locked by registrant")
|
||||
end
|
||||
|
||||
def test_registrant_unlocked_domain
|
||||
refute @domain.locked_by_registrant?
|
||||
@domain.apply_registry_lock
|
||||
assert @domain.locked_by_registrant?
|
||||
@domain.remove_registry_lock
|
||||
refute @domain.locked_by_registrant?
|
||||
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been unlocked by registrant")
|
||||
end
|
||||
|
||||
def test_rejected_registrant_verification_notifies_registrar
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
|
|
|
@ -30,8 +30,15 @@ class SerializersRegistrantApiDomainTest < ActiveSupport::TestCase
|
|||
assert_equal({name: 'Best Names', website: 'https://bestnames.test' }, @json[:registrar])
|
||||
end
|
||||
|
||||
def test_returns_registrant_name_and_uuid
|
||||
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'},
|
||||
def test_returns_registrant_name_uuid_and_org
|
||||
assert_equal({:name=>"John",
|
||||
:id=>"eb2f2766-b44c-4e14-9f16-32ab1a7cb957",
|
||||
:ident=>"1234",
|
||||
:ident_type=>"priv",
|
||||
:ident_country_code=>"US",
|
||||
:phone=>"+555.555",
|
||||
:email=>"john@inbox.test",
|
||||
:org=>false},
|
||||
@json[:registrant])
|
||||
end
|
||||
|
||||
|
|
|
@ -72,11 +72,14 @@ class RegistrantChangeMailerTest < ActionMailer::TestCase
|
|||
|
||||
email = RegistrantChangeMailer.expired(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
registrant: @domain.registrant).deliver_now
|
||||
registrant: @domain.registrant,
|
||||
send_to: [@domain.new_registrant_email,
|
||||
@domain.registrant.email],
|
||||
).deliver_now
|
||||
|
||||
assert_emails 1
|
||||
assert_equal ['william@inbox.test'], email.to
|
||||
assert_equal ['william@inbox.test', @domain.registrant.email], email.to
|
||||
assert_equal 'Domeeni shop.test registreerija vahetuse taotlus on tühistatud' \
|
||||
' / shop.test registrant change cancelled', email.subject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ class VersionsTest < ActiveSupport::TestCase
|
|||
@nameserver.update(hostname: 'ns99.bestnames.test')
|
||||
@ignored_column_title = Nameserver.ignored_columns.first
|
||||
|
||||
version = NameserverVersion.last
|
||||
version = Version::NameserverVersion.last
|
||||
hash = version.object
|
||||
hash[@ignored_column_title] = 123456
|
||||
version.update(object: hash)
|
||||
|
|
|
@ -6,8 +6,8 @@ class ArchivableContactTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_contact_is_archivable_when_it_was_linked_and_inactivity_period_has_passed
|
||||
DomainVersion.stub(:was_contact_linked?, true) do
|
||||
DomainVersion.stub(:contact_unlinked_more_than?, true) do
|
||||
Version::DomainVersion.stub(:was_contact_linked?, true) do
|
||||
Version::DomainVersion.stub(:contact_unlinked_more_than?, true) do
|
||||
assert @contact.archivable?
|
||||
end
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ class ArchivableContactTest < ActiveSupport::TestCase
|
|||
@contact.created_at = Time.zone.parse('2010-07-05 00:00:00')
|
||||
travel_to Time.zone.parse('2010-07-05 00:00:01')
|
||||
|
||||
DomainVersion.stub(:was_contact_linked?, false) do
|
||||
Version::DomainVersion.stub(:was_contact_linked?, false) do
|
||||
assert @contact.archivable?
|
||||
end
|
||||
end
|
||||
|
@ -28,14 +28,14 @@ class ArchivableContactTest < ActiveSupport::TestCase
|
|||
@contact.created_at = Time.zone.parse('2010-07-05')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
DomainVersion.stub(:contact_unlinked_more_than?, false) do
|
||||
Version::DomainVersion.stub(:contact_unlinked_more_than?, false) do
|
||||
assert_not @contact.archivable?
|
||||
end
|
||||
end
|
||||
|
||||
def test_contact_is_not_archivable_when_it_was_ever_linked_but_linked_within_inactivity_period
|
||||
DomainVersion.stub(:was_contact_linked?, true) do
|
||||
DomainVersion.stub(:contact_unlinked_more_than?, false) do
|
||||
Version::DomainVersion.stub(:was_contact_linked?, true) do
|
||||
Version::DomainVersion.stub(:contact_unlinked_more_than?, false) do
|
||||
assert_not @contact.archivable?
|
||||
end
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ class ArchivableContactTest < ActiveSupport::TestCase
|
|||
def archivable_contact
|
||||
contact = contacts(:john)
|
||||
Setting.orphans_contacts_in_months = 0
|
||||
DomainVersion.delete_all
|
||||
Version::DomainVersion.delete_all
|
||||
|
||||
other_contact = contacts(:william)
|
||||
assert_not_equal other_contact, contact
|
||||
|
|
|
@ -234,6 +234,19 @@ class ForceDeleteTest < ActionMailer::TestCase
|
|||
assert_includes(@domain.statuses, asserted_status)
|
||||
end
|
||||
|
||||
def test_client_hold_prohibits_manual_inzone
|
||||
@domain.update(valid_to: Time.zone.parse('2012-08-05'))
|
||||
@domain.update(template_name: 'legal_person')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
@domain.schedule_force_delete(type: :soft)
|
||||
travel_to Time.zone.parse('2010-08-21')
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
@domain.statuses << DomainStatus::SERVER_MANUAL_INZONE
|
||||
assert_not @domain.valid?
|
||||
end
|
||||
|
||||
def test_force_delete_soft_year_ahead_not_sets_client_hold_before_threshold
|
||||
asserted_status = DomainStatus::CLIENT_HOLD
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase
|
|||
def test_skips_auction_when_domains_is_blocked
|
||||
assert_equal 'shop.test', @domain.name
|
||||
blocked_domains(:one).update!(name: 'shop.test')
|
||||
@domain.save!(validate: false)
|
||||
|
||||
@domain.release
|
||||
|
||||
|
@ -34,6 +35,7 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase
|
|||
def test_skips_auction_when_domains_is_reserved
|
||||
assert_equal 'shop.test', @domain.name
|
||||
reserved_domains(:one).update!(name: 'shop.test')
|
||||
@domain.save!(validate: false)
|
||||
|
||||
@domain.release
|
||||
|
||||
|
@ -58,6 +60,24 @@ class DomainReleasableAuctionableTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_updates_whois_server
|
||||
@domain.update!(delete_date: '2010-07-04')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
old_whois = @domain.whois_record
|
||||
|
||||
Domain.release_domains
|
||||
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
old_whois.reload
|
||||
end
|
||||
|
||||
whois_record = Whois::Record.find_by(name: @domain.name)
|
||||
json = { "name"=>@domain.name,
|
||||
"status"=>["AtAuction"],
|
||||
"disclaimer"=> Setting.registry_whois_disclaimer }
|
||||
assert_equal whois_record.json, json
|
||||
end
|
||||
|
||||
def test_notifies_registrar
|
||||
@domain.update!(delete_date: '2010-07-04')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
|
|
@ -69,6 +69,12 @@ class DomainTest < ActiveSupport::TestCase
|
|||
|
||||
domain.name = 'xn--mnchen-3ya.test'
|
||||
assert domain.valid?
|
||||
|
||||
domain.name = '####'
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = 'https://example.test'
|
||||
assert domain.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_when_name_is_already_taken
|
||||
|
|
|
@ -15,7 +15,7 @@ class RegistrantVerificationTest < ActiveSupport::TestCase
|
|||
registrant_verification = registrant_verifications(:one)
|
||||
random_action = "random#{rand(100)}"
|
||||
|
||||
assert_difference -> { RegistrantVerificationVersion.count } do
|
||||
assert_difference -> { Version::RegistrantVerificationVersion.count } do
|
||||
registrant_verification.update_attributes!(action: random_action)
|
||||
end
|
||||
end
|
||||
|
@ -23,11 +23,11 @@ class RegistrantVerificationTest < ActiveSupport::TestCase
|
|||
def test_reject_changes
|
||||
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||
verification_token: @token)
|
||||
start_versions_count = RegistrantVerificationVersion.count
|
||||
start_versions_count = Version::RegistrantVerificationVersion.count
|
||||
|
||||
assert_nothing_raised do
|
||||
@registrant_verification.domain_registrant_change_reject!("email link, #{@initiator}")
|
||||
end
|
||||
assert_equal RegistrantVerificationVersion.count, start_versions_count + 1
|
||||
assert_equal Version::RegistrantVerificationVersion.count, start_versions_count + 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
tech_contacts: [],
|
||||
registrant: [@contact.id] })
|
||||
|
||||
assert DomainVersion.was_contact_linked?(@contact.id)
|
||||
assert Version::DomainVersion.was_contact_linked?(@contact.id)
|
||||
end
|
||||
|
||||
def test_was_contact_linked_returns_true_when_contact_was_used_as_admin_contact
|
||||
|
@ -19,7 +19,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
tech_contacts: [],
|
||||
registrant: [] })
|
||||
|
||||
assert DomainVersion.was_contact_linked?(@contact.id)
|
||||
assert Version::DomainVersion.was_contact_linked?(@contact.id)
|
||||
end
|
||||
|
||||
def test_was_contact_linked_returns_true_when_contact_was_used_as_tech_contact
|
||||
|
@ -27,7 +27,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
tech_contacts: [@contact.id],
|
||||
registrant: [] })
|
||||
|
||||
assert DomainVersion.was_contact_linked?(@contact.id)
|
||||
assert Version::DomainVersion.was_contact_linked?(@contact.id)
|
||||
end
|
||||
|
||||
def test_was_contact_linked_returns_false_when_contact_was_not_used
|
||||
|
@ -35,7 +35,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
tech_contacts: [],
|
||||
registrant: [] })
|
||||
|
||||
assert_not DomainVersion.was_contact_linked?(@contact.id)
|
||||
assert_not Version::DomainVersion.was_contact_linked?(@contact.id)
|
||||
end
|
||||
|
||||
def test_contact_unlinked_more_than_returns_true_when_contact_was_linked_as_registrant_more_than_given_period
|
||||
|
@ -45,7 +45,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [@contact.id] })
|
||||
travel_to Time.zone.parse('2010-07-05 00:00:01')
|
||||
|
||||
assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_unlinked_more_than_given_period_as_admin_contact
|
||||
|
@ -55,7 +55,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [] })
|
||||
travel_to Time.zone.parse('2010-07-05 00:00:01')
|
||||
|
||||
assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_unlinked_more_than_given_period_as_tech_contact
|
||||
|
@ -65,7 +65,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [] })
|
||||
travel_to Time.zone.parse('2010-07-05 00:00:01')
|
||||
|
||||
assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_linked_within_given_period_as_registrant
|
||||
|
@ -75,7 +75,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [@contact.id] })
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_linked_within_given_period_as_admin_contact
|
||||
|
@ -85,7 +85,7 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [] })
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_linked_within_given_period_as_tech_contact
|
||||
|
@ -95,11 +95,11 @@ class DomainVersionTest < ActiveSupport::TestCase
|
|||
registrant: [] })
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
|
||||
def test_contact_was_never_linked
|
||||
DomainVersion.delete_all
|
||||
assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
Version::DomainVersion.delete_all
|
||||
assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,6 +38,20 @@ class WhiteIpTest < ActiveSupport::TestCase
|
|||
assert white_ip.valid?
|
||||
end
|
||||
|
||||
def test_validates_include_empty_ipv4
|
||||
white_ip = WhiteIp.new
|
||||
|
||||
white_ip.ipv4 = nil
|
||||
white_ip.ipv6 = '001:0db8:85a3:0000:0000:8a2e:0370:7334'
|
||||
white_ip.registrar = registrars(:bestnames)
|
||||
|
||||
assert_nothing_raised { white_ip.save }
|
||||
assert white_ip.valid?
|
||||
|
||||
assert WhiteIp.include_ip?(white_ip.ipv6)
|
||||
assert_not WhiteIp.include_ip?('192.168.1.1')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_white_ip
|
||||
|
|
|
@ -4,6 +4,35 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase
|
|||
setup do
|
||||
sign_in users(:admin)
|
||||
travel_to Time.zone.parse('2010-07-05 00:30:00')
|
||||
|
||||
@invoice = invoices(:one)
|
||||
end
|
||||
|
||||
def test_update_bank_statement
|
||||
visit admin_bank_statement_path(id: @invoice.id)
|
||||
|
||||
click_link_or_button 'Add'
|
||||
|
||||
fill_in 'Description', with: 'Invoice with id 123'
|
||||
fill_in 'Reference number', with: '1232'
|
||||
fill_in 'Sum', with: '500'
|
||||
fill_in 'Paid at', with: Time.zone.today.to_s
|
||||
|
||||
click_link_or_button 'Save'
|
||||
assert_text 'Bank transaction'
|
||||
|
||||
click_link_or_button 'Edit'
|
||||
fill_in 'Description', with: 'Invoice with id 123'
|
||||
click_link_or_button 'Save'
|
||||
|
||||
assert_text 'Record updated'
|
||||
end
|
||||
|
||||
def test_bind_bank
|
||||
visit admin_bank_statement_path(id: @invoice.id)
|
||||
click_link_or_button 'Bind invoices'
|
||||
|
||||
assert_text 'No invoices were binded'
|
||||
end
|
||||
|
||||
def test_can_create_statement_manually
|
||||
|
|
|
@ -8,6 +8,17 @@ class AdminContactsTest < ApplicationSystemTestCase
|
|||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_update_contact
|
||||
visit admin_contact_path(id: @contact.id)
|
||||
assert_text "#{@contact.name}"
|
||||
|
||||
click_on 'Edit statuses'
|
||||
assert_text "Edit: #{@contact.name}"
|
||||
|
||||
click_on 'Save'
|
||||
assert_text 'Contact updated'
|
||||
end
|
||||
|
||||
def test_display_list
|
||||
visit admin_contacts_path
|
||||
|
||||
|
|
18
test/system/admin_area/domains/csv_test.rb
Normal file
18
test/system/admin_area/domains/csv_test.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaCsvTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_downloads_domain_list_as_csv
|
||||
search_params = {"valid_to_lteq"=>nil}
|
||||
expected_csv = Domain.includes(:registrar, :registrant).search(search_params).result.to_csv
|
||||
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
visit admin_domains_url
|
||||
click_link('CSV')
|
||||
assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response_headers['Content-Disposition']
|
||||
assert_equal expected_csv, page.body
|
||||
end
|
||||
end
|
|
@ -15,7 +15,7 @@ class AdminAreaDomainsLegalDocTest < ApplicationSystemTestCase
|
|||
def test_absent_doc_downloading_without_errors
|
||||
visit admin_domain_url(@domain)
|
||||
assert_nothing_raised do
|
||||
click_on "#{@document.created_at}"
|
||||
click_on "#{@document.created_at}", match: :first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,4 +40,4 @@ class AdminAreaInvoicesTest < ApplicationSystemTestCase
|
|||
assert_current_path admin_invoice_path(@invoice)
|
||||
assert_text 'Invoice has been sent'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,7 @@ class AdminAreaPricesTest < ApplicationSystemTestCase
|
|||
fill_in 'Valid from', with: effective_date
|
||||
click_on 'Create price'
|
||||
|
||||
|
||||
assert_text 'Price has been created'
|
||||
assert_text I18n.localize(effective_date)
|
||||
end
|
||||
|
|
|
@ -19,4 +19,4 @@ class AdminAreaProtectedAreaTest < ApplicationSystemTestCase
|
|||
assert_text 'You are already signed in'
|
||||
assert_current_path admin_domains_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrantAreaContactDetailsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:registrant)
|
||||
@domain = domains(:shop)
|
||||
@contact = contacts(:john)
|
||||
end
|
||||
|
||||
def test_general_data
|
||||
visit registrant_domain_contact_url(@domain, @contact)
|
||||
assert_text 'Code john-001'
|
||||
assert_text 'Name John'
|
||||
|
||||
assert_text 'Auth info'
|
||||
assert_css('[value="cacb5b"]')
|
||||
|
||||
assert_text 'Ident 1234'
|
||||
assert_text 'Email john@inbox.test'
|
||||
assert_text 'Phone +555.555'
|
||||
|
||||
assert_text "Created at #{l Time.zone.parse('2010-07-05')}"
|
||||
assert_text "Updated at #{l Time.zone.parse('2010-07-06')}"
|
||||
end
|
||||
|
||||
def test_registrant_user_cannot_access_contact_when_given_domain_belongs_to_another_user
|
||||
suppress(ActiveRecord::RecordNotFound) do
|
||||
visit registrant_domain_contact_url(domains(:metro), @contact)
|
||||
assert_response :not_found
|
||||
assert_no_text 'Name John'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,172 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrantAreaContactUpdateTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@contact = contacts(:john)
|
||||
sign_in users(:registrant)
|
||||
|
||||
@original_address_processing = Setting.address_processing
|
||||
@original_fax_enabled_setting = ENV['fax_enabled']
|
||||
@original_registrant_api_base_url_setting = ENV['registrant_api_base_url']
|
||||
|
||||
ENV['registrant_api_base_url'] = 'https://api.test'
|
||||
end
|
||||
|
||||
teardown do
|
||||
Setting.address_processing = @original_address_processing
|
||||
ENV['fax_enabled'] = @original_fax_enabled_setting
|
||||
ENV['registrant_api_base_url'] = @original_registrant_api_base_url_setting
|
||||
end
|
||||
|
||||
def test_form_is_pre_populated_with_contact_data
|
||||
visit edit_registrant_domain_contact_url(@domain, @contact)
|
||||
|
||||
assert_field 'Name', with: 'John'
|
||||
assert_field 'Email', with: 'john@inbox.test'
|
||||
assert_field 'Phone', with: '+555.555'
|
||||
end
|
||||
|
||||
def test_update_contact
|
||||
stub_auth_request
|
||||
|
||||
request_body = { name: 'new name', email: 'new@inbox.test', phone: '+666.6' }.to_json
|
||||
headers = { 'Content-Type' => Mime[:json],
|
||||
'Authorization' => 'Bearer test-access-token' }
|
||||
url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
|
||||
update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
|
||||
.to_return(body: '{}', status: 200)
|
||||
|
||||
visit registrant_domain_contact_url(@domain, @contact)
|
||||
click_link_or_button 'Edit'
|
||||
|
||||
fill_in 'Name', with: 'new name'
|
||||
fill_in 'Email', with: 'new@inbox.test'
|
||||
fill_in 'Phone', with: '+666.6'
|
||||
|
||||
click_link_or_button 'Update contact'
|
||||
|
||||
assert_requested update_request_stub
|
||||
assert_current_path registrant_domain_contact_path(@domain, @contact)
|
||||
assert_text 'Contact has been successfully updated'
|
||||
end
|
||||
|
||||
def test_form_is_pre_populated_with_fax_when_enabled
|
||||
ENV['fax_enabled'] = 'true'
|
||||
@contact.update!(fax: '+111.1')
|
||||
|
||||
visit edit_registrant_domain_contact_url(@domain, @contact)
|
||||
assert_field 'Fax', with: '+111.1'
|
||||
end
|
||||
|
||||
def test_update_fax_when_enabled
|
||||
ENV['fax_enabled'] = 'true'
|
||||
stub_auth_request
|
||||
|
||||
request_body = { email: 'john@inbox.test', name: 'John', phone: '+555.555', fax: '+222.2' }
|
||||
headers = { 'Authorization' => 'Bearer test-access-token' }
|
||||
url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
|
||||
update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
|
||||
.to_return(body: '{}', status: 200)
|
||||
|
||||
visit edit_registrant_domain_contact_url(@domain, @contact)
|
||||
|
||||
fill_in 'Fax', with: '+222.2'
|
||||
click_link_or_button 'Update contact'
|
||||
|
||||
assert_requested update_request_stub
|
||||
assert_current_path registrant_domain_contact_path(@domain, @contact)
|
||||
assert_text 'Contact has been successfully updated'
|
||||
end
|
||||
|
||||
def test_hide_fax_field_when_disabled
|
||||
visit edit_registrant_domain_contact_url(@domain, @contact)
|
||||
assert_no_field 'Fax'
|
||||
end
|
||||
|
||||
def test_form_is_pre_populated_with_address_when_enabled
|
||||
Setting.address_processing = true
|
||||
@contact.update!(street: 'Main Street',
|
||||
zip: '12345',
|
||||
city: 'New York',
|
||||
state: 'New York State',
|
||||
country_code: 'US')
|
||||
|
||||
visit edit_registrant_domain_contact_url(@domain, @contact)
|
||||
|
||||
assert_field 'Street', with: 'Main Street'
|
||||
assert_field 'Zip', with: '12345'
|
||||
assert_field 'City', with: 'New York'
|
||||
assert_field 'State', with: 'New York State'
|
||||
assert_select 'Country', selected: 'United States'
|
||||
end
|
||||
|
||||
def test_update_address_when_enabled
|
||||
Setting.address_processing = true
|
||||
stub_auth_request
|
||||
|
||||
request_body = { name: 'John',
|
||||
email: 'john@inbox.test',
|
||||
phone: '+555.555',
|
||||
address: {
|
||||
city: 'new city',
|
||||
street: 'new street',
|
||||
zip: '93742',
|
||||
country_code: 'AT',
|
||||
state: 'new state',
|
||||
} }.to_json
|
||||
headers = { 'Content-type' => Mime[:json],
|
||||
'Authorization' => 'Bearer test-access-token' }
|
||||
url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
|
||||
update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
|
||||
.to_return(body: '{}', status: 200)
|
||||
|
||||
visit edit_registrant_domain_contact_url(@domain, @contact)
|
||||
|
||||
fill_in 'Street', with: 'new street'
|
||||
fill_in 'City', with: 'new city'
|
||||
fill_in 'State', with: 'new state'
|
||||
fill_in 'Zip', with: '93742'
|
||||
select 'Austria', from: 'Country'
|
||||
click_link_or_button 'Update contact'
|
||||
|
||||
assert_requested update_request_stub
|
||||
assert_current_path registrant_domain_contact_path(@domain, @contact)
|
||||
assert_text 'Contact has been successfully updated'
|
||||
end
|
||||
|
||||
def test_hide_address_field_when_disabled
|
||||
visit edit_registrant_domain_contact_url(@domain, @contact)
|
||||
assert_no_field 'Address'
|
||||
assert_no_field 'Street'
|
||||
end
|
||||
|
||||
def test_fail_gracefully
|
||||
stub_auth_request
|
||||
|
||||
response_body = { errors: { name: ['Name is invalid'] } }.to_json
|
||||
headers = { 'Authorization' => 'Bearer test-access-token' }
|
||||
stub_request(:patch, "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}")
|
||||
.with(headers: headers)
|
||||
.to_return(body: response_body, status: 400)
|
||||
|
||||
visit edit_registrant_domain_contact_url(@domain, @contact)
|
||||
fill_in 'Name', with: 'invalid name'
|
||||
click_link_or_button 'Update contact'
|
||||
|
||||
assert_current_path registrant_domain_contact_path(@domain, @contact)
|
||||
assert_text 'Name is invalid'
|
||||
assert_field 'Name', with: 'invalid name'
|
||||
assert_no_text 'Contact has been successfully updated'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def stub_auth_request
|
||||
body = { ident: '1234', first_name: 'Registrant', last_name: 'User' }
|
||||
stub_request(:post, 'https://api.test/api/v1/registrant/auth/eid').with(body: body)
|
||||
.to_return(body: { access_token: 'test-access-token' }.to_json,
|
||||
headers: { 'Content-type' => Mime[:json] },
|
||||
status: 200)
|
||||
end
|
||||
end
|
|
@ -1,76 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:registrant)
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_general_data
|
||||
@domain.update_columns(force_delete_date: '2010-07-08', statuses: [DomainStatus::FORCE_DELETE])
|
||||
|
||||
visit registrant_domain_url(@domain)
|
||||
|
||||
assert_text 'Name shop.test'
|
||||
assert_text "Registered at #{l @domain.registered_at}"
|
||||
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
|
||||
|
||||
assert_text 'Transfer code'
|
||||
assert_css('[value="65078d5"]')
|
||||
|
||||
assert_text "Valid to #{l Time.zone.parse('2010-07-05')}"
|
||||
assert_text "Outzone at #{l Time.zone.parse('2010-07-06')}"
|
||||
assert_text "Delete date #{l Date.parse('2010-07-07')}"
|
||||
assert_text "Force delete date #{l Date.parse('2010-07-08')}"
|
||||
end
|
||||
|
||||
def test_registrant
|
||||
visit registrant_domain_url(@domain)
|
||||
assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
|
||||
assert_text 'Code john-001'
|
||||
assert_text 'Ident 1234'
|
||||
assert_text 'Email john@inbox.test'
|
||||
assert_text 'Phone +555.555'
|
||||
end
|
||||
|
||||
def test_admin_contacts
|
||||
visit registrant_domain_url(@domain)
|
||||
|
||||
within('.admin-domain-contacts') do
|
||||
assert_link 'Jane', href: registrant_domain_contact_path(@domain, contacts(:jane))
|
||||
assert_text 'jane-001'
|
||||
assert_text 'jane@mail.test'
|
||||
assert_css '.admin-domain-contact', count: 1
|
||||
end
|
||||
end
|
||||
|
||||
def test_tech_contacts
|
||||
visit registrant_domain_url(@domain)
|
||||
|
||||
within('.tech-domain-contacts') do
|
||||
assert_link 'William', href: registrant_domain_contact_path(@domain, contacts(:william))
|
||||
assert_text 'william-001'
|
||||
assert_text 'william@inbox.test'
|
||||
assert_css '.tech-domain-contact', count: 2
|
||||
end
|
||||
end
|
||||
|
||||
def test_registrant_user_cannot_access_domains_of_other_users
|
||||
suppress(ActiveRecord::RecordNotFound) do
|
||||
visit registrant_domain_url(domains(:metro))
|
||||
assert_response :not_found
|
||||
assert_no_text 'metro.test'
|
||||
end
|
||||
end
|
||||
|
||||
def test_confirmation_url
|
||||
@domain.update!(registrant_verification_token: 'a01',
|
||||
pending_json: { new_registrant_email: 'any' },
|
||||
statuses: [DomainStatus::PENDING_UPDATE])
|
||||
|
||||
visit registrant_domain_url(@domain)
|
||||
click_on 'pendingUpdate'
|
||||
|
||||
assert_field nil, with: registrant_domain_update_confirm_url(@domain, token: 'a01')
|
||||
end
|
||||
end
|
|
@ -1,46 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class DomainDeleteConfirmsTest < ApplicationSystemTestCase
|
||||
include ActionMailer::TestHelper
|
||||
setup do
|
||||
@user = users(:registrant)
|
||||
sign_in @user
|
||||
|
||||
@domain = domains(:shop)
|
||||
@domain.registrant_verification_asked!('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp></epp>', @user.id)
|
||||
@domain.pending_delete!
|
||||
end
|
||||
|
||||
def test_enqueues_approve_job_after_verification
|
||||
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
|
||||
|
||||
perform_enqueued_jobs do
|
||||
click_on 'Confirm domain delete'
|
||||
end
|
||||
assert_text 'Domain registrant change has successfully received.'
|
||||
|
||||
@domain.reload
|
||||
assert_includes @domain.statuses, 'serverHold'
|
||||
end
|
||||
|
||||
def test_enqueues_reject_job_after_verification
|
||||
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
|
||||
|
||||
perform_enqueued_jobs do
|
||||
click_on 'Reject domain delete'
|
||||
end
|
||||
assert_text 'Domain registrant change has been rejected successfully.'
|
||||
|
||||
@domain.reload
|
||||
assert_equal ['ok'], @domain.statuses
|
||||
end
|
||||
|
||||
def test_saves_whodunnit_info_after_verifivation
|
||||
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
|
||||
token = @domain.registrant_verification_token
|
||||
click_on 'Confirm domain delete'
|
||||
assert_text 'Domain registrant change has successfully received.'
|
||||
|
||||
refute RegistrantVerification.find_by(verification_token:token).updator_str.empty?
|
||||
end
|
||||
end
|
|
@ -1,71 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
CompanyRegisterClientStub = Struct.new(:any_method) do
|
||||
def representation_rights(citizen_personal_code:, citizen_country_code:)
|
||||
raise CompanyRegister::NotAvailableError
|
||||
end
|
||||
end
|
||||
|
||||
class RegistrantAreaDomainListTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@user = users(:registrant)
|
||||
sign_in @user
|
||||
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_show_domain_list
|
||||
visit registrant_domains_url
|
||||
assert_link 'shop.test', href: registrant_domain_path(@domain)
|
||||
assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
|
||||
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
|
||||
assert_text l(Time.zone.parse('2010-07-05'))
|
||||
assert_css '.domains .domain', count: 4
|
||||
end
|
||||
|
||||
def test_do_not_show_domains_of_other_registrant_users
|
||||
visit registrant_domains_url
|
||||
assert_no_text 'metro.test'
|
||||
end
|
||||
|
||||
def test_only_shows_direct_relation_and_or_company_domains
|
||||
# case https://github.com/internetee/registry/issues/1690
|
||||
tech_contact = contacts(:registrar_ltd)
|
||||
|
||||
# All domains share the same tech contact object
|
||||
Domain.all.each do |domain|
|
||||
DomainContact.create(domain: domain, contact: tech_contact, type: TechDomainContact)
|
||||
end
|
||||
|
||||
visit registrant_domains_url
|
||||
assert_no_text 'Company register is unavailable.'
|
||||
assert_no_text 'metro.test'
|
||||
end
|
||||
|
||||
def test_notification_when_company_register_is_unavailable
|
||||
CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
|
||||
visit registrant_domains_url
|
||||
end
|
||||
|
||||
assert_text 'Company register is unavailable. Domains and contacts associated via' \
|
||||
' organizations are not shown.'
|
||||
end
|
||||
|
||||
def test_show_direct_domains_when_company_register_is_unavailable
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
contact = contacts(:john)
|
||||
assert_equal '1234', contact.ident
|
||||
assert_equal Contact::PRIV, contact.ident_type
|
||||
assert_equal 'US', contact.ident_country_code
|
||||
|
||||
assert_equal contact.becomes(Registrant), @domain.registrant
|
||||
assert_equal 'shop.test', @domain.name
|
||||
|
||||
CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
|
||||
visit registrant_domains_url
|
||||
end
|
||||
|
||||
assert_text 'shop.test'
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrantDomainsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:registrant)
|
||||
end
|
||||
|
||||
def test_shows_domains_where_current_user_is_registrant
|
||||
visit registrant_domains_url
|
||||
assert_text 'shop.test'
|
||||
end
|
||||
|
||||
def test_shows_domains_where_current_user_is_contact_person
|
||||
visit registrant_domains_url
|
||||
assert_text 'airport.test'
|
||||
end
|
||||
|
||||
def test_shows_domains_where_current_user_has_associated_organizations
|
||||
visit registrant_domains_url
|
||||
assert_text 'library.test'
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrantLayoutTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
sign_in(users(:registrant))
|
||||
end
|
||||
|
||||
def test_has_link_to_rest_whois_and_internet_ee
|
||||
visit registrant_domains_url
|
||||
|
||||
assert(has_link?('Internet.ee', href: 'https://internet.ee'))
|
||||
assert(has_link?('WHOIS', href: 'https://whois.internet.ee'))
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrantAreaTaraUsersTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
OmniAuth.config.test_mode = true
|
||||
@registrant = users(:registrant)
|
||||
|
||||
@existing_user_hash = {
|
||||
'provider' => 'rant_tara',
|
||||
'uid' => "US1234",
|
||||
'info': { 'first_name': 'Registrant', 'last_name': 'User' }
|
||||
}
|
||||
|
||||
@new_user_hash = {
|
||||
'provider' => 'rant_tara',
|
||||
'uid' => 'EE51007050604',
|
||||
'info': { 'first_name': 'New Registrant', 'last_name': 'User'}
|
||||
}
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
OmniAuth.config.test_mode = false
|
||||
OmniAuth.config.mock_auth['rant_tara'] = nil
|
||||
end
|
||||
|
||||
def test_existing_user_gets_signed_in
|
||||
OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@existing_user_hash)
|
||||
|
||||
visit new_registrant_user_session_path
|
||||
click_link('Sign in')
|
||||
|
||||
assert_text('Signed in successfully')
|
||||
end
|
||||
|
||||
def test_new_user_is_created_and_signed_in
|
||||
OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@new_user_hash)
|
||||
|
||||
assert_difference 'RegistrantUser.count' do
|
||||
visit new_registrant_user_session_path
|
||||
click_link('Sign in')
|
||||
|
||||
assert_equal 'New Registrant User', RegistrantUser.last.username
|
||||
assert_equal 'EE-51007050604', RegistrantUser.last.registrant_ident
|
||||
assert_text('Signed in successfully')
|
||||
end
|
||||
end
|
||||
end
|
28
test/system/registrar_area/account_activities_test.rb
Normal file
28
test/system/registrar_area/account_activities_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrarAccountActivitiesTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@registrar = registrars(:bestnames)
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_show_account_activity_page
|
||||
account_activities(:one).update(sum: "123.00")
|
||||
visit registrar_account_activities_path
|
||||
assert_text 'Account activity'
|
||||
end
|
||||
|
||||
def test_download_account_activity
|
||||
now = Time.zone.parse('2010-07-05 08:00')
|
||||
travel_to now
|
||||
account_activities(:one).update(sum: "123.00")
|
||||
|
||||
get registrar_account_activities_path(format: :csv)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal "text/csv", response.headers['Content-Type']
|
||||
assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
||||
response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
end
|
49
test/system/registrar_area/bulk_change/admin_contact_test.rb
Normal file
49
test/system/registrar_area/bulk_change/admin_contact_test.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrarAreaAdminContactBulkChangeTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_replace_domain_contacts_of_current_registrar
|
||||
request_stub = stub_request(:patch, /domains\/admin_contacts/)
|
||||
.with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' },
|
||||
basic_auth: ['test_bestnames', 'testtest'])
|
||||
.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
|
||||
click_link 'Bulk change'
|
||||
click_link 'Admin contact'
|
||||
|
||||
find('.current_admin_contact').fill_in 'Current contact ID', with: 'william-001'
|
||||
find('.new_admin_contact').fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace admin contacts'
|
||||
|
||||
assert_requested request_stub
|
||||
assert_current_path registrar_domains_path
|
||||
assert_text 'Admin contacts have been successfully replaced'
|
||||
assert_text 'Affected domains: foo.test, bar.test'
|
||||
assert_text 'Skipped domains: baz.test, qux.test'
|
||||
end
|
||||
|
||||
def test_fails_gracefully
|
||||
stub_request(:patch, /domains\/admin_contacts/)
|
||||
.to_return(status: 400,
|
||||
body: { message: 'epic fail' }.to_json,
|
||||
headers: { 'Content-type' => Mime[:json] })
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
click_link 'Admin contact'
|
||||
|
||||
find('.current_admin_contact').fill_in 'Current contact ID', with: 'william-001'
|
||||
find('.new_admin_contact').fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace admin contacts'
|
||||
|
||||
assert_text 'epic fail'
|
||||
assert_field 'Current contact ID', with: 'william-001'
|
||||
assert_field 'New contact ID', with: 'john-001'
|
||||
end
|
||||
end
|
|
@ -16,8 +16,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
|
|||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
||||
fill_in 'Current contact ID', with: 'william-001'
|
||||
fill_in 'New contact ID', with: 'john-001'
|
||||
find('.current_tech_contact').fill_in 'Current contact ID', with: 'william-001'
|
||||
find('.new_tech_contact').fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace technical contacts'
|
||||
|
||||
assert_requested request_stub
|
||||
|
@ -36,8 +36,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
|
|||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
||||
fill_in 'Current contact ID', with: 'william-001'
|
||||
fill_in 'New contact ID', with: 'john-001'
|
||||
find('.current_tech_contact').fill_in 'Current contact ID', with: 'william-001'
|
||||
find('.new_tech_contact').fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace technical contacts'
|
||||
|
||||
assert_text 'epic fail'
|
||||
|
|
|
@ -34,6 +34,18 @@ class TaraUsersTest < ApplicationSystemTestCase
|
|||
assert_text('Signed in successfully')
|
||||
end
|
||||
|
||||
def test_existing_user_logs_in_without_cookie_overflow
|
||||
@existing_user_hash['credentials'] = massive_hash
|
||||
OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@existing_user_hash)
|
||||
|
||||
visit new_registrar_user_session_path
|
||||
assert_nothing_raised do
|
||||
click_link('Sign in')
|
||||
end
|
||||
|
||||
assert_text('Signed in successfully')
|
||||
end
|
||||
|
||||
def test_nonexisting_user_gets_error_message
|
||||
OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@new_user_hash)
|
||||
|
||||
|
@ -42,4 +54,10 @@ class TaraUsersTest < ApplicationSystemTestCase
|
|||
|
||||
assert_text('No such user')
|
||||
end
|
||||
|
||||
def massive_hash
|
||||
o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten
|
||||
string = (0...5000).map { o[rand(o.length)] }.join
|
||||
{"access_token":"AT-540-Fj5gbPvJp4jPkO-4EdgzIhIhhJapoRTM","token_type":"bearer","expires_in":600,"id_token":string}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase
|
|||
def archivable_contact
|
||||
contact = contacts(:john)
|
||||
Setting.orphans_contacts_in_months = 0
|
||||
DomainVersion.delete_all
|
||||
Version::DomainVersion.delete_all
|
||||
|
||||
other_contact = contacts(:william)
|
||||
assert_not_equal other_contact, contact
|
||||
|
|
|
@ -42,7 +42,7 @@ EInvoice.provider = EInvoice::Providers::TestProvider.new
|
|||
class ActiveSupport::TestCase
|
||||
ActiveRecord::Migration.check_pending!
|
||||
fixtures :all
|
||||
set_fixture_class log_domains: DomainVersion
|
||||
set_fixture_class log_domains: Version::DomainVersion
|
||||
|
||||
teardown do
|
||||
travel_back
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue