diff --git a/test/integration/registrar_area/contacts_test.rb b/test/integration/registrar_area/contacts_test.rb deleted file mode 100644 index a8e50aafa..000000000 --- a/test/integration/registrar_area/contacts_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'test_helper' - -class RegistrarAreaContactsIntegrationTest < ApplicationIntegrationTest - setup do - sign_in users(:api_bestnames) - end - - def test_downloads_list_as_csv - get registrar_contacts_path(format: :csv) - - assert_response :ok - assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type'] - assert_equal "attachment; filename=\"contacts.csv\"; filename*=UTF-8''contacts.csv", response.headers['Content-Disposition'] - assert_not_empty response.body - end - - def test_downloads_list_as_pdf - get registrar_contacts_path(format: :pdf) - - assert_response :ok - assert_equal Mime[:pdf], response.headers['Content-Type'] - assert_equal "attachment; filename=\"contacts.pdf\"; filename*=UTF-8''contacts.pdf", response.headers['Content-Disposition'] - assert_not_empty response.body - end -end diff --git a/test/integration/registrar_area/domains_test.rb b/test/integration/registrar_area/domains_test.rb deleted file mode 100644 index 307bcae5e..000000000 --- a/test/integration/registrar_area/domains_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'test_helper' - -class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest - include FormTagHelper - - setup do - sign_in users(:api_bestnames) - end - - def test_downloads_list_as_csv - now = Time.zone.parse('2010-07-05 08:00') - travel_to now - - get registrar_domains_path(format: :csv) - - assert_response :ok - assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type'] - assert_equal %(attachment; filename="Domains_#{l(now, format: :filename)}.csv"; filename*=UTF-8''Domains_#{l(now, format: :filename)}.csv), - response.headers['Content-Disposition'] - assert_not_empty response.body - end -end diff --git a/test/integration/registrar_area/invoices/payment_callback_test.rb b/test/integration/registrar_area/invoices/payment_callback_test.rb deleted file mode 100644 index 94ca6e373..000000000 --- a/test/integration/registrar_area/invoices/payment_callback_test.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'test_helper' - -class PaymentCallbackTest < ApplicationIntegrationTest - def setup - super - - @user = users(:api_bestnames) - sign_in @user - - @payment_order = payment_orders(:everypay_issued) - @invoice = invoices(:one) - @invoice.update!(account_activity: nil, total: 12) - end - - def test_every_pay_callback_returns_status_200 - request_params = every_pay_request_params - post "/registrar/pay/callback/#{@payment_order.id}", params: request_params - - assert_response :ok - end - - def test_invoice_is_marked_as_paid - request_params = every_pay_request_params - post "/registrar/pay/callback/#{@payment_order.id}", params: request_params - - assert @payment_order.invoice.paid? - end - - def failure_log_is_created_if_unsuccessful_payment - request_params = every_pay_request_params.dup - request_params['payment_state'] = 'cancelled' - request_params['transaction_result'] = 'failed' - - post "/registrar/pay/callback/#{@payment_order.id}", params: request_params - - @payment_order.reload - assert @payment_order.cancelled? - assert_includes @payment_order.notes, 'Payment state: cancelled' - end - - private - - def every_pay_request_params - { - nonce: "392f2d7748bc8cb0d14f263ebb7b8932", - timestamp: "1524136727", - api_username: "ca8d6336dd750ddb", - transaction_result: "completed", - payment_reference: "fd5d27b59a1eb597393cd5ff77386d6cab81ae05067e18d530b10f3802e30b56", - payment_state: "settled", - amount: "12.00", - order_reference: "e468a2d59a731ccc546f2165c3b1a6", - account_id: "EUR3D1", - cc_type: "master_card", - cc_last_four_digits: "0487", - cc_month: "10", - cc_year: "2018", - cc_holder_name: "John Doe", - hmac_fields: "account_id,amount,api_username,cc_holder_name,cc_last_four_digits,cc_month,cc_type,cc_year,hmac_fields,nonce,order_reference,payment_reference,payment_state,timestamp,transaction_result", - hmac: "efac1c732835668cd86023a7abc140506c692f0d", - invoice_id: "12900000", - payment_method: "every_pay" - } - end -end diff --git a/test/integration/registrar_area/invoices/payment_return_test.rb b/test/integration/registrar_area/invoices/payment_return_test.rb deleted file mode 100644 index a4adb8160..000000000 --- a/test/integration/registrar_area/invoices/payment_return_test.rb +++ /dev/null @@ -1,137 +0,0 @@ -require 'test_helper' - -class PaymentReturnTest < ApplicationIntegrationTest - def setup - super - - @user = users(:api_bestnames) - sign_in @user - - @invoice = invoices(:one) - @invoice.update!(account_activity: nil, total: 12) - @everypay_order = payment_orders(:everypay_issued) - @banklink_order = payment_orders(:banklink_issued) - end - - def every_pay_request_params - { - nonce: "392f2d7748bc8cb0d14f263ebb7b8932", - timestamp: "1524136727", - api_username: "ca8d6336dd750ddb", - transaction_result: "completed", - payment_reference: "fd5d27b59a1eb597393cd5ff77386d6cab81ae05067e18d530b10f3802e30b56", - payment_state: "settled", - amount: "12.00", - order_reference: "e468a2d59a731ccc546f2165c3b1a6", - account_id: "EUR3D1", - cc_type: "master_card", - cc_last_four_digits: "0487", - cc_month: "10", - cc_year: "2018", - cc_holder_name: "John Doe", - hmac_fields: "account_id,amount,api_username,cc_holder_name,cc_last_four_digits,cc_month,cc_type,cc_year,hmac_fields,nonce,order_reference,payment_reference,payment_state,timestamp,transaction_result", - hmac: "efac1c732835668cd86023a7abc140506c692f0d", - invoice_id: "12900000", - payment_method: "every_pay" - } - end - - def bank_link_request_params - { - "VK_SERVICE": "1111", - "VK_VERSION": "008", - "VK_SND_ID": "testvpos", - "VK_REC_ID": "seb", - "VK_STAMP": 1, - "VK_T_NO": "1", - "VK_AMOUNT": "12.00", - "VK_CURR": "EUR", - "VK_REC_ACC": "1234", - "VK_REC_NAME": "Eesti Internet", - "VK_SND_ACC": "1234", - "VK_SND_NAME": "John Doe", - "VK_REF": "", - "VK_MSG": "Order nr 1", - "VK_T_DATETIME": "2018-04-01T00:30:00+0300", - "VK_MAC": "CZZvcptkxfuOxRR88JmT4N+Lw6Hs4xiQfhBWzVYldAcRTQbcB/lPf9MbJzBE4e1/HuslQgkdCFt5g1xW2lJwrVDBQTtP6DAHfvxU3kkw7dbk0IcwhI4whUl68/QCwlXEQTAVDv1AFnGVxXZ40vbm/aLKafBYgrirB5SUe8+g9FE=", - "VK_ENCODING": "UTF-8", - "VK_LANG": "ENG", - payment_method: "seb" - } - end - - def test_successful_bank_payment_marks_invoice_as_paid - @invoice.update!(account_activity: nil) - request_params = bank_link_request_params - - post "/registrar/pay/return/#{@banklink_order.id}", params: request_params - - @banklink_order.reload - assert @banklink_order.invoice.paid? - end - - def test_every_pay_return_creates_activity_redirects_to_invoice_path - request_params = every_pay_request_params - - post "/registrar/pay/return/#{@everypay_order.id}", params: request_params - assert_equal(302, response.status) - assert_redirected_to(registrar_invoice_path(@invoice)) - end - - def test_every_pay_return_raises_record_not_found - request_params = every_pay_request_params - assert_raises(ActiveRecord::RecordNotFound) do - post '/registrar/pay/return/123456', params: request_params - end - end - - def test_bank_link_return_redirects_to_invoice_paths - request_params = bank_link_request_params - - post "/registrar/pay/return/#{@banklink_order.id}", params: request_params - assert_equal(302, response.status) - assert_redirected_to(registrar_invoice_path(@invoice)) - end - - def test_bank_link_return - request_params = bank_link_request_params - assert_raises(ActiveRecord::RecordNotFound) do - post '/registrar/pay/return/123456', params: request_params - end - end - - def test_marks_as_paid_and_adds_notes_if_failed_to_bind - request_params = bank_link_request_params - - post "/registrar/pay/return/#{@banklink_order.id}", params: request_params - post "/registrar/pay/return/#{@banklink_order.id}", params: request_params - @banklink_order.reload - - assert @banklink_order.notes.present? - assert @banklink_order.paid? - assert_includes @banklink_order.notes, 'Failed to bind' - end - - def test_failed_bank_link_payment_creates_brief_error_explanation - request_params = bank_link_request_params.dup - request_params['VK_SERVICE'] = '1911' - - post "/registrar/pay/return/#{@banklink_order.id}", params: request_params - - @banklink_order.reload - - assert_includes @banklink_order.notes, 'Bank responded with code 1911' - end - - def test_failed_every_pay_payment_creates_brief_error_explanation - request_params = every_pay_request_params.dup - request_params['payment_state'] = 'cancelled' - request_params['transaction_result'] = 'failed' - - post "/registrar/pay/return/#{@everypay_order.id}", params: request_params - - @everypay_order.reload - - assert_includes @everypay_order.notes, 'Payment state: cancelled' - end -end diff --git a/test/integration/registrar_area/invoices_test.rb b/test/integration/registrar_area/invoices_test.rb deleted file mode 100644 index 91c6afbd8..000000000 --- a/test/integration/registrar_area/invoices_test.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'test_helper' - -class RegistrarAreaInvoicesIntegrationTest < ApplicationIntegrationTest - setup do - @invoice = invoices(:one) - sign_in users(:api_bestnames) - end - - def test_downloads_invoice - assert_equal 1, @invoice.number - - get download_registrar_invoice_path(@invoice) - - assert_response :ok - assert_equal 'application/pdf', response.headers['Content-Type'] - assert_equal "attachment; filename=\"invoice-1.pdf\"; filename*=UTF-8''invoice-1.pdf", response.headers['Content-Disposition'] - assert_not_empty response.body - end -end diff --git a/test/integration/registrar_area/settings/balance_auto_reload_test.rb b/test/integration/registrar_area/settings/balance_auto_reload_test.rb deleted file mode 100644 index 1a2c3f835..000000000 --- a/test/integration/registrar_area/settings/balance_auto_reload_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'test_helper' - -class RegistrarAreaSettingsBalanceAutoReloadIntegrationTest < ActionDispatch::IntegrationTest - include Devise::Test::IntegrationHelpers - - setup do - @registrar = registrars(:bestnames) - sign_in users(:api_bestnames) - end - - def test_updates_balance_auto_reload_setting - amount = 100 - threshold = 10 - assert_nil @registrar.settings['balance_auto_reload'] - - patch registrar_settings_balance_auto_reload_path, params: { type: { amount: amount, - threshold: threshold } } - @registrar.reload - - assert_equal amount, @registrar.settings['balance_auto_reload']['type']['amount'] - assert_equal threshold, @registrar.settings['balance_auto_reload']['type']['threshold'] - end - - def test_disables_balance_auto_reload_setting - @registrar.update!(settings: { balance_auto_reload: { amount: 'any', threshold: 'any' } }) - - delete registrar_settings_balance_auto_reload_path - @registrar.reload - - assert_nil @registrar.settings['balance_auto_reload'] - end -end \ No newline at end of file diff --git a/test/integration/registrar_area/xml_consoles_test.rb b/test/integration/registrar_area/xml_consoles_test.rb deleted file mode 100644 index 443abfb78..000000000 --- a/test/integration/registrar_area/xml_consoles_test.rb +++ /dev/null @@ -1,112 +0,0 @@ -require 'test_helper' - -class RegistrarXmlConsolesIntegrationTest < ApplicationIntegrationTest - setup do - sign_in users(:api_bestnames) - end - - def test_check_schema_path - post registrar_xml_console_path, params: { frame: payload }, - headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } - - assert_response :ok - end - - def test_load_schema_path - get load_xml_registrar_xml_console_path, params: { obj: 'domain', epp_action: 'update' } - - assert_response :ok - assert_equal update_payload, response.body - end - - private - - def payload - <<~XML - - - - - - auction.test - - - - - XML - end - - def wrong_payload - <<~XML - - - - - - auction.test - - - - - XML - end - - def update_payload - <<~XML - - - - - - example.ee - - - - ns1.example.com - - - ns2.example.com - - - mak21 - - - - - ns1.example.net - - - mak21 - - - mak21 - - newpw - - - - - - - - - 257 - 3 - 8 - 700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f - - - - - - dGVzdCBmYWlsCg== - - - - test_bestnames-#{Time.zone.now.to_i} - - - XML - end -end diff --git a/test/system/registrar_area/account_activities_test.rb b/test/system/registrar_area/account_activities_test.rb deleted file mode 100644 index 08ffe447f..000000000 --- a/test/system/registrar_area/account_activities_test.rb +++ /dev/null @@ -1,44 +0,0 @@ -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 - - def test_search_account_activity_with_invalid_date - account_activities(:one).update(description: "Description of activity one", - sum: "123.00", - activity_type: "create", - created_at: Time.zone.parse('2021-07-05 10:00')) - - visit registrar_account_activities_path - - find('#q_activity_type_in').click - find(:option, "Renew").select_option - fill_in('q_created_at_lteq', with: '2021-12--') - find(:xpath, ".//button[./span[contains(@class, 'glyphicon-search')]]").click - - assert_text 'Description of activity renew_cash' - end -end diff --git a/test/system/registrar_area/account_test.rb b/test/system/registrar_area/account_test.rb deleted file mode 100644 index 708f8dc8f..000000000 --- a/test/system/registrar_area/account_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAccountTest < ApplicationSystemTestCase - setup do - @registrar = registrars(:bestnames) - sign_in users(:api_bestnames) - end - - def test_updates_account - new_billing_email = 'new@registrar.test' - new_iban = 'GB77BARC20201530093459' - assert_not_equal new_billing_email, @registrar.billing_email - assert_not_equal new_iban, @registrar.iban - - visit registrar_account_path - click_on 'Edit' - - fill_in 'Billing email', with: new_billing_email - fill_in 'IBAN', with: new_iban - click_on 'Save changes' - - assert_text 'Your account has been updated' - assert_text new_billing_email - assert_text new_iban - end -end \ No newline at end of file diff --git a/test/system/registrar_area/add_deposits_test.rb b/test/system/registrar_area/add_deposits_test.rb deleted file mode 100644 index 3ca7691ce..000000000 --- a/test/system/registrar_area/add_deposits_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'application_system_test_case' - -class AddDepositsTest < ApplicationSystemTestCase - include ActionMailer::TestHelper - - setup do - sign_in users(:api_bestnames) - @invoice = invoices(:one) - - ActionMailer::Base.deliveries.clear - end -end diff --git a/test/system/registrar_area/base_test.rb b/test/system/registrar_area/base_test.rb deleted file mode 100644 index 2529b009a..000000000 --- a/test/system/registrar_area/base_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaBaseTestTest < ApplicationSystemTestCase - setup do - @original_registrar_area_ip_whitelist = Setting.registrar_ip_whitelist_enabled - end - - teardown do - Setting.registrar_ip_whitelist_enabled = @original_registrar_area_ip_whitelist - end - - def test_user_cannot_access_without_ip_address_being_whitelisted - Setting.registrar_ip_whitelist_enabled = true - WhiteIp.delete_all - - visit new_registrar_user_session_url - - assert_text 'Access denied from IP 127.0.0.1' - assert_no_button 'Login' - end - - def test_user_can_access_when_ip_is_whitelisted - white_ips(:one).update!(ipv4: '127.0.0.1', interfaces: [WhiteIp::REGISTRAR]) - Setting.registrar_ip_whitelist_enabled = true - - visit new_registrar_user_session_url - - assert_no_text 'Access denied from IP 127.0.0.1' - assert_button 'Login' - end - - def test_user_can_access_when_ip_is_whitelisted_with_subnet - white_ips(:one).update!(ipv4: '127.0.0.1/32', interfaces: [WhiteIp::REGISTRAR]) - Setting.registrar_ip_whitelist_enabled = true - - visit new_registrar_user_session_url - - assert_no_text 'Access denied from IP 127.0.0.1' - assert_button 'Login' - end - - def test_user_can_access_when_ip_is_not_whitelisted_and_whitelist_is_disabled - Setting.registrar_ip_whitelist_enabled = false - WhiteIp.delete_all - - visit new_registrar_user_session_url - - assert_no_text 'Access denied from IP 127.0.0.1' - assert_button 'Login' - end -end diff --git a/test/system/registrar_area/billing/balance_top_up_test.rb b/test/system/registrar_area/billing/balance_top_up_test.rb deleted file mode 100644 index 5cb32361f..000000000 --- a/test/system/registrar_area/billing/balance_top_up_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'application_system_test_case' - -class BalanceTopUpTest < ApplicationSystemTestCase - setup do - sign_in users(:api_bestnames) - @original_registry_vat_rate = Setting.registry_vat_prc - - eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}") - Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response) - Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true) - end - - teardown do - Setting.registry_vat_prc = @original_registry_vat_rate - end - - def test_creates_new_invoice - if Feature.billing_system_integrated? - invoice_n = Invoice.order(number: :desc).last.number - stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator"). - to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {}) - - stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response") - .to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {}) - - stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice") - .to_return(status: 200, body: "", headers: {}) - - Setting.registry_vat_prc = 0.1 - - visit registrar_invoices_url - click_link_or_button 'Add deposit' - fill_in 'Amount', with: '25.5' - - assert_difference 'Invoice.count' do - click_link_or_button 'Add' - end - - invoice = Invoice.last - - assert_equal BigDecimal(10), invoice.vat_rate - assert_equal BigDecimal('28.05'), invoice.total - assert_text 'Please pay the following invoice' - end - end -end diff --git a/test/system/registrar_area/bulk_change/admin_contact_test.rb b/test/system/registrar_area/bulk_change/admin_contact_test.rb deleted file mode 100644 index 8847812cb..000000000 --- a/test/system/registrar_area/bulk_change/admin_contact_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -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 diff --git a/test/system/registrar_area/bulk_change/bulk_renew_test.rb b/test/system/registrar_area/bulk_change/bulk_renew_test.rb deleted file mode 100644 index 5e1704afd..000000000 --- a/test/system/registrar_area/bulk_change/bulk_renew_test.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'application_system_test_case' - -class BulkRenewTest < ApplicationSystemTestCase - setup do - @registrar = users(:api_bestnames).registrar - @price = billing_prices(:renew_one_year) - end - - def test_shows_domain_list - sign_in users(:api_bestnames) - travel_to Time.zone.parse('2010-07-05 10:30') - - visit new_registrar_bulk_change_url - click_link('Bulk renew') - assert_text 'Current balance' - page.has_css?('#registrar_balance', text: - ApplicationController.helpers.number_to_currency(@registrar.balance)) - - select '1 year', from: 'Period' - click_button 'Filter' - - @registrar.domains.pluck(:name).each do |domain_name| - assert_text domain_name - end - end - - def test_makes_bulk_renew - sign_in users(:api_bestnames) - travel_to Time.zone.parse('2010-07-05 10:30') - - req_body = { domains: ["shop.test", "airport.test", "library.test", "invalid.test"], renew_period: "1y" } - stub_request(:post, "#{ENV['repp_url']}domains/renew/bulk").with(body: req_body) - .to_return(status: 400, body: { - code: 2304, - message: "Domain renew error for invalid.test", - data: {} - }.to_json) - - visit new_registrar_bulk_change_url - click_link('Bulk renew') - select '1 year', from: 'Period' - click_button 'Filter' - click_button 'Renew' - - assert_text 'Domain renew error for invalid.test' - end - - def test_bulk_renew_checks_balance - sign_in users(:api_bestnames) - @price.update(price_cents: 99999999) - travel_to Time.zone.parse('2010-07-05 10:30') - - req_body = { domains: ["shop.test", "airport.test", "library.test", "invalid.test"], renew_period: "1y" } - stub_request(:post, "#{ENV['repp_url']}domains/renew/bulk").with(body: req_body) - .to_return(status: 400, body: { - code: 2304, - message: "Not enough funds for renew domains", - data: {} - }.to_json) - - visit new_registrar_bulk_change_url - click_link('Bulk renew') - select '1 year', from: 'Period' - click_button 'Filter' - click_button 'Renew' - - assert_text 'Not enough funds for renew domains' - - end -end diff --git a/test/system/registrar_area/bulk_change/bulk_transfer_test.rb b/test/system/registrar_area/bulk_change/bulk_transfer_test.rb deleted file mode 100644 index 820b1cf96..000000000 --- a/test/system/registrar_area/bulk_change/bulk_transfer_test.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase - setup do - sign_in users(:api_goodnames) - end - - def test_transfer_multiple_domains_in_bulk - request_body = { data: { domain_transfers: [{ domain_name: 'shop.test', transfer_code: '65078d5' }] } } - headers = { 'Content-type' => Mime[:json] } - request_stub = stub_request(:post, /domains\/transfer/).with(body: request_body, - headers: headers, - basic_auth: ['test_goodnames', 'testtest']) - .to_return(body: { data: { success: [{ type: 'domain_transfer', domain_name: 'shop.test' }], - failed: [] - } }.to_json, status: 200) - - visit registrar_domains_url - click_link 'Bulk change' - click_link 'Bulk transfer' - attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s - click_button 'Transfer' - - assert_requested request_stub - assert_current_path registrar_domains_path - assert_text '1 domains have been successfully transferred' - end - - def test_fail_gracefully - body = { message: 'epic fail' }.to_json - headers = { 'Content-type' => Mime[:json] } - stub_request(:post, /domains\/transfer/).to_return(status: 400, body: body, headers: headers) - - visit registrar_domains_url - click_link 'Bulk change' - click_link 'Bulk transfer' - attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s - click_button 'Transfer' - - assert_text 'epic fail' - end -end diff --git a/test/system/registrar_area/bulk_change/nameserver_test.rb b/test/system/registrar_area/bulk_change/nameserver_test.rb deleted file mode 100644 index cfde8e6d1..000000000 --- a/test/system/registrar_area/bulk_change/nameserver_test.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase - setup do - sign_in users(:api_goodnames) - Capybara.default_max_wait_time = 10 - end - - def test_replaces_current_registrar_nameservers - request_body = { data: { type: 'nameserver', - id: 'ns1.bestnames.test', - domains: [], - attributes: { hostname: 'new-ns.bestnames.test', - ipv4: %w[192.0.2.55 192.0.2.56], - ipv6: %w[2001:db8::55 2001:db8::56] } } } - request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body, - headers: { 'Content-type' => Mime[:json] }, - basic_auth: ['test_goodnames', 'testtest']) - .to_return(body: { data: { - type: 'nameserver', - id: 'new-ns.bestnames.test', - affected_domains: ["airport.test", "shop.test"], - skipped_domains: [] - } - }.to_json, status: 200) - - visit registrar_domains_url - click_link 'Bulk change' - click_link 'Nameserver' - - fill_in 'Old hostname (optional)', with: 'ns1.bestnames.test' - fill_in 'New hostname', with: 'new-ns.bestnames.test' - fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56" - fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56" - click_on 'Replace/Add nameserver' - - assert_requested request_stub - assert_current_path registrar_domains_path - assert_text 'Nameserver have been successfully replaced' - assert_text 'Affected domains: airport.test, shop.test' - end - - def test_fails_gracefully - stub_request(:put, /registrar\/nameservers/).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 'Nameserver' - - fill_in 'Old hostname (optional)', with: 'old hostname' - fill_in 'New hostname', with: 'new hostname' - fill_in 'ipv4', with: 'ipv4' - fill_in 'ipv6', with: 'ipv6' - click_on 'Replace/Add nameserver' - - assert_text 'epic fail' - assert_field 'Old hostname (optional)', with: 'old hostname' - assert_field 'New hostname', with: 'new hostname' - assert_field 'ipv4', with: 'ipv4' - assert_field 'ipv6', with: 'ipv6' - end - - def test_replaces_nameservers_only_for_scoped_domains - request_body = { data: { type: 'nameserver', - id: 'ns1.bestnames.test', - domains: ['shop.test'], - attributes: { hostname: 'new-ns.bestnames.test', - ipv4: %w[192.0.2.55 192.0.2.56], - ipv6: %w[2001:db8::55 2001:db8::56] } } } - request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body, - headers: { 'Content-type' => Mime[:json] }, - basic_auth: ['test_goodnames', 'testtest']) - .to_return(body: { data: { - type: 'nameserver', - id: 'new-ns.bestnames.test', - affected_domains: ["shop.test"], - skipped_domains: []}}.to_json, status: 200) - - visit registrar_domains_url - click_link 'Bulk change' - click_link 'Nameserver' - - fill_in 'Old hostname (optional)', with: 'ns1.bestnames.test' - fill_in 'New hostname', with: 'new-ns.bestnames.test' - fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56" - fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56" - attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_ns_replacement.csv').to_s - - click_on 'Replace/Add nameserver' - - assert_requested request_stub - assert_current_path registrar_domains_path - assert_text 'Nameserver have been successfully replaced' - assert_text 'Affected domains: shop.test' - end - - def test_replaces_nameservers_with_invalid_domains_list - nameserver = nameservers(:shop_ns1) - - visit registrar_domains_url - click_link 'Bulk change' - click_link 'Nameserver' - - fill_in 'Old hostname (optional)', with: nameserver.hostname - fill_in 'New hostname', with: 'new-ns.bestnames.test' - fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56" - fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56" - attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'invalid_domains_for_ns_replacement.csv').to_s - - assert_no_changes -> { nameserver.hostname } do - click_on 'Replace/Add nameserver' - end - - assert_current_path registrar_domains_path - assert_text 'CSV scoped domain list seems empty. Make sure that domains are added and "Domain" header is present.' - end - - def test_adding_current_registrar_nameservers - request_body = { data: { type: 'nameserver', - id: '', - domains: [], - attributes: { hostname: 'new-ns2.bestnames.test', - ipv4: %w[192.0.2.55 192.0.2.56], - ipv6: %w[2001:db8::55 2001:db8::56] } } } - request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body, - headers: { 'Content-type' => Mime[:json] }, - basic_auth: ['test_goodnames', 'testtest']) - .to_return(body: { data: { - type: 'nameserver', - id: 'new-ns2.bestnames.test', - affected_domains: ["airport.test", "shop.test"], - skipped_domains: [] - } - }.to_json, status: 200) - - visit registrar_domains_url - click_link 'Bulk change' - click_link 'Nameserver' - - fill_in 'New hostname', with: 'new-ns2.bestnames.test' - fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56" - fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56" - click_on 'Replace/Add nameserver' - - assert_requested request_stub - assert_current_path registrar_domains_path - assert_text 'Nameserver have been successfully added' - assert_text 'Affected domains: airport.test, shop.test' - end - - def test_adding_nameservers_only_for_scoped_domains - request_body = { data: { type: 'nameserver', - id: '', - domains: ['shop.test'], - attributes: { hostname: 'new-ns1.bestnames.test', - ipv4: %w[192.0.2.55 192.0.2.56], - ipv6: %w[2001:db8::55 2001:db8::56] } } } - request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body, - headers: { 'Content-type' => Mime[:json] }, - basic_auth: ['test_goodnames', 'testtest']) - .to_return(body: { data: { - type: 'nameserver', - id: 'new-ns1.bestnames.test', - affected_domains: ["shop.test"], - skipped_domains: []}}.to_json, status: 200) - - visit registrar_domains_url - click_link 'Bulk change' - click_link 'Nameserver' - - fill_in 'New hostname', with: 'new-ns1.bestnames.test' - fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56" - fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56" - attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_ns_replacement.csv').to_s - - click_on 'Replace/Add nameserver' - - assert_requested request_stub - assert_current_path registrar_domains_path - assert_text 'Nameserver have been successfully added' - assert_text 'Affected domains: shop.test' - end -end diff --git a/test/system/registrar_area/bulk_change/tech_contact_test.rb b/test/system/registrar_area/bulk_change/tech_contact_test.rb deleted file mode 100644 index 055ec25ca..000000000 --- a/test/system/registrar_area/bulk_change/tech_contact_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase - setup do - sign_in users(:api_bestnames) - end - - def test_replace_domain_contacts_of_current_registrar - request_stub = stub_request(:patch, /domains\/contacts/) - .with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' }, - basic_auth: ['test_bestnames', 'testtest']) - .to_return(body: { 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' - - 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 - assert_current_path registrar_domains_path - assert_text 'Technical 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\/contacts/) - .to_return(status: 400, - body: { message: 'epic fail' }.to_json, - headers: { 'Content-type' => Mime[:json] }) - - visit registrar_domains_url - click_link 'Bulk change' - - 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' - assert_field 'Current contact ID', with: 'william-001' - assert_field 'New contact ID', with: 'john-001' - end -end diff --git a/test/system/registrar_area/contact_test.rb b/test/system/registrar_area/contact_test.rb deleted file mode 100644 index 8d156f1b8..000000000 --- a/test/system/registrar_area/contact_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaContactTest < ApplicationSystemTestCase - setup do - @registrar = registrars(:bestnames) - @contact = contacts(:john) - sign_in users(:api_bestnames) - end - - def test_creates_contact_with_invalid_phone - visit registrar_contacts_path - click_on 'New' - - fill_in 'depp_contact_ident', with: @contact.ident - fill_in 'depp_contact_name', with: @contact.name - fill_in 'depp_contact_email', with: @contact.email - fill_in 'depp_contact_phone', with: '372' - click_on 'Create' - - assert_text 'Phone number must be in +XXX.YYYYYYY format' - end - - def test_updates_contact_with_invalid_phone - depp_contact = Depp::Contact.new( - id: @contact.id, - name: @contact.name, - code: @contact.code, - email: @contact.email, - phone: @contact.phone, - ident: @contact.ident, - ident_type: @contact.ident_type, - ident_country_code: @contact.ident_country_code) - - Spy.on(Depp::Contact, :find_by_id).and_return(depp_contact) - - visit edit_registrar_contact_path(depp_contact.code) - - assert_text "Edit: #{depp_contact.name}" - - fill_in 'depp_contact_phone', with: '372' - click_on 'Save' - - assert_text 'Phone number must be in +XXX.YYYYYYY format' - end -end diff --git a/test/system/registrar_area/domains_test.rb b/test/system/registrar_area/domains_test.rb deleted file mode 100644 index 7a2f5f7f1..000000000 --- a/test/system/registrar_area/domains_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'application_system_test_case' - -class RegistrarDomainsTest < ApplicationSystemTestCase - def test_downloads_domain_list_as_csv - sign_in users(:api_bestnames) - travel_to Time.zone.parse('2010-07-05 10:30') - - expected_csv = <<-CSV.strip_heredoc - Domain,Transfer code,Registrant name,Registrant code,Date of expiry - library.test,45118f5,Acme Ltd,acme-ltd-001,2010-07-05 - shop.test,65078d5,John,john-001,2010-07-05 - invalid.test,1438d6,any,invalid,2010-07-05 - airport.test,55438j5,John,john-001,2010-07-05 - CSV - - visit registrar_domains_url - click_button 'Download CSV' - assert_equal "attachment; filename=\"Domains_2010-07-05_10.30.csv\"; filename*=UTF-8''Domains_2010-07-05_10.30.csv", response_headers['Content-Disposition'] - assert_equal expected_csv, page.body - end -end diff --git a/test/system/registrar_area/invoices/list_test.rb b/test/system/registrar_area/invoices/list_test.rb deleted file mode 100644 index ffab9c202..000000000 --- a/test/system/registrar_area/invoices/list_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'application_system_test_case' - -class ListInvoicesTest < ApplicationSystemTestCase - setup do - @user = users(:api_bestnames) - @invoice = invoices(:one) - - sign_in @user - end - - def test_show_balance - visit registrar_invoices_path - assert_text "Your current account balance is 100,00 EUR" - end - - def test_shows_invoice_title - visit registrar_invoices_path - assert_text 'Invoice', minimum: 2 - end - - def test_shows_invoice_owned_by_current_user - owning_registrar = registrars(:bestnames) - assert_equal owning_registrar, @user.registrar - @invoice.update!(buyer: owning_registrar) - - visit registrar_invoices_url - - assert_text @invoice.to_s - end - - def test_hides_invoice_owned_by_other_user - other_registrar = registrars(:goodnames) - assert_not_equal other_registrar, @user.registrar - @invoice.update!(buyer: other_registrar) - - visit registrar_invoices_url - - assert_no_text @invoice.to_s - end -end diff --git a/test/system/registrar_area/invoices/new_invoice_payment_test.rb b/test/system/registrar_area/invoices/new_invoice_payment_test.rb deleted file mode 100644 index 77050f12a..000000000 --- a/test/system/registrar_area/invoices/new_invoice_payment_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'application_system_test_case' - -class NewInvoicePaymentTest < ApplicationSystemTestCase - def setup - super - eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}") - Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response) - - @original_vat_prc = Setting.registry_vat_prc - Setting.registry_vat_prc = 0.2 - @user = users(:api_bestnames) - sign_in @user - end - - def teardown - super - - Setting.registry_vat_prc = @original_vat_prc - end - - def create_invoice_and_visit_its_page - visit registrar_invoices_path - click_link_or_button 'Add deposit' - fill_in 'Amount', with: '200.00' - fill_in 'Description', with: 'My first invoice' - click_link_or_button 'Add' - end -end diff --git a/test/system/registrar_area/invoices/new_test.rb b/test/system/registrar_area/invoices/new_test.rb deleted file mode 100644 index a1b66ac47..000000000 --- a/test/system/registrar_area/invoices/new_test.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'application_system_test_case' - -class NewInvoiceTest < ApplicationSystemTestCase - def setup - super - - @user = users(:api_bestnames) - sign_in @user - - eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}") - Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response) - end - - def test_show_balance - visit registrar_invoices_path - assert_text "Your current account balance is 100,00 EUR" - end - - def test_create_new_invoice_with_positive_amount - if Feature.billing_system_integrated? - invoice_n = Invoice.order(number: :desc).last.number - stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator"). - to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {}) - - stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response"). - to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {}) - - stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice"). - to_return(status: 200, body: "", headers: {}) - - visit registrar_invoices_path - click_link_or_button 'Add deposit' - fill_in 'Amount', with: '200.00' - fill_in 'Description', with: 'My first invoice' - - assert_difference 'Invoice.count', 1 do - click_link_or_button 'Add' - end - - assert_text 'Please pay the following invoice' - assert_text "Invoice no. #{invoice_n + 3}" - assert_text 'Subtotal 200,00 €' - assert_text 'Pay invoice' - end - end - - def test_create_new_invoice_with_comma_in_number - if Feature.billing_system_integrated? - invoice_n = Invoice.order(number: :desc).last.number - stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator"). - to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {}) - - stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response"). - to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {}) - - stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice"). - to_return(status: 200, body: "", headers: {}) - - visit registrar_invoices_path - click_link_or_button 'Add deposit' - fill_in 'Amount', with: '200,00' - fill_in 'Description', with: 'My first invoice' - - assert_difference 'Invoice.count', 1 do - click_link_or_button 'Add' - end - - assert_text 'Please pay the following invoice' - assert_text "Invoice no. #{invoice_n + 3}" - assert_text 'Subtotal 200,00 €' - assert_text 'Pay invoice' - end - end - - def test_create_new_invoice_fails_when_amount_is_0 - visit registrar_invoices_path - click_link_or_button 'Add deposit' - fill_in 'Amount', with: '0.00' - fill_in 'Description', with: 'My first invoice' - - assert_no_difference 'Invoice.count' do - click_link_or_button 'Add' - end - - assert_text 'Amount is too small. Minimum deposit is 0.01 EUR' - end - - def test_create_new_invoice_fails_when_amount_is_negative - visit registrar_invoices_path - click_link_or_button 'Add deposit' - fill_in 'Amount', with: '-120.00' - fill_in 'Description', with: 'My first invoice' - - assert_no_difference 'Invoice.count' do - click_link_or_button 'Add' - end - - assert_text 'Amount is too small. Minimum deposit is 0.01 EUR' - end -end diff --git a/test/system/registrar_area/invoices_test.rb b/test/system/registrar_area/invoices_test.rb deleted file mode 100644 index 1c6d1d780..000000000 --- a/test/system/registrar_area/invoices_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaInvoicesTest < ApplicationSystemTestCase - include ActionMailer::TestHelper - - setup do - sign_in users(:api_bestnames) - @invoice = invoices(:one) - - ActionMailer::Base.deliveries.clear - eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}") - Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response) - end - - def test_cancels_an_invoice - Spy.on(EisBilling::SendInvoiceStatus, :send_info).and_return(true) - - @invoice.account_activity = nil - assert @invoice.cancellable? - - visit registrar_invoice_url(@invoice) - click_on 'Cancel' - @invoice.reload - - assert @invoice.cancelled? - assert_text 'Invoice has been cancelled' - end - - def test_invoice_delivery_form_is_pre_populated_with_billing_email_of_a_registrar - assert_equal 'billing@bestnames.test', @invoice.buyer.billing_email - visit new_registrar_invoice_delivery_url(@invoice) - assert_field 'Recipient', with: 'billing@bestnames.test' - end - - def test_delivers_an_invoice - visit registrar_invoice_url(@invoice) - click_on 'Send' - fill_in 'Recipient', with: 'billing@registrar.test' - click_on 'Send' - - assert_emails 1 - email = ActionMailer::Base.deliveries.first - assert_equal ['billing@registrar.test'], email.to - assert_current_path registrar_invoice_path(@invoice) - assert_text 'Invoice has been sent' - end - - def test_if_invoice_unpaid_and_not_generated_link_comes_then_should_render_no_everypay_link - invoice = invoices(:unpaid) - visit registrar_invoice_url(invoice) - - assert_text 'No everypay link' - end - - def test_if_invoice_aldready_paid_there_should_not_any_everypay_link - visit registrar_invoice_url(@invoice) - - assert_no_text 'No everypay link' - assert_no_text 'Everypay link' - end -end diff --git a/test/system/registrar_area/protected_area_test.rb b/test/system/registrar_area/protected_area_test.rb deleted file mode 100644 index f1be6008d..000000000 --- a/test/system/registrar_area/protected_area_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaProtectedAreaTest < ApplicationSystemTestCase - def test_anonymous_user_is_asked_to_authenticate_when_navigating_to_protected_area - visit registrar_domains_url - assert_text 'You need to sign in before continuing' - assert_current_path new_registrar_user_session_path - end - - def test_authenticated_user_can_access_protected_area - sign_in users(:api_bestnames) - visit registrar_domains_url - - assert_no_text 'You need to sign in before continuing' - assert_current_path registrar_domains_path - end - - def test_authenticated_user_is_not_asked_to_authenticate_again - sign_in users(:api_bestnames) - visit new_registrar_user_session_url - - assert_text 'You are already signed in' - assert_current_path registrar_root_path - end -end \ No newline at end of file diff --git a/test/system/registrar_area/settings/balance_auto_reload_test.rb b/test/system/registrar_area/settings/balance_auto_reload_test.rb deleted file mode 100644 index 066fb6186..000000000 --- a/test/system/registrar_area/settings/balance_auto_reload_test.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaSettingsBalanceAutoReloadTest < ApplicationSystemTestCase - setup do - @registrar = registrars(:bestnames) - @user = users(:api_bestnames) - sign_in @user - end - - def test_enables_balance_auto_reload - amount = 100 - threshold = 10 - assert_nil @registrar.settings['balance_auto_reload'] - - visit registrar_account_path - click_on 'Enable' - fill_in 'Amount', with: amount - fill_in 'Threshold', with: threshold - click_button 'Save' - - assert_current_path registrar_account_path - assert_text 'Balance Auto-Reload setting has been updated' - - # Using `number_to_currency` leads to `expected to find text "Reload 100,00 € when your balance - # drops to 10,00 €" in "...Reload 100,00 € when your balance drops to 10,00 €...` - assert_text 'Reload 100,00 € when your balance drops to 10,00 €' - end - - def test_disables_balance_auto_reload - @registrar.update!(settings: { balance_auto_reload: { type: {} } }) - - visit registrar_account_path - click_on 'Disable' - - assert_current_path registrar_account_path - assert_text 'Balance Auto-Reload setting has been disabled' - end - - def test_edits_balance_auto_reload - @registrar.update!(settings: { balance_auto_reload: { type: { name: 'threshold', - amount: 100, - threshold: 10 } } }) - - visit registrar_account_path - within '.balance-auto-reload' do - click_on 'Edit' - end - fill_in 'Amount', with: '101' - fill_in 'Threshold', with: '11' - click_button 'Save' - - assert_current_path registrar_account_path - assert_text 'Balance Auto-Reload setting has been updated' - end - - def test_form_is_pre_populated_when_editing - amount = 100 - threshold = 10 - @registrar.update!(settings: { balance_auto_reload: { type: { name: 'threshold', - amount: amount, - threshold: threshold } } }) - - visit edit_registrar_settings_balance_auto_reload_path - - assert_field 'Amount', with: amount - assert_field 'Threshold', with: threshold - end - - def test_user_of_epp_role_cannot_edit_balance_auto_reload_setting - @user.update!(roles: [ApiUser::EPP]) - visit registrar_account_path - assert_no_text 'Balance Auto-Reload' - end -end \ No newline at end of file diff --git a/test/system/registrar_area/sign_in/password_test.rb b/test/system/registrar_area/sign_in/password_test.rb deleted file mode 100644 index a362e98e3..000000000 --- a/test/system/registrar_area/sign_in/password_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaPasswordSignInTest < ApplicationSystemTestCase - setup do - @user = users(:api_bestnames) - end - - def test_correct_username_and_password - login_with_correct_credentials - assert_text 'Log out' - assert_current_path registrar_root_path - end - - def test_after_successful_sign_in_super_user_sees_service_message_list - @user.update!(roles: [ApiUser::SUPER]) - login_with_correct_credentials - assert_current_path registrar_root_path - end - - def test_after_successful_sign_in_billing_user_sees_account - @user.update!(roles: [ApiUser::BILLING]) - login_with_correct_credentials - assert_current_path registrar_account_path - end - - def test_wrong_password - visit new_registrar_user_session_url - fill_in 'registrar_user_username', with: @user.username - fill_in 'registrar_user_password', with: 'wrong' - click_button 'Login' - - assert_text 'No such user' - assert_current_path new_registrar_user_session_path - end - - def test_inactive_user - @user.update!(active: false) - login_with_correct_credentials - - assert_text 'User is not active' - assert_current_path new_registrar_user_session_path - end - - private - - def login_with_correct_credentials - visit new_registrar_user_session_url - fill_in 'registrar_user_username', with: @user.username - fill_in 'registrar_user_password', with: 'testtest' - click_button 'Login' - end -end \ No newline at end of file diff --git a/test/system/registrar_area/sign_out_test.rb b/test/system/registrar_area/sign_out_test.rb deleted file mode 100644 index 040836600..000000000 --- a/test/system/registrar_area/sign_out_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaSignOutTest < ApplicationSystemTestCase - setup do - sign_in users(:api_bestnames) - end - - def test_logout - visit registrar_root_url - click_on 'Log out' - - assert_text 'Signed out successfully' - assert_current_path new_registrar_user_session_path - end -end \ No newline at end of file diff --git a/test/system/registrar_area/tara/tara_users_test.rb b/test/system/registrar_area/tara/tara_users_test.rb deleted file mode 100644 index 005504043..000000000 --- a/test/system/registrar_area/tara/tara_users_test.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'application_system_test_case' - -class TaraUsersTest < ApplicationSystemTestCase - def setup - super - - OmniAuth.config.test_mode = true - @user = users(:api_bestnames) - - @existing_user_hash = { - 'provider' => 'tara', - 'uid' => "EE" + @user.identity_code - } - - @new_user_hash = { - 'provider' => 'tara', - 'uid' => 'EE51007050604' - } - end - - def teardown - super - - OmniAuth.config.test_mode = false - OmniAuth.config.mock_auth['tara'] = nil - end - - def test_existing_user_gets_signed_in - OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@existing_user_hash) - - visit new_registrar_user_session_path - click_link('Sign in') - - 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) - - visit new_registrar_user_session_path - click_link('Sign in') - - 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 diff --git a/test/system/registrar_area/xml_consoles_test.rb b/test/system/registrar_area/xml_consoles_test.rb deleted file mode 100644 index 51cc362eb..000000000 --- a/test/system/registrar_area/xml_consoles_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaXmlConsolesTest < ApplicationSystemTestCase - setup do - sign_in users(:api_bestnames) - end - - def test_epp_server_does_not_response - visit registrar_xml_console_path - fill_in 'payload', with: schema_example - click_on 'Send EPP Request' - - el = page.find('.CodeRay', visible: :all) - assert el.text.include? 'CONNECTION ERROR - Is the EPP server running?' - end - - private - - def schema_example - <<~XML - - - - - - auction.test - - - - - XML - end -end