mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Merge branch 'master' into registry-790
# Conflicts: # test/integration/epp/domain/domain_delete_test.rb # test/integration/epp/domain/domain_update_test.rb # test/integration/epp/domain/transfer/request_test.rb # test/system/admin_area/domains_test.rb
This commit is contained in:
commit
1d79f6548d
61 changed files with 731 additions and 84 deletions
|
@ -3,7 +3,7 @@ require 'test_helper'
|
|||
require 'database_cleaner'
|
||||
require 'selenium/webdriver'
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::IntegrationTest; end
|
||||
ApplicationSystemTestCase = Class.new(ApplicationIntegrationTest)
|
||||
|
||||
class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
|
||||
self.use_transactional_fixtures = false
|
||||
|
|
12
test/fixtures/domains.yml
vendored
12
test/fixtures/domains.yml
vendored
|
@ -42,10 +42,20 @@ metro:
|
|||
period_unit: m
|
||||
uuid: ef97cb80-333b-4893-b9df-163f2b452798
|
||||
|
||||
hospital:
|
||||
name: hospital.test
|
||||
registrar: goodnames
|
||||
registrant: john
|
||||
transfer_code: 23118v2
|
||||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
uuid: 5edda1a5-3548-41ee-8b65-6d60daf85a37
|
||||
|
||||
invalid:
|
||||
name: invalid.test
|
||||
transfer_code: 1438d6
|
||||
valid_to: <%= Time.zone.parse('2010-07-05').utc.to_s(:db) %>
|
||||
registrar: bestnames
|
||||
registrant: invalid
|
||||
uuid: 3c430ead-bb17-4b5b-aaa1-caa7dde7e138
|
||||
uuid: 3c430ead-bb17-4b5b-aaa1-caa7dde7e138
|
||||
|
|
1
test/fixtures/users.yml
vendored
1
test/fixtures/users.yml
vendored
|
@ -26,3 +26,4 @@ admin:
|
|||
registrant:
|
||||
type: RegistrantUser
|
||||
registrant_ident: US-1234
|
||||
username: Registrant User
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class APIDomainContactsTest < ActionDispatch::IntegrationTest
|
||||
class APIDomainContactsTest < ApplicationIntegrationTest
|
||||
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' },
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||
class APIDomainTransfersTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@new_registrar = registrars(:goodnames)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class APINameserversPutTest < ActionDispatch::IntegrationTest
|
||||
class APINameserversPutTest < ApplicationIntegrationTest
|
||||
def test_replaces_registrar_nameservers
|
||||
old_nameserver_ids = [nameservers(:shop_ns1).id,
|
||||
nameservers(:airport_ns1).id,
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@user_hash = { ident: '37010100049', first_name: 'Adam', last_name: 'Baker' }
|
||||
@existing_user = RegistrantUser.find_or_create_by_api_data(@user_hash)
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
end
|
||||
|
||||
def test_request_creates_user_when_one_does_not_exist
|
||||
params = {
|
||||
ident: '30110100103',
|
||||
first_name: 'John',
|
||||
last_name: 'Smith',
|
||||
}
|
||||
|
||||
post '/api/v1/registrant/auth/eid', params
|
||||
assert(User.find_by(registrant_ident: 'EE-30110100103'))
|
||||
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal([:access_token, :expires_at, :type], json.keys)
|
||||
end
|
||||
|
||||
def test_request_returns_existing_user
|
||||
assert_no_changes User.count do
|
||||
post '/api/v1/registrant/auth/eid', @user_hash
|
||||
end
|
||||
end
|
||||
|
||||
def test_request_returns_401_from_a_not_whitelisted_ip
|
||||
params = { foo: :bar, test: :test }
|
||||
@original_whitelist_ip = ENV['registrant_api_auth_allowed_ips']
|
||||
ENV['registrant_api_auth_allowed_ips'] = '1.2.3.4'
|
||||
|
||||
post '/api/v1/registrant/auth/eid', params
|
||||
assert_equal(401, response.status)
|
||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||
|
||||
ENV['registrant_api_auth_allowed_ips'] = @original_whitelist_ip
|
||||
end
|
||||
|
||||
def test_request_documented_parameters_are_required
|
||||
params = { foo: :bar, test: :test }
|
||||
|
||||
post '/api/v1/registrant/auth/eid', params
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal({ errors: [{ ident: ['parameter is required'] }] }, json)
|
||||
assert_equal(422, response.status)
|
||||
end
|
||||
end
|
102
test/integration/api/registrant/registrant_api_domains_test.rb
Normal file
102
test/integration/api/registrant/registrant_api_domains_test.rb
Normal file
|
@ -0,0 +1,102 @@
|
|||
require 'test_helper'
|
||||
require 'auth_token/auth_token_creator'
|
||||
|
||||
class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@original_registry_time = Setting.days_to_keep_business_registry_cache
|
||||
Setting.days_to_keep_business_registry_cache = 1
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
@domain = domains(:hospital)
|
||||
@registrant = @domain.registrant
|
||||
@user = users(:registrant)
|
||||
@auth_headers = { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
Setting.days_to_keep_business_registry_cache = @original_registry_time
|
||||
travel_back
|
||||
end
|
||||
|
||||
def test_get_domain_details_by_uuid
|
||||
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37', {}, @auth_headers
|
||||
assert_equal(200, response.status)
|
||||
|
||||
domain = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal('hospital.test', domain[:name])
|
||||
end
|
||||
|
||||
def test_get_non_existent_domain_details_by_uuid
|
||||
get '/api/v1/registrant/domains/random-uuid', {}, @auth_headers
|
||||
assert_equal(404, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal({ errors: [base: ['Domain not found']] }, response_json)
|
||||
end
|
||||
|
||||
def test_root_returns_domain_list
|
||||
get '/api/v1/registrant/domains', {}, @auth_headers
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
array_of_domain_names = response_json.map { |x| x[:name] }
|
||||
assert(array_of_domain_names.include?('hospital.test'))
|
||||
end
|
||||
|
||||
def test_root_accepts_limit_and_offset_parameters
|
||||
get '/api/v1/registrant/domains', { 'limit' => 2, 'offset' => 0 }, @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal(200, response.status)
|
||||
assert_equal(2, response_json.count)
|
||||
|
||||
get '/api/v1/registrant/domains', {}, @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal(5, response_json.count)
|
||||
end
|
||||
|
||||
def test_root_does_not_accept_limit_higher_than_200
|
||||
get '/api/v1/registrant/domains', { 'limit' => 400, 'offset' => 0 }, @auth_headers
|
||||
|
||||
assert_equal(400, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal({ errors: [{ limit: ['parameter is out of range'] }] }, response_json)
|
||||
end
|
||||
|
||||
def test_root_does_not_accept_offset_lower_than_0
|
||||
get '/api/v1/registrant/domains', { 'limit' => 200, 'offset' => "-10" }, @auth_headers
|
||||
|
||||
assert_equal(400, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal({ errors: [{ offset: ['parameter is out of range'] }] }, response_json)
|
||||
end
|
||||
|
||||
def test_root_returns_401_without_authorization
|
||||
get '/api/v1/registrant/domains', {}, {}
|
||||
assert_equal(401, response.status)
|
||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||
end
|
||||
|
||||
def test_details_returns_401_without_authorization
|
||||
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37', {}, {}
|
||||
assert_equal(401, response.status)
|
||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def auth_token
|
||||
token_creator = AuthTokenCreator.create_with_defaults(@user)
|
||||
hash = token_creator.token_in_hash
|
||||
"Bearer #{hash[:access_token]}"
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCreateNameserversTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainCreateNameserversTest < ApplicationIntegrationTest
|
||||
# Glue record requirement
|
||||
def test_nameserver_ip_address_is_required_if_hostname_is_under_the_same_domain
|
||||
request_xml = <<-XML
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCreateTransferCodeTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainCreateTransferCodeTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainDeleteTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainDeleteTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainRenewTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainRenewTest < ApplicationIntegrationTest
|
||||
self.use_transactional_fixtures = false
|
||||
|
||||
setup do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainUpdateTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainUpdateTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferBaseTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainTransferBaseTest < ApplicationIntegrationTest
|
||||
def test_non_existent_domain
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferQueryTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainTransferQueryTest < ApplicationIntegrationTest
|
||||
def test_returns_domain_transfer_details
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
@new_registrar = registrars(:goodnames)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLoginCredentialsTest < ActionDispatch::IntegrationTest
|
||||
class EppLoginCredentialsTest < ApplicationIntegrationTest
|
||||
def test_correct_credentials
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLoginSessionLimitTest < ActionDispatch::IntegrationTest
|
||||
class EppLoginSessionLimitTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
EppSession.delete_all
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLogoutTest < ActionDispatch::IntegrationTest
|
||||
class EppLogoutTest < ApplicationIntegrationTest
|
||||
def test_success_response
|
||||
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="1500"]')
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppPollTest < ActionDispatch::IntegrationTest
|
||||
class EppPollTest < ApplicationIntegrationTest
|
||||
def test_messages
|
||||
post '/epp/command/poll', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '1301', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
|
|
53
test/lib/auth_token/auth_token_creator_test.rb
Normal file
53
test/lib/auth_token/auth_token_creator_test.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
require 'test_helper'
|
||||
require 'openssl'
|
||||
require_relative '../../../lib/auth_token/auth_token_creator'
|
||||
|
||||
class AuthTokenCreatorTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@user = users(:registrant)
|
||||
time = Time.zone.parse('2010-07-05 00:30:00 +0000')
|
||||
@random_bytes = SecureRandom.random_bytes(64)
|
||||
@token_creator = AuthTokenCreator.new(@user, @random_bytes, time)
|
||||
end
|
||||
|
||||
def test_hashable_is_constructed_as_expected
|
||||
expected_hashable = { user_ident: 'US-1234', user_username: 'Registrant User',
|
||||
expires_at: '2010-07-05 00:30:00 UTC' }.to_json
|
||||
|
||||
assert_equal(expected_hashable, @token_creator.hashable)
|
||||
end
|
||||
|
||||
def test_encrypted_token_is_decryptable
|
||||
encryptor = OpenSSL::Cipher::AES.new(256, :CBC)
|
||||
encryptor.decrypt
|
||||
encryptor.key = @random_bytes
|
||||
|
||||
base64_decoded = Base64.urlsafe_decode64(@token_creator.encrypted_token)
|
||||
result = encryptor.update(base64_decoded) + encryptor.final
|
||||
|
||||
hashable = { user_ident: 'US-1234', user_username: 'Registrant User',
|
||||
expires_at: '2010-07-05 00:30:00 UTC' }.to_json
|
||||
|
||||
assert_equal(hashable, result)
|
||||
end
|
||||
|
||||
def test_token_in_json_returns_expected_values
|
||||
@token_creator.stub(:encrypted_token, 'super_secure_token') do
|
||||
token = @token_creator.token_in_hash
|
||||
assert_equal('2010-07-05 00:30:00 UTC', token[:expires_at])
|
||||
assert_equal('Bearer', token[:type])
|
||||
end
|
||||
end
|
||||
|
||||
def test_create_with_defaults_injects_values
|
||||
travel_to Time.zone.parse('2010-07-05 00:30:00 +0000')
|
||||
|
||||
token_creator_with_defaults = AuthTokenCreator.create_with_defaults(@user)
|
||||
assert_equal(Rails.application.config.secret_key_base, token_creator_with_defaults.key)
|
||||
assert_equal('2010-07-05 02:30:00 UTC', token_creator_with_defaults.expires_at)
|
||||
|
||||
travel_back
|
||||
end
|
||||
end
|
82
test/lib/auth_token/auth_token_decryptor_test.rb
Normal file
82
test/lib/auth_token/auth_token_decryptor_test.rb
Normal file
|
@ -0,0 +1,82 @@
|
|||
require 'test_helper'
|
||||
require_relative '../../../lib/auth_token/auth_token_decryptor'
|
||||
require_relative '../../../lib/auth_token/auth_token_creator'
|
||||
|
||||
class AuthTokenDecryptorTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
travel_to Time.parse("2010-07-05 00:15:00 UTC")
|
||||
@user = users(:registrant)
|
||||
|
||||
# For testing purposes, the token needs to be random and long enough, hence:
|
||||
@key = "b8+PtSq1+iXzUVnGEqciKsITNR0KmLl7uPiSTHbteqCoEBdbMLUl3GXlIDWD\nDZp1hIgKWnIMPNEgbuCa/7qccA==\n"
|
||||
@faulty_key = "FALSE+iXzUVnGEqciKsITNR0KmLl7uPiSTHbteqCoEBdbMLUl3GXlIDWD\nDZp1hIgKWnIMPNEgbuCa/7qccA==\n"
|
||||
|
||||
# this token corresponds to:
|
||||
# {:user_ident=>"US-1234", :user_username=>"Registrant User", :expires_at=>"2010-07-05 02:15:00 UTC"}
|
||||
@access_token = "q27NWIsKD5snWj9vZzJ0RcOYvgocEyu7H9yCaDjfmGi54sogovpBeALMPWTZHMcdFQzSiq6b4cI0p5tO0_5UEOHic2jRzNW7mkhi-bn-Y2Wlnw7jhMpxw6VwJR8QEoDzjkcNxnKBN6OKF4nssa60ZQ=="
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
travel_back
|
||||
end
|
||||
|
||||
def test_decrypt_token_returns_a_hash_when_token_is_valid
|
||||
decryptor = AuthTokenDecryptor.new(@access_token, @key)
|
||||
|
||||
assert(decryptor.decrypt_token.is_a?(Hash))
|
||||
end
|
||||
|
||||
def test_decrypt_token_return_false_when_token_is_invalid
|
||||
faulty_decryptor = AuthTokenDecryptor.new(@access_token, @faulty_key)
|
||||
refute(faulty_decryptor.decrypt_token)
|
||||
end
|
||||
|
||||
def test_decrypt_token_return_false_when_token_is_nil
|
||||
faulty_decryptor = AuthTokenDecryptor.new(nil, @key)
|
||||
refute(faulty_decryptor.decrypt_token)
|
||||
end
|
||||
|
||||
def test_valid_returns_true_for_valid_token
|
||||
decryptor = AuthTokenDecryptor.new(@access_token, @key)
|
||||
decryptor.decrypt_token
|
||||
|
||||
assert(decryptor.valid?)
|
||||
end
|
||||
|
||||
def test_valid_returns_false_for_invalid_token
|
||||
faulty_decryptor = AuthTokenDecryptor.new(@access_token, @faulty_key)
|
||||
faulty_decryptor.decrypt_token
|
||||
|
||||
refute(faulty_decryptor.valid?)
|
||||
end
|
||||
|
||||
def test_valid_returns_false_for_expired_token
|
||||
travel_to Time.parse("2010-07-05 10:15:00 UTC")
|
||||
|
||||
decryptor = AuthTokenDecryptor.new(@access_token, @key)
|
||||
decryptor.decrypt_token
|
||||
|
||||
refute(decryptor.valid?)
|
||||
end
|
||||
|
||||
def test_returns_false_for_non_existing_user
|
||||
# This token was created from an admin user and @key. Decrypted, it corresponds to:
|
||||
# {:user_ident=>nil, :user_username=>"test", :expires_at=>"2010-07-05 00:15:00 UTC"}
|
||||
other_token = "rMkjgpyRcj2xOnHVwvvQ5RAS0yQepUSrw3XM5BrwM4TMH-h-TBeLve9InC_zaPneMMnCs0NHQHt1EpH95A2Yhdk6Ge6HQ-4gN5L0THDywCO2vHKGucPxbd6g6wOSaOnR"
|
||||
|
||||
decryptor = AuthTokenDecryptor.new(other_token, @key)
|
||||
decryptor.decrypt_token
|
||||
|
||||
refute(decryptor.valid?)
|
||||
end
|
||||
|
||||
def test_create_with_defaults_injects_values
|
||||
decryptor = AuthTokenDecryptor.create_with_defaults(@access_token)
|
||||
|
||||
assert_equal(Rails.application.config.secret_key_base, decryptor.key)
|
||||
end
|
||||
end
|
37
test/models/contact_test.rb
Normal file
37
test/models/contact_test.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContactTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@contact = contacts(:john)
|
||||
end
|
||||
|
||||
def test_valid_fixture
|
||||
assert @contact.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_email
|
||||
@contact.email = ''
|
||||
assert @contact.invalid?
|
||||
end
|
||||
|
||||
def test_email_format_validation
|
||||
@contact.email = 'invalid'
|
||||
assert @contact.invalid?
|
||||
|
||||
@contact.email = 'test@bestmail.test'
|
||||
assert @contact.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_phone
|
||||
@contact.email = ''
|
||||
assert @contact.invalid?
|
||||
end
|
||||
|
||||
def test_phone_format_validation
|
||||
@contact.phone = '+123.'
|
||||
assert @contact.invalid?
|
||||
|
||||
@contact.phone = '+123.4'
|
||||
assert @contact.valid?
|
||||
end
|
||||
end
|
62
test/models/registrant_user_test.rb
Normal file
62
test/models/registrant_user_test.rb
Normal file
|
@ -0,0 +1,62 @@
|
|||
class RegistrantUserTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
end
|
||||
|
||||
def test_find_or_create_by_api_data_creates_a_user
|
||||
user_data = {
|
||||
ident: '37710100070',
|
||||
first_name: 'JOHN',
|
||||
last_name: 'SMITH'
|
||||
}
|
||||
|
||||
RegistrantUser.find_or_create_by_api_data(user_data)
|
||||
|
||||
user = User.find_by(registrant_ident: 'EE-37710100070')
|
||||
assert_equal('JOHN SMITH', user.username)
|
||||
end
|
||||
|
||||
def test_find_or_create_by_api_data_creates_a_user_after_upcasing_input
|
||||
user_data = {
|
||||
ident: '37710100070',
|
||||
first_name: 'John',
|
||||
last_name: 'Smith'
|
||||
}
|
||||
|
||||
RegistrantUser.find_or_create_by_api_data(user_data)
|
||||
|
||||
user = User.find_by(registrant_ident: 'EE-37710100070')
|
||||
assert_equal('JOHN SMITH', user.username)
|
||||
end
|
||||
|
||||
def test_find_or_create_by_mid_data_creates_a_user
|
||||
user_data = OpenStruct.new(user_country: 'EE', user_id_code: '37710100070',
|
||||
user_givenname: 'JOHN', user_surname: 'SMITH')
|
||||
|
||||
RegistrantUser.find_or_create_by_mid_data(user_data)
|
||||
user = User.find_by(registrant_ident: 'EE-37710100070')
|
||||
assert_equal('JOHN SMITH', user.username)
|
||||
end
|
||||
|
||||
def test_find_or_create_by_idc_with_legacy_header_creates_a_user
|
||||
header = '/C=EE/O=ESTEID/OU=authentication/CN=SMITH,JOHN,37710100070/SN=SMITH/GN=JOHN/serialNumber=37710100070'
|
||||
|
||||
RegistrantUser.find_or_create_by_idc_data(header, RegistrantUser::ACCEPTED_ISSUER)
|
||||
|
||||
user = User.find_by(registrant_ident: 'EE-37710100070')
|
||||
assert_equal('JOHN SMITH', user.username)
|
||||
end
|
||||
|
||||
def test_find_or_create_by_idc_with_rfc2253_header_creates_a_user
|
||||
header = 'serialNumber=37710100070,GN=JOHN,SN=SMITH,CN=SMITH\\,JOHN\\,37710100070,OU=authentication,O=ESTEID,C=EE'
|
||||
|
||||
RegistrantUser.find_or_create_by_idc_data(header, RegistrantUser::ACCEPTED_ISSUER)
|
||||
|
||||
user = User.find_by(registrant_ident: 'EE-37710100070')
|
||||
assert_equal('JOHN SMITH', user.username)
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContactVersionsTest < ActionDispatch::IntegrationTest
|
||||
class ContactVersionsTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminContactsTest < ActionDispatch::IntegrationTest
|
||||
class AdminContactsTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainVersionsTest < ActionDispatch::IntegrationTest
|
||||
class DomainVersionsTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaDomainDetailsTest < ActionDispatch::IntegrationTest
|
||||
class AdminAreaDomainDetailsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
@domain = domains(:shop)
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest
|
||||
class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminDomainsTestTest < ActionDispatch::IntegrationTest
|
||||
class AdminDomainsTestTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
sign_in users(:admin)
|
||||
@domain = domains(:shop)
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaNewMailTemplateTest < ActionDispatch::IntegrationTest
|
||||
class AdminAreaNewMailTemplateTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaDeleteRegistrarTest < ActionDispatch::IntegrationTest
|
||||
class AdminAreaDeleteRegistrarTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaRegistrarDetailsTest < ActionDispatch::IntegrationTest
|
||||
class AdminAreaRegistrarDetailsTest < ApplicationSystemTestCase
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
setup do
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaEditRegistrarTest < ActionDispatch::IntegrationTest
|
||||
class AdminAreaEditRegistrarTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
@registrar = registrars(:bestnames)
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaNewRegistrarTest < ActionDispatch::IntegrationTest
|
||||
class AdminAreaNewRegistrarTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantDomainsTest < ActionDispatch::IntegrationTest
|
||||
class RegistrantDomainsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:registrant)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantLayoutTest < ActionDispatch::IntegrationTest
|
||||
class RegistrantLayoutTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
sign_in(users(:registrant))
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BalanceTopUpTest < ActionDispatch::IntegrationTest
|
||||
class BalanceTopUpTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAreaBulkTransferTest < ActionDispatch::IntegrationTest
|
||||
class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:api_goodnames)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest
|
||||
class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:api_goodnames)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAreaTechContactBulkChangeTest < ActionDispatch::IntegrationTest
|
||||
class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarDomainsTest < ActionDispatch::IntegrationTest
|
||||
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')
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ListInvoicesTest < ActionDispatch::IntegrationTest
|
||||
class ListInvoicesTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewInvoicePaymentTest < ActionDispatch::IntegrationTest
|
||||
class NewInvoicePaymentTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewInvoiceTest < ActionDispatch::IntegrationTest
|
||||
class NewInvoiceTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class PaymentCallbackTest < ActionDispatch::IntegrationTest
|
||||
class PaymentCallbackTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class PaymentReturnTest < ActionDispatch::IntegrationTest
|
||||
class PaymentReturnTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
|
|
@ -13,8 +13,6 @@ require 'capybara/minitest'
|
|||
require 'webmock/minitest'
|
||||
require 'support/rails5_assertions' # Remove once upgraded to Rails 5
|
||||
|
||||
require 'application_system_test_case'
|
||||
|
||||
Setting.address_processing = false
|
||||
Setting.registry_country_code = 'US'
|
||||
|
||||
|
@ -29,7 +27,7 @@ class ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
class ActionDispatch::IntegrationTest
|
||||
class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
|
||||
include Capybara::DSL
|
||||
include Capybara::Minitest::Assertions
|
||||
include AbstractController::Translation
|
||||
|
@ -41,3 +39,5 @@ class ActionDispatch::IntegrationTest
|
|||
Capybara.use_default_driver
|
||||
end
|
||||
end
|
||||
|
||||
require 'application_system_test_case'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue