mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
Merge branch 'master' into registry-790
This commit is contained in:
commit
e4305e7865
86 changed files with 1329 additions and 1163 deletions
42
test/application_system_test_case.rb
Normal file
42
test/application_system_test_case.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
require 'test_helper'
|
||||
|
||||
require 'database_cleaner'
|
||||
require 'selenium/webdriver'
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::IntegrationTest; end
|
||||
|
||||
class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
|
||||
self.use_transactional_fixtures = false
|
||||
DatabaseCleaner.strategy = :truncation
|
||||
|
||||
Capybara.register_driver(:chrome) do |_app|
|
||||
options = ::Selenium::WebDriver::Chrome::Options.new
|
||||
|
||||
options.add_argument('--headless')
|
||||
options.add_argument('--no-sandbox')
|
||||
options.add_argument('--disable-dev-shm-usage')
|
||||
options.add_argument('--window-size=1400,1400')
|
||||
|
||||
Capybara::Selenium::Driver.new(Rails.application, browser: :chrome, options: options)
|
||||
end
|
||||
|
||||
Capybara.register_server(:silent_puma) do |app, port, _host|
|
||||
require 'rack/handler/puma'
|
||||
Rack::Handler::Puma.run(app, Port: port, Threads: '0:2', Silent: true)
|
||||
end
|
||||
|
||||
def setup
|
||||
DatabaseCleaner.start
|
||||
|
||||
super
|
||||
|
||||
Capybara.current_driver = :chrome
|
||||
Capybara.server = :silent_puma
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
end
|
8
test/fixtures/contacts.yml
vendored
8
test/fixtures/contacts.yml
vendored
|
@ -8,6 +8,7 @@ john:
|
|||
registrar: bestnames
|
||||
code: john-001
|
||||
auth_info: cacb5b
|
||||
uuid: eb2f2766-b44c-4e14-9f16-32ab1a7cb957
|
||||
|
||||
william: &william
|
||||
name: William
|
||||
|
@ -27,6 +28,7 @@ william: &william
|
|||
country_code: US
|
||||
statuses:
|
||||
- ok
|
||||
uuid: 0aa54704-d6f7-4ca9-b8ca-2827d9a4e4eb
|
||||
|
||||
jane:
|
||||
name: Jane
|
||||
|
@ -38,6 +40,7 @@ jane:
|
|||
registrar: bestnames
|
||||
code: jane-001
|
||||
auth_info: 0aa09f
|
||||
uuid: 9db3de62-2414-4487-bee2-d5c155567768
|
||||
|
||||
acme_ltd:
|
||||
name: Acme Ltd
|
||||
|
@ -49,6 +52,7 @@ acme_ltd:
|
|||
ident_country_code: US
|
||||
code: acme-ltd-001
|
||||
auth_info: 720b3c
|
||||
uuid: f1dd365c-5be9-4b3d-a44e-3fa002465e4d
|
||||
|
||||
jack:
|
||||
name: Jack
|
||||
|
@ -60,12 +64,14 @@ jack:
|
|||
ident_country_code: US
|
||||
code: jack-001
|
||||
auth_info: e2c440
|
||||
uuid: 28b65455-6f1a-49fd-961c-0758886dbd75
|
||||
|
||||
identical_to_william:
|
||||
<<: *william
|
||||
registrar: goodnames
|
||||
code: william-002
|
||||
auth_info: 5ab865
|
||||
uuid: c0a191d5-3793-4f0b-8f85-491612d0293e
|
||||
|
||||
not_in_use:
|
||||
name: Useless
|
||||
|
@ -73,6 +79,7 @@ not_in_use:
|
|||
registrar: bestnames
|
||||
code: useless-001
|
||||
auth_info: e75a2a
|
||||
uuid: ca613cc5-a8dc-48c1-8d32-d3c6a0b6c952
|
||||
|
||||
invalid:
|
||||
name: any
|
||||
|
@ -80,3 +87,4 @@ invalid:
|
|||
email: invalid@invalid.test
|
||||
auth_info: any
|
||||
registrar: bestnames
|
||||
uuid: bd80c0f9-26ee-49e0-a2cb-2311d931c433
|
5
test/fixtures/domains.yml
vendored
5
test/fixtures/domains.yml
vendored
|
@ -7,6 +7,7 @@ shop:
|
|||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
uuid: 1b3ee442-e8fe-4922-9492-8fcb9dccc69c
|
||||
|
||||
airport:
|
||||
name: airport.test
|
||||
|
@ -17,6 +18,7 @@ airport:
|
|||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
uuid: 2df2c1a1-8f6a-490a-81be-8bdf29866880
|
||||
|
||||
library:
|
||||
name: library.test
|
||||
|
@ -27,6 +29,7 @@ library:
|
|||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
uuid: 647bcc48-8d5e-4a04-8ce5-2a3cd17b6eab
|
||||
|
||||
metro:
|
||||
name: metro.test
|
||||
|
@ -37,6 +40,7 @@ metro:
|
|||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
uuid: ef97cb80-333b-4893-b9df-163f2b452798
|
||||
|
||||
invalid:
|
||||
name: invalid.test
|
||||
|
@ -44,3 +48,4 @@ invalid:
|
|||
valid_to: <%= Time.zone.parse('2010-07-05').utc.to_s(:db) %>
|
||||
registrar: bestnames
|
||||
registrant: invalid
|
||||
uuid: 3c430ead-bb17-4b5b-aaa1-caa7dde7e138
|
1
test/fixtures/invoices.yml
vendored
1
test/fixtures/invoices.yml
vendored
|
@ -35,5 +35,4 @@ overdue:
|
|||
for_payments_test:
|
||||
<<: *DEFAULTS
|
||||
total: 12.00
|
||||
id: 1
|
||||
number: 1
|
||||
|
|
6
test/fixtures/whois_records.yml
vendored
Normal file
6
test/fixtures/whois_records.yml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
shop:
|
||||
name: shop.test
|
||||
domain: shop
|
||||
body: WHOIS text
|
||||
json:
|
||||
name: shop.test
|
|
@ -41,11 +41,12 @@ class APINameserversPutTest < ActionDispatch::IntegrationTest
|
|||
assert_equal nameserver_hash, nameservers(:metro_ns1).reload.attributes
|
||||
end
|
||||
|
||||
def test_returns_new_nameserver_record
|
||||
def test_returns_new_nameserver_record_and_affected_domain
|
||||
request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test',
|
||||
attributes: { hostname: 'ns55.bestnames.test',
|
||||
ipv4: ['192.0.2.55'],
|
||||
ipv6: ['2001:db8::55'] } } }
|
||||
|
||||
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response 200
|
||||
|
@ -53,7 +54,8 @@ class APINameserversPutTest < ActionDispatch::IntegrationTest
|
|||
id: 'ns55.bestnames.test',
|
||||
attributes: { hostname: 'ns55.bestnames.test',
|
||||
ipv4: ['192.0.2.55'],
|
||||
ipv6: ['2001:db8::55'] } } }),
|
||||
ipv6: ['2001:db8::55'] }},
|
||||
affected_domains: ["airport.test", "shop.test"] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest
|
|||
basic_auth: ['test_goodnames', 'testtest'])
|
||||
.to_return(body: { data: [{
|
||||
type: 'nameserver',
|
||||
id: 'new-ns.bestnames.test'
|
||||
}] }.to_json, status: 200)
|
||||
id: 'new-ns.bestnames.test'}],
|
||||
affected_domains: ["airport.test", "shop.test"]}.to_json, status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
@ -32,6 +32,7 @@ class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest
|
|||
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
|
||||
|
|
36
test/jobs/domain_delete_confirm_job_test.rb
Normal file
36
test/jobs/domain_delete_confirm_job_test.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require "test_helper"
|
||||
|
||||
class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:shop)
|
||||
@new_registrant = contacts(:william)
|
||||
@user = users(:api_bestnames)
|
||||
|
||||
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id })
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
end
|
||||
|
||||
def test_rejected_registrant_verification_polls_a_message
|
||||
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
last_registrar_message = @domain.registrar.messages.last
|
||||
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
|
||||
assert_equal(last_registrar_message.body, 'Registrant rejected domain deletion: shop.test')
|
||||
end
|
||||
|
||||
def test_accepted_registrant_verification_polls_a_message
|
||||
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
|
||||
last_registrar_message = @domain.registrar.messages.last
|
||||
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
|
||||
assert_equal(last_registrar_message.body, 'Registrant confirmed domain deletion: shop.test')
|
||||
end
|
||||
end
|
36
test/jobs/domain_update_confirm_job_test.rb
Normal file
36
test/jobs/domain_update_confirm_job_test.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require "test_helper"
|
||||
|
||||
class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:shop)
|
||||
@new_registrant = contacts(:william)
|
||||
@user = users(:api_bestnames)
|
||||
|
||||
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id })
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
end
|
||||
|
||||
def test_rejected_registrant_verification_polls_a_message
|
||||
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
last_registrar_message = @domain.registrar.messages.last
|
||||
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
|
||||
assert_equal(last_registrar_message.body, 'Registrant rejected domain update: shop.test')
|
||||
end
|
||||
|
||||
def test_accepted_registrant_verification_polls_a_message
|
||||
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
|
||||
last_registrar_message = @domain.registrar.messages.last
|
||||
assert_equal(last_registrar_message.attached_obj_id, @domain.id)
|
||||
assert_equal(last_registrar_message.body, 'Registrant confirmed domain update: shop.test')
|
||||
end
|
||||
end
|
23
test/models/registrar/replace_nameservers_test.rb
Normal file
23
test/models/registrar/replace_nameservers_test.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReplaceNameserversTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@registrar = registrars(:bestnames)
|
||||
end
|
||||
|
||||
def test_replace_nameservers_in_bulk_returns_sorted_domain_names
|
||||
new_attributes = { hostname: 'ns-updated1.bestnames.test', ipv4: '192.0.3.1',
|
||||
ipv6: '2001:db8::2' }
|
||||
result = @registrar.replace_nameservers('ns1.bestnames.test', new_attributes)
|
||||
|
||||
assert_equal(["airport.test", "shop.test"], result)
|
||||
end
|
||||
|
||||
def test_replace_nameservers_in_bulk_returns_empty_array_for_non_existent_base_nameserver
|
||||
new_attributes = { hostname: 'ns-updated1.bestnames.test', ipv4: '192.0.3.1',
|
||||
ipv6: '2001:db8::2' }
|
||||
result = @registrar.replace_nameservers('ns3.bestnames.test', new_attributes)
|
||||
|
||||
assert_equal([], result)
|
||||
end
|
||||
end
|
35
test/system/registrar/sign_in_test.rb
Normal file
35
test/system/registrar/sign_in_test.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAreaSignInTest < JavaScriptApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
WebMock.allow_net_connect!
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
@user.identity_code = '1234'
|
||||
@user.save
|
||||
end
|
||||
|
||||
def test_mobile_id_sign_in_page
|
||||
mock_client = Minitest::Mock.new
|
||||
mock_client.expect(:authenticate,
|
||||
OpenStruct.new(user_id_code: '1234', challenge_id: '1234'),
|
||||
[{ phone: "+3721234",
|
||||
message_to_display: "Authenticating",
|
||||
service_name: "Testimine" }])
|
||||
mock_client.expect(:session_code, 1234)
|
||||
|
||||
Digidoc::Client.stub(:new, mock_client) do
|
||||
visit registrar_login_path
|
||||
|
||||
click_on 'login-with-mobile-id-btn'
|
||||
|
||||
fill_in 'user[phone]', with: '1234'
|
||||
click_button 'Login'
|
||||
|
||||
flash_message = page.find('div.bg-success')
|
||||
assert_equal('Confirmation sms was sent to your phone. Verification code is 1234.',
|
||||
flash_message.text)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -13,6 +13,8 @@ require 'capybara/minitest'
|
|||
require 'webmock/minitest'
|
||||
require 'support/rails5_assetions' # Remove once upgraded to Rails 5
|
||||
|
||||
require 'application_system_test_case'
|
||||
|
||||
Setting.address_processing = false
|
||||
Setting.registry_country_code = 'US'
|
||||
|
||||
|
@ -38,4 +40,4 @@ class ActionDispatch::IntegrationTest
|
|||
Capybara.reset_sessions!
|
||||
Capybara.use_default_driver
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue