mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
Merge branch 'master' into registry-791
This commit is contained in:
commit
36b137eb84
129 changed files with 2226 additions and 3275 deletions
5
test/fixtures/bank_transactions.yml
vendored
5
test/fixtures/bank_transactions.yml
vendored
|
@ -1,3 +1,8 @@
|
|||
one:
|
||||
sum: 1
|
||||
currency: EUR
|
||||
|
||||
for_payments_test:
|
||||
description: "Order nr. 1"
|
||||
currency: "EUR"
|
||||
iban: "1234"
|
||||
|
|
2
test/fixtures/contacts.yml
vendored
2
test/fixtures/contacts.yml
vendored
|
@ -76,7 +76,7 @@ not_in_use:
|
|||
|
||||
invalid:
|
||||
name: any
|
||||
code: any
|
||||
code: invalid
|
||||
email: invalid@invalid.test
|
||||
auth_info: any
|
||||
registrar: bestnames
|
||||
|
|
15
test/fixtures/domain_contacts.yml
vendored
15
test/fixtures/domain_contacts.yml
vendored
|
@ -8,11 +8,26 @@ shop_william:
|
|||
contact: william
|
||||
type: TechDomainContact
|
||||
|
||||
shop_acme_ltd:
|
||||
domain: shop
|
||||
contact: acme_ltd
|
||||
type: TechDomainContact
|
||||
|
||||
airport_john:
|
||||
domain: airport
|
||||
contact: john
|
||||
type: AdminDomainContact
|
||||
|
||||
airport_william_admin:
|
||||
domain: airport
|
||||
contact: william
|
||||
type: AdminDomainContact
|
||||
|
||||
airport_william_tech:
|
||||
domain: airport
|
||||
contact: william
|
||||
type: TechDomainContact
|
||||
|
||||
library_john:
|
||||
domain: library
|
||||
contact: john
|
||||
|
|
15
test/fixtures/files/seb_bank_cert.pem
vendored
Normal file
15
test/fixtures/files/seb_bank_cert.pem
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIICVTCCAb4CCQCdHk6fGGIg9DANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJF
|
||||
RTERMA8GA1UECAwISGFyanVtYWExEDAOBgNVBAcMB1RhbGxpbm4xJTAjBgNVBAoM
|
||||
HEVzdG9uaWFuIEludGVybmV0IEZvdW5kYXRpb24xFDASBgNVBAMMC2ludGVybmV0
|
||||
LmVlMB4XDTE4MDQyMTEyNDEyMloXDTE4MDUyMTEyNDEyMlowbzELMAkGA1UEBhMC
|
||||
RUUxETAPBgNVBAgMCEhhcmp1bWFhMRAwDgYDVQQHDAdUYWxsaW5uMSUwIwYDVQQK
|
||||
DBxFc3RvbmlhbiBJbnRlcm5ldCBGb3VuZGF0aW9uMRQwEgYDVQQDDAtpbnRlcm5l
|
||||
dC5lZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4QPTaFdN+03vC63vgcSd
|
||||
OsURjrt/eslJkPXr53VgkcFoD2AI+z1AoUbOMJ/FfXb+iY4o70we3YeRP8SeaDFn
|
||||
pjOlSmS+DTsh5s3DCahbdbFzvyBDD5A4yKRaVRSCWFEjC684Uvg9Pf/ifP6GxHN6
|
||||
uVFg9/YhkS9XwfE0deJhxUUCAwEAATANBgkqhkiG9w0BAQsFAAOBgQCKC6bL+4Eu
|
||||
+Dz+RQEZ9IEerZSKnnV2mygN9usddg46BnMqceWCA19Ei71C2UQsVD2e+7XkLjrl
|
||||
0IDGciQqAjOUp4KKG+jQbtlcP0BBvP6CnirwqFfeV0XLWKapLetDjtdlmACAtHXj
|
||||
8U0YFVbj5GGPJWAfAPnzpsiTxnQIinXNZw==
|
||||
-----END CERTIFICATE-----
|
16
test/fixtures/files/seb_seller_key.pem
vendored
Normal file
16
test/fixtures/files/seb_seller_key.pem
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
-----BEGIN PRIVATE KEY-----
|
||||
MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAOED02hXTftN7wut
|
||||
74HEnTrFEY67f3rJSZD16+d1YJHBaA9gCPs9QKFGzjCfxX12/omOKO9MHt2HkT/E
|
||||
nmgxZ6YzpUpkvg07IebNwwmoW3Wxc78gQw+QOMikWlUUglhRIwuvOFL4PT3/4nz+
|
||||
hsRzerlRYPf2IZEvV8HxNHXiYcVFAgMBAAECgYEAxLXAgm4YaUK3YOF9CVgmD/Oq
|
||||
Jrp5dpEzs/uZcO4nLyUCYLaXA3SH5LXumYmDb+ywFvbliFVmgkn6y+GKjhHqxjhx
|
||||
KtyK3w1vGVkk6RyA076vgnOEp3un7j9XXM5U93Osk25Ezzb4pqslU7nDPb1OGg2A
|
||||
q4UG+zHyj9UkI2S1V10CQQD39JtA3eiSlJ4jtr7QP3/KFV3O7Sku5TTmc6aMUhja
|
||||
9qZCUMaK/67aMFjl62E9vdNBb1gGg28dBo/zV0uZAdsrAkEA6FCvyzaMOOzWqz6N
|
||||
/uzeU7NTW9cHNQRx1d7e3vjWhYxvvknNrFim3sH+tbTock5MeNr4d4yCYFM72Zc5
|
||||
wH/pTwJBAIrD7OMnjZIC9GGeUzluYBDzVjWJCmRBSBK0pH+hLmHUaYVxeTuvDebz
|
||||
6bx6t0f7ZTAYpRW4FsYStxsDPr6ZiFMCQFh7SslKSFPyGLz2QVzj2LXmagxjtLID
|
||||
tFux3A7ulb4dw/2k3HoU9dGH77xDX/kRS10IgXP/BzUq3nO8flmMHk8CQQCCnqcJ
|
||||
CEA+kqwPvgQ8YdeJOBFEc4spQ+OFbLUAtMt8+9YfeWtHyUlyNhtGXmwN8kGAHcPz
|
||||
qtfPVIDR4dU0uvCw
|
||||
-----END PRIVATE KEY-----
|
6
test/fixtures/invoices.yml
vendored
6
test/fixtures/invoices.yml
vendored
|
@ -31,3 +31,9 @@ outstanding:
|
|||
overdue:
|
||||
<<: *DEFAULTS
|
||||
due_date: <%= Date.parse '2010-07-03' %>
|
||||
|
||||
for_payments_test:
|
||||
<<: *DEFAULTS
|
||||
total: 12.00
|
||||
id: 1
|
||||
number: 1
|
||||
|
|
4
test/fixtures/nameservers.yml
vendored
4
test/fixtures/nameservers.yml
vendored
|
@ -18,6 +18,10 @@ airport_ns1:
|
|||
hostname: ns1.bestnames.test
|
||||
domain: airport
|
||||
|
||||
airport_ns2:
|
||||
hostname: ns2.bestnames.test
|
||||
domain: airport
|
||||
|
||||
metro_ns1:
|
||||
hostname: ns1.bestnames.test
|
||||
domain: metro
|
||||
|
|
60
test/integration/admin/contact_versions_test.rb
Normal file
60
test/integration/admin/contact_versions_test.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContactVersionsTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
create_contact_with_history
|
||||
login_as users(:admin)
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
delete_objects_once_done
|
||||
end
|
||||
|
||||
def create_contact_with_history
|
||||
sql = <<-SQL.squish
|
||||
INSERT INTO registrars (id, name, reg_no, email, country_code, code,
|
||||
accounting_customer_code, language)
|
||||
VALUES (75, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
|
||||
'test123', 'en');
|
||||
|
||||
INSERT INTO contacts (id, code, auth_info, registrar_id)
|
||||
VALUES (75, 'test_code', '8b4d462aa04194ca78840a', 75);
|
||||
|
||||
INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object,
|
||||
object_changes, created_at, session, children, ident_updated_at, uuid)
|
||||
VALUES ('Contact', 75, 'update', '1-AdminUser',
|
||||
'{"id": 75, "code": "test_code", "auth_info": "8b4d462aa04194ca78840a", "registrar_id": 75, "old_field": "value"}',
|
||||
'{"other_made_up_field": "value"}',
|
||||
'2018-04-23 15:50:48.113491', '2018-04-23 12:44:56',
|
||||
'{"legal_documents":[null]}', null, null
|
||||
)
|
||||
SQL
|
||||
|
||||
ActiveRecord::Base.connection.execute(sql)
|
||||
end
|
||||
|
||||
def delete_objects_once_done
|
||||
ActiveRecord::Base.connection.execute('DELETE from log_contacts where item_id = 75')
|
||||
Domain.destroy_all
|
||||
Contact.destroy_all
|
||||
Registrar.destroy_all
|
||||
end
|
||||
|
||||
def test_removed_fields_are_not_causing_errors_in_index_view
|
||||
visit admin_contact_versions_path
|
||||
assert_text 'test_registrar'
|
||||
assert_text 'update 23.04.18, 18:50'
|
||||
end
|
||||
|
||||
def test_removed_fields_are_not_causing_errors_in_details_view
|
||||
version_id = Contact.find(75).versions.last
|
||||
visit admin_contact_version_path(version_id)
|
||||
|
||||
assert_text 'test_registrar'
|
||||
assert_text '23.04.18, 18:50 update 1-AdminUser'
|
||||
end
|
||||
end
|
25
test/integration/admin/contacts_test.rb
Normal file
25
test/integration/admin/contacts_test.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminContactsTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@contact = contacts(:william)
|
||||
login_as users(:admin)
|
||||
end
|
||||
|
||||
def test_display_list
|
||||
visit admin_contacts_path
|
||||
|
||||
assert_text('william-001')
|
||||
assert_text('william-002')
|
||||
assert_text('acme-ltd-001')
|
||||
end
|
||||
|
||||
def test_display_details
|
||||
visit admin_contact_path(@contact)
|
||||
|
||||
assert_text('Street Main Street City New York Postcode 12345 ' \
|
||||
'State New York Country United States of America')
|
||||
end
|
||||
end
|
65
test/integration/admin/domain_versions_test.rb
Normal file
65
test/integration/admin/domain_versions_test.rb
Normal file
|
@ -0,0 +1,65 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainVersionsTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
create_domain_with_history
|
||||
login_as users(:admin)
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
delete_objects_once_done
|
||||
end
|
||||
|
||||
def create_domain_with_history
|
||||
sql = <<-SQL.squish
|
||||
INSERT INTO registrars (id, name, reg_no, email, country_code, code,
|
||||
accounting_customer_code, language)
|
||||
VALUES (54, 'test_registrar', 'test123', 'test@test.com', 'EE', 'TEST123',
|
||||
'test123', 'en');
|
||||
|
||||
INSERT INTO contacts (id, code, auth_info, registrar_id)
|
||||
VALUES (54, 'test_code', '8b4d462aa04194ca78840a', 54);
|
||||
|
||||
INSERT INTO domains (id, registrar_id, valid_to, registrant_id,
|
||||
transfer_code)
|
||||
VALUES (54, 54, '2018-06-23T12:14:02.732+03:00', 54, 'transfer_code');
|
||||
|
||||
INSERT INTO log_domains (item_type, item_id, event, whodunnit, object,
|
||||
object_changes, created_at, nameserver_ids, tech_contact_ids,
|
||||
admin_contact_ids, session, children)
|
||||
VALUES ('Domain', 54, 'update', '1-AdminUser',
|
||||
'{"id": 54, "registrar_id": 54, "valid_to": "2018-07-23T12:14:05.583+03:00", "registrant_id": 54, "transfer_code": "transfer_code", "valid_from": "2017-07-23T12:14:05.583+03:00"}',
|
||||
'{"foo": "bar", "other_made_up_field": "value"}',
|
||||
'2018-04-23 15:50:48.113491', '{}', '{}', '{}', '2018-04-23 12:44:56',
|
||||
'{"null_fracdmin_contacts":[108],"tech_contacts":[109],"nameservers":[],"dnskeys":[],"legal_documents":[null],"registrant":[1]}'
|
||||
)
|
||||
SQL
|
||||
ActiveRecord::Base.connection.execute(sql)
|
||||
end
|
||||
|
||||
def delete_objects_once_done
|
||||
ActiveRecord::Base.connection.execute('DELETE FROM log_domains where item_id = 54')
|
||||
Domain.destroy_all
|
||||
Contact.destroy_all
|
||||
Registrar.destroy_all
|
||||
end
|
||||
|
||||
def test_removed_fields_are_not_causing_errors_in_index_view
|
||||
visit admin_domain_versions_path
|
||||
|
||||
assert_text 'test_registrar'
|
||||
assert_text 'test_registrar update 23.04.18, 18:50'
|
||||
end
|
||||
|
||||
def test_removed_fields_are_not_causing_errors_in_details_view
|
||||
version_id = Domain.find(54).versions.last
|
||||
visit admin_domain_version_path(version_id)
|
||||
|
||||
assert_text 'test_registrar'
|
||||
assert_text '23.04.18, 18:50 update 1-AdminUser'
|
||||
end
|
||||
end
|
124
test/integration/api/domain_contacts_test.rb
Normal file
124
test/integration/api/domain_contacts_test.rb
Normal file
|
@ -0,0 +1,124 @@
|
|||
require 'test_helper'
|
||||
|
||||
class APIDomainContactsTest < ActionDispatch::IntegrationTest
|
||||
def test_replace_all_tech_contacts_of_the_current_registrar
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_nil domains(:shop).tech_contacts.find_by(code: 'william-001')
|
||||
assert domains(:shop).tech_contacts.find_by(code: 'john-001')
|
||||
assert domains(:airport).tech_contacts.find_by(code: 'john-001')
|
||||
end
|
||||
|
||||
def test_skip_discarded_domains
|
||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).tech_contacts.find_by(code: 'william-001')
|
||||
end
|
||||
|
||||
def test_return_affected_domains_in_alphabetical_order
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ 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/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal %w[airport.test shop.test], JSON.parse(response.body,
|
||||
symbolize_names: true)[:skipped_domains]
|
||||
end
|
||||
|
||||
def test_keep_other_tech_contacts_intact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:shop).tech_contacts.find_by(code: 'acme-ltd-001')
|
||||
end
|
||||
|
||||
def test_keep_admin_contacts_intact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).admin_contacts.find_by(code: 'william-001')
|
||||
end
|
||||
|
||||
def test_restrict_contacts_to_the_current_registrar
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'jack-001',
|
||||
new_contact_id: 'william-002' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'current_contact_id',
|
||||
message: 'No such contact: jack-001' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_non_existent_current_contact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'non-existent',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'current_contact_id',
|
||||
message: 'No such contact: non-existent' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_non_existent_new_contact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'non-existent' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'new_contact_id',
|
||||
message: 'No such contact: non-existent' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_disallow_invalid_new_contact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'invalid' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'new_contact_id',
|
||||
message: 'New contact must be valid' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_disallow_self_replacement
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'william-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
message: 'New contact ID must be different from current contact ID' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def http_auth_key
|
||||
ActionController::HttpAuthentication::Basic.encode_credentials('test_bestnames', 'testtest')
|
||||
end
|
||||
end
|
|
@ -53,7 +53,7 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_duplicates_registrant_admin_and_tech_contacts
|
||||
assert_difference -> { @new_registrar.contacts.size }, 2 do
|
||||
assert_difference -> { @new_registrar.contacts.size }, 3 do
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_duplicates_registrant_admin_and_tech_contacts
|
||||
assert_difference -> { @new_registrar.contacts.size }, 2 do
|
||||
assert_difference -> { @new_registrar.contacts.size }, 3 do
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
end
|
||||
end
|
||||
|
|
17
test/integration/registrant/layout_test.rb
Normal file
17
test/integration/registrant/layout_test.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantLayoutTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
login_as(users(:registrant))
|
||||
|
||||
Setting.days_to_keep_business_registry_cache = 1
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
end
|
||||
|
||||
def test_has_link_to_rest_whois
|
||||
visit registrant_domains_url
|
||||
assert(has_link?('Internet.ee', href: 'https://internet.ee'))
|
||||
refute(has_link?('WHOIS', href: 'registrant/whois'))
|
||||
end
|
||||
end
|
|
@ -6,6 +6,7 @@ class BalanceTopUpTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_creates_new_invoice
|
||||
original_vat_prc = Setting.registry_vat_prc
|
||||
Setting.registry_vat_prc = 0.1
|
||||
|
||||
visit registrar_invoices_url
|
||||
|
@ -21,5 +22,7 @@ class BalanceTopUpTest < ActionDispatch::IntegrationTest
|
|||
assert_equal BigDecimal(10), invoice.vat_rate
|
||||
assert_equal BigDecimal('28.05'), invoice.total
|
||||
assert_text 'Please pay the following invoice'
|
||||
|
||||
Setting.registry_vat_prc = original_vat_prc
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||
class RegistrarAreaBulkTransferTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
WebMock.reset!
|
||||
login_as users(:api_goodnames)
|
||||
end
|
||||
|
||||
def test_batch_transfer_succeeds
|
||||
def test_transfer_multiple_domains_in_bulk
|
||||
request_body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||
headers = { 'Content-type' => 'application/json' }
|
||||
request_stub = stub_request(:post, /domain_transfers/).with(body: request_body,
|
||||
|
@ -17,28 +16,26 @@ class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
}] }.to_json, status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Transfer'
|
||||
|
||||
click_on 'Batch'
|
||||
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 batch'
|
||||
click_button 'Transfer'
|
||||
|
||||
assert_requested request_stub
|
||||
assert_current_path registrar_domains_path
|
||||
assert_text '1 domains have been successfully transferred'
|
||||
end
|
||||
|
||||
def test_batch_transfer_fails_gracefully
|
||||
def test_fail_gracefully
|
||||
body = { errors: [{ title: 'epic fail' }] }.to_json
|
||||
headers = { 'Content-type' => 'application/json' }
|
||||
stub_request(:post, /domain_transfers/).to_return(status: 400, body: body, headers: headers)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Transfer'
|
||||
|
||||
click_on 'Batch'
|
||||
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 batch'
|
||||
click_button 'Transfer'
|
||||
|
||||
assert_text 'epic fail'
|
||||
end
|
|
@ -1,8 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
|
||||
class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
WebMock.reset!
|
||||
login_as users(:api_goodnames)
|
||||
end
|
||||
|
||||
|
@ -21,7 +20,8 @@ class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
|
|||
}] }.to_json, status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Replace nameserver'
|
||||
click_link 'Bulk change'
|
||||
click_link 'Nameserver'
|
||||
|
||||
fill_in 'Old hostname', with: 'ns1.bestnames.test'
|
||||
fill_in 'New hostname', with: 'new-ns.bestnames.test'
|
||||
|
@ -40,7 +40,8 @@ class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
|
|||
headers: { 'Content-type' => 'application/json' })
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Replace nameserver'
|
||||
click_link 'Bulk change'
|
||||
click_link 'Nameserver'
|
||||
|
||||
fill_in 'Old hostname', with: 'old hostname'
|
||||
fill_in 'New hostname', with: 'new hostname'
|
47
test/integration/registrar/bulk_change/tech_contact_test.rb
Normal file
47
test/integration/registrar/bulk_change/tech_contact_test.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAreaTechContactBulkChangeTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
login_as 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: { 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'
|
||||
|
||||
fill_in 'Current contact ID', with: 'william-001'
|
||||
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: { error: { message: 'epic fail' } }.to_json,
|
||||
headers: { 'Content-type' => 'application/json' })
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
||||
fill_in 'Current contact ID', with: 'william-001'
|
||||
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
|
|
@ -9,7 +9,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest
|
|||
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,any,2010-07-05
|
||||
invalid.test,1438d6,any,invalid,2010-07-05
|
||||
airport.test,55438j5,John,john-001,2010-07-05
|
||||
CSV
|
||||
|
||||
|
|
28
test/integration/registrar/invoices/list_test.rb
Normal file
28
test/integration/registrar/invoices/list_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ListInvoicesTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
@registrar_invoices = @user.registrar.invoices
|
||||
login_as @user
|
||||
end
|
||||
|
||||
def test_show_balance
|
||||
visit registrar_invoices_path
|
||||
assert_text "Your current account balance is 100,00 EUR"
|
||||
end
|
||||
|
||||
def test_show_multiple_invoices
|
||||
@invoices = invoices
|
||||
@registrar_invoices = []
|
||||
@invoices.each do |invoice|
|
||||
@registrar_invoices << invoice
|
||||
end
|
||||
|
||||
visit registrar_invoices_path
|
||||
assert_text "Unpaid", count: 5
|
||||
assert_text "Invoice no.", count: 7
|
||||
end
|
||||
end
|
|
@ -0,0 +1,40 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewInvoicePaymentTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
login_as @user
|
||||
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
|
||||
|
||||
def test_create_new_SEB_payment
|
||||
create_invoice_and_visit_its_page
|
||||
click_link_or_button 'Seb'
|
||||
form = page.find('form')
|
||||
assert_equal('https://www.seb.ee/cgi-bin/dv.sh/ipank.r', form['action'])
|
||||
assert_equal('post', form['method'])
|
||||
assert_equal('240.00', form.find_by_id('VK_AMOUNT', visible: false).value)
|
||||
end
|
||||
|
||||
def test_create_new_Every_Pay_payment
|
||||
create_invoice_and_visit_its_page
|
||||
click_link_or_button 'Every pay'
|
||||
expected_hmac_fields = 'account_id,amount,api_username,callback_url,' +
|
||||
'customer_url,hmac_fields,nonce,order_reference,timestamp,transaction_type'
|
||||
|
||||
form = page.find('form')
|
||||
assert_equal('https://igw-demo.every-pay.com/transactions/', form['action'])
|
||||
assert_equal('post', form['method'])
|
||||
assert_equal(expected_hmac_fields, form.find_by_id('hmac_fields', visible: false).value)
|
||||
assert_equal('240.00', form.find_by_id('amount', visible: false).value)
|
||||
end
|
||||
end
|
48
test/integration/registrar/invoices/new_test.rb
Normal file
48
test/integration/registrar/invoices/new_test.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewInvoiceTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
login_as @user
|
||||
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
|
||||
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. 131050'
|
||||
assert_text 'Subtotal 200,00 €'
|
||||
assert_text 'Pay invoice'
|
||||
end
|
||||
|
||||
# This test case should fail once issue #651 gets fixed
|
||||
def test_create_new_invoice_with_amount_0_goes_through
|
||||
visit registrar_invoices_path
|
||||
click_link_or_button 'Add deposit'
|
||||
fill_in 'Amount', with: '0.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. 131050'
|
||||
assert_text 'Subtotal 0,00 €'
|
||||
assert_text 'Pay invoice'
|
||||
end
|
||||
end
|
49
test/integration/registrar/invoices/payment_callback_test.rb
Normal file
49
test/integration/registrar/invoices/payment_callback_test.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
require 'test_helper'
|
||||
|
||||
class PaymentCallbackTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
login_as @user
|
||||
end
|
||||
|
||||
def create_invoice_with_items
|
||||
@invoice = invoices(:for_payments_test)
|
||||
invoice_item = invoice_items(:one)
|
||||
|
||||
@invoice.invoice_items << invoice_item
|
||||
@invoice.invoice_items << invoice_item
|
||||
@user.registrar.invoices << @invoice
|
||||
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 test_every_pay_callback_returns_status_200
|
||||
create_invoice_with_items
|
||||
request_params = every_pay_request_params.merge(invoice_id: @invoice.id)
|
||||
post "/registrar/pay/callback/every_pay", request_params
|
||||
assert_equal(200, response.status)
|
||||
end
|
||||
end
|
100
test/integration/registrar/invoices/payment_return_test.rb
Normal file
100
test/integration/registrar/invoices/payment_return_test.rb
Normal file
|
@ -0,0 +1,100 @@
|
|||
require 'test_helper'
|
||||
|
||||
class PaymentReturnTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
login_as @user
|
||||
end
|
||||
|
||||
def create_invoice_with_items
|
||||
@invoice = invoices(:for_payments_test)
|
||||
invoice_item = invoice_items(:one)
|
||||
|
||||
@invoice.invoice_items << invoice_item
|
||||
@invoice.invoice_items << invoice_item
|
||||
@user.registrar.invoices << @invoice
|
||||
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_every_pay_return_creates_activity_redirects_to_invoice_path
|
||||
create_invoice_with_items
|
||||
request_params = every_pay_request_params.merge(invoice_id: @invoice.id)
|
||||
|
||||
post "/registrar/pay/return/every_pay", request_params
|
||||
assert_equal(302, response.status)
|
||||
assert_redirected_to(registrar_invoice_path(@invoice))
|
||||
end
|
||||
|
||||
def test_Every_Pay_return_raises_RecordNotFound
|
||||
create_invoice_with_items
|
||||
request_params = every_pay_request_params.merge(invoice_id: "178907")
|
||||
assert_raises(ActiveRecord::RecordNotFound) do
|
||||
post "/registrar/pay/return/every_pay", request_params
|
||||
end
|
||||
end
|
||||
|
||||
def test_bank_link_return_redirects_to_invoice_paths
|
||||
create_invoice_with_items
|
||||
request_params = bank_link_request_params.merge(invoice_id: @invoice.id)
|
||||
|
||||
post "/registrar/pay/return/seb", request_params
|
||||
assert_equal(302, response.status)
|
||||
assert_redirected_to(registrar_invoice_path(@invoice))
|
||||
end
|
||||
|
||||
def test_bank_link_return
|
||||
create_invoice_with_items
|
||||
request_params = bank_link_request_params.merge(invoice_id: "178907")
|
||||
assert_raises(ActiveRecord::RecordNotFound) do
|
||||
post "/registrar/pay/return/seb", request_params
|
||||
end
|
||||
end
|
||||
end
|
|
@ -20,7 +20,7 @@ class DomainTransferTest < ActiveSupport::TestCase
|
|||
|
||||
body = 'Transfer of domain shop.test has been approved.' \
|
||||
' It was associated with registrant john-001' \
|
||||
' and contacts jane-001, william-001.'
|
||||
' and contacts acme-ltd-001, jane-001, william-001.'
|
||||
id = @domain_transfer.id
|
||||
class_name = @domain_transfer.class.name
|
||||
|
||||
|
|
|
@ -50,9 +50,11 @@ class NameserverTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_hostnames
|
||||
assert_equal %w[ns1.bestnames.test
|
||||
assert_equal %w[
|
||||
ns1.bestnames.test
|
||||
ns2.bestnames.test
|
||||
ns1.bestnames.test
|
||||
ns2.bestnames.test
|
||||
ns1.bestnames.test], Nameserver.hostnames
|
||||
end
|
||||
|
||||
|
|
134
test/models/payment_orders/bank_link_test.rb
Normal file
134
test/models/payment_orders/bank_link_test.rb
Normal file
|
@ -0,0 +1,134 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BankLinkTest < ActiveSupport::TestCase
|
||||
# Note: Files stored in: test/fixtures/files/seb_seller_key.pem
|
||||
# test/fixtures/files/seb_bank_cert.pem
|
||||
# are autogenerated, they will not work against production or even staging.
|
||||
def setup
|
||||
super
|
||||
|
||||
@invoice = invoices(:for_payments_test)
|
||||
invoice_item = invoice_items(:one)
|
||||
|
||||
@invoice.invoice_items << invoice_item
|
||||
@invoice.invoice_items << invoice_item
|
||||
|
||||
travel_to '2018-04-01 00:30 +0300'
|
||||
create_new_bank_link
|
||||
create_completed_bank_link
|
||||
create_cancelled_bank_link
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
travel_back
|
||||
end
|
||||
|
||||
def create_completed_bank_link
|
||||
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'
|
||||
}.with_indifferent_access
|
||||
|
||||
@completed_bank_link = PaymentOrders::BankLink.new(
|
||||
'seb', @invoice, { response: params }
|
||||
)
|
||||
end
|
||||
|
||||
def create_cancelled_bank_link
|
||||
params = {
|
||||
'VK_SERVICE': '1911',
|
||||
'VK_VERSION': '008',
|
||||
'VK_SND_ID': 'testvpos',
|
||||
'VK_REC_ID': 'seb',
|
||||
'VK_STAMP': 1,
|
||||
'VK_REF': '',
|
||||
'VK_MSG': 'Order nr 1',
|
||||
'VK_MAC': 'PElE2mYXXN50q2UBvTuYU1rN0BmOQcbafPummDnWfNdm9qbaGQkGyOn0XaaFGlrdEcldXaHBbZKUS0HegIgjdDfl2NOk+wkLNNH0Iu38KzZaxHoW9ga7vqiyKHC8dcxkHiO9HsOnz77Sy/KpWCq6cz48bi3fcMgo+MUzBMauWoQ=',
|
||||
'VK_ENCODING': 'UTF-8',
|
||||
'VK_LANG': 'ENG'
|
||||
}.with_indifferent_access
|
||||
|
||||
@cancelled_bank_link = PaymentOrders::BankLink.new(
|
||||
'seb', @invoice, { response: params }
|
||||
)
|
||||
end
|
||||
|
||||
def create_new_bank_link
|
||||
params = { return_url: 'return.url', response_url: 'response.url' }
|
||||
@new_bank_link = PaymentOrders::BankLink.new('seb', @invoice, params)
|
||||
end
|
||||
|
||||
def test_response_is_not_valid_when_it_is_missing
|
||||
refute(false, @new_bank_link.valid_response_from_intermediary?)
|
||||
end
|
||||
|
||||
def test_form_fields
|
||||
expected_response = {
|
||||
'VK_SERVICE': '1012',
|
||||
'VK_VERSION': '008',
|
||||
'VK_SND_ID': 'testvpos',
|
||||
'VK_STAMP': 1,
|
||||
'VK_AMOUNT': '12.00',
|
||||
'VK_CURR': 'EUR',
|
||||
'VK_REF': '',
|
||||
'VK_MSG': 'Order nr. 1',
|
||||
'VK_RETURN': 'return.url',
|
||||
'VK_CANCEL': 'return.url',
|
||||
'VK_DATETIME': '2018-04-01T00:30:00+0300',
|
||||
'VK_MAC': 'q70UNFV4ih1qYij2+CyrHaApc3OE66igy3ijuR1m9dl0Cg+lIrAUsP47JChAF7PRErwZ78vSuZwrg0Vabhlp3WoC934ik2FiE04BBxUUTndONvguaNR1wvl0FiwfXFljLncX7TOmRraywJljKC5vTnIRNT2+1HXvmv0v576PGao=',
|
||||
'VK_ENCODING': 'UTF-8',
|
||||
'VK_LANG': 'ENG'
|
||||
}.with_indifferent_access
|
||||
|
||||
assert_equal(expected_response, @new_bank_link.form_fields)
|
||||
end
|
||||
|
||||
def test_valid_success_response_from_intermediary?
|
||||
assert(@completed_bank_link.valid_response_from_intermediary?)
|
||||
end
|
||||
|
||||
def test_valid_cancellation_response_from_intermediary?
|
||||
assert(@cancelled_bank_link.valid_response_from_intermediary?)
|
||||
end
|
||||
|
||||
def test_settled_payment?
|
||||
assert(@completed_bank_link.settled_payment?)
|
||||
refute(@cancelled_bank_link.settled_payment?)
|
||||
end
|
||||
|
||||
def test_complete_transaction_calls_methods_on_transaction
|
||||
mock_transaction = MiniTest::Mock.new
|
||||
mock_transaction.expect(:sum= , '12.00', ['12.00'])
|
||||
mock_transaction.expect(:bank_reference= , '1', ['1'])
|
||||
mock_transaction.expect(:buyer_bank_code= , 'testvpos', ['testvpos'])
|
||||
mock_transaction.expect(:buyer_iban= , '1234', ['1234'])
|
||||
mock_transaction.expect(:paid_at= , Date.parse('2018-04-01 00:30:00 +0300'), [Time.parse('2018-04-01T00:30:00+0300')])
|
||||
mock_transaction.expect(:buyer_name=, 'John Doe', ['John Doe'])
|
||||
mock_transaction.expect(:save!, true)
|
||||
mock_transaction.expect(:autobind_invoice, AccountActivity.new)
|
||||
|
||||
BankTransaction.stub(:find_by, mock_transaction) do
|
||||
@completed_bank_link.complete_transaction
|
||||
end
|
||||
|
||||
mock_transaction.verify
|
||||
end
|
||||
end
|
92
test/models/payment_orders/every_pay_test.rb
Normal file
92
test/models/payment_orders/every_pay_test.rb
Normal file
|
@ -0,0 +1,92 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EveryPayTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@invoice = invoices(:for_payments_test)
|
||||
invoice_item = invoice_items(:one)
|
||||
|
||||
@invoice.invoice_items << invoice_item
|
||||
@invoice.invoice_items << invoice_item
|
||||
|
||||
params = {
|
||||
response:
|
||||
{
|
||||
utf8: '✓',
|
||||
_method: 'put',
|
||||
authenticity_token: 'OnA69vbccQtMt3C9wxEWigs5Gpf/7z+NoxRCMkFPlTvaATs8+OgMKF1I4B2f+vuK37zCgpWZaWWtyuslRRSwkw==',
|
||||
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: '1',
|
||||
},
|
||||
}
|
||||
@every_pay = PaymentOrders::EveryPay.new('every_pay', @invoice, params)
|
||||
@other_pay = PaymentOrders::EveryPay.new('every_pay', @invoice, {})
|
||||
|
||||
travel_to Time.zone.parse('2018-04-01 00:30:00 +0000')
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
travel_back
|
||||
end
|
||||
|
||||
def test_form_fields
|
||||
expected_fields = {
|
||||
api_username: 'api_user',
|
||||
account_id: 'EUR3D1',
|
||||
timestamp: '1522542600',
|
||||
amount: '12.00',
|
||||
transaction_type: 'charge',
|
||||
hmac_fields: 'account_id,amount,api_username,callback_url,customer_url,hmac_fields,nonce,order_reference,timestamp,transaction_type'
|
||||
}
|
||||
form_fields = @every_pay.form_fields
|
||||
expected_fields.each do |k, v|
|
||||
assert_equal(v, form_fields[k])
|
||||
end
|
||||
end
|
||||
|
||||
def test_valid_response_from_intermediary?
|
||||
assert(@every_pay.valid_response_from_intermediary?)
|
||||
refute(@other_pay.valid_response_from_intermediary?)
|
||||
end
|
||||
|
||||
def test_settled_payment?
|
||||
assert(@every_pay.settled_payment?)
|
||||
other_pay = PaymentOrders::EveryPay.new(
|
||||
'every_pay', @invoice, {response: {payment_state: 'CANCELLED'}}
|
||||
)
|
||||
refute(other_pay.settled_payment?)
|
||||
end
|
||||
|
||||
def test_complete_transaction_calls_methods_on_transaction
|
||||
mock_transaction = MiniTest::Mock.new
|
||||
mock_transaction.expect(:sum= , '12.00', ['12.00'])
|
||||
mock_transaction.expect(:paid_at= , Date.strptime('1524136727', '%s'), [Date.strptime('1524136727', '%s')])
|
||||
mock_transaction.expect(:buyer_name=, 'John Doe', ['John Doe'])
|
||||
mock_transaction.expect(:save!, true)
|
||||
mock_transaction.expect(:autobind_invoice, AccountActivity.new)
|
||||
|
||||
BankTransaction.stub(:find_by, mock_transaction) do
|
||||
@every_pay.complete_transaction
|
||||
end
|
||||
|
||||
mock_transaction.verify
|
||||
end
|
||||
end
|
58
test/models/payment_orders_test.rb
Normal file
58
test/models/payment_orders_test.rb
Normal file
|
@ -0,0 +1,58 @@
|
|||
require 'test_helper'
|
||||
|
||||
class PaymentOrdersTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@original_methods = ENV['payment_methods']
|
||||
@original_seb_URL = ENV['seb_payment_url']
|
||||
ENV['payment_methods'] = 'seb, swed, credit_card'
|
||||
ENV['seb_payment_url'] = nil
|
||||
@not_implemented_payment = PaymentOrders::Base.new(
|
||||
'not_implemented', Invoice.new
|
||||
)
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
ENV['payment_methods'] = @original_methods
|
||||
ENV['seb_payment_url'] = @original_seb_URL
|
||||
end
|
||||
|
||||
def test_variable_assignment
|
||||
assert_equal 'not_implemented', @not_implemented_payment.type
|
||||
assert_nil @not_implemented_payment.response_url
|
||||
assert_nil @not_implemented_payment.return_url
|
||||
assert_nil @not_implemented_payment.form_url
|
||||
end
|
||||
|
||||
def test_that_errors_are_raised_on_missing_methods
|
||||
assert_raise NoMethodError do
|
||||
@not_implemented_payment.valid_response?
|
||||
end
|
||||
|
||||
assert_raise NoMethodError do
|
||||
@not_implemented_payment.settled_payment?
|
||||
end
|
||||
|
||||
assert_raise NoMethodError do
|
||||
@not_implemented_payment.form_fields
|
||||
end
|
||||
|
||||
assert_raise NoMethodError do
|
||||
@not_implemented_payment.complete_transaction
|
||||
end
|
||||
end
|
||||
|
||||
def test_that_create_with_type_raises_argument_error
|
||||
assert_raise ArgumentError do
|
||||
PaymentOrders.create_with_type("not_implemented", Invoice.new)
|
||||
end
|
||||
end
|
||||
|
||||
def test_create_with_correct_subclass
|
||||
payment = PaymentOrders.create_with_type('seb', Invoice.new)
|
||||
assert_equal PaymentOrders::BankLink, payment.class
|
||||
end
|
||||
end
|
|
@ -10,7 +10,11 @@ class RegistryTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_vat_rate
|
||||
original_vat_prc = Setting.registry_vat_prc
|
||||
Setting.registry_vat_prc = 0.25
|
||||
|
||||
assert_equal BigDecimal(25), @registry.vat_rate
|
||||
|
||||
Setting.registry_vat_prc = original_vat_prc
|
||||
end
|
||||
end
|
||||
|
|
60
test/models/whois_record_test.rb
Normal file
60
test/models/whois_record_test.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
require 'test_helper'
|
||||
|
||||
class WhoisRecordTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:shop)
|
||||
@record = WhoisRecord.new(domain: @domain)
|
||||
@record.populate
|
||||
end
|
||||
|
||||
def test_generated_json_has_expected_values
|
||||
expected_disclaimer_text = <<-TEXT.squish
|
||||
Search results may not be used for commercial, advertising, recompilation,
|
||||
repackaging, redistribution, reuse, obscuring or other similar activities.
|
||||
TEXT
|
||||
|
||||
expected_partial_hash = {
|
||||
disclaimer: expected_disclaimer_text,
|
||||
name: 'shop.test',
|
||||
registrant: 'John',
|
||||
registrant_kind: 'priv',
|
||||
email: 'john@inbox.test',
|
||||
expire: '2010-07-05',
|
||||
nameservers: ['ns1.bestnames.test', 'ns2.bestnames.test'],
|
||||
registrar_address: 'Main Street, New York, New York, 12345',
|
||||
dnssec_keys: [],
|
||||
}
|
||||
|
||||
expected_partial_hash.each do |key, value|
|
||||
assert_equal(value, @record.generated_json[key])
|
||||
end
|
||||
end
|
||||
|
||||
def test_generated_body_has_justified_disclaimer
|
||||
expected_disclaimer = begin
|
||||
'Search results may not be used for commercial, advertising, recompilation,\n' \
|
||||
'repackaging, redistribution, reuse, obscuring or other similar activities.'
|
||||
end
|
||||
expected_technical_contact = begin
|
||||
'Technical contact:\n' \
|
||||
'name: Not Disclosed\n' \
|
||||
'email: Not Disclosed - Visit www.internet.ee for webbased WHOIS\n' \
|
||||
'changed: Not Disclosed'
|
||||
end
|
||||
|
||||
regexp_contact = Regexp.new(expected_technical_contact, Regexp::MULTILINE)
|
||||
regexp_disclaimer = Regexp.new(expected_disclaimer, Regexp::MULTILINE)
|
||||
|
||||
assert_match(regexp_disclaimer, @record.body)
|
||||
assert_match(regexp_contact, @record.body)
|
||||
end
|
||||
|
||||
def test_whois_record_has_no_disclaimer_if_Setting_is_blank
|
||||
Setting.stubs(:registry_whois_disclaimer, '') do
|
||||
refute(@record.json['disclaimer'])
|
||||
refute_match(/Search results may not be used for commercial/, @record.body)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue