Merge branch 'master' into registry-791

# Conflicts:
#	db/structure.sql
This commit is contained in:
Artur Beljajev 2018-07-19 20:40:45 +03:00
commit 106592e53e
58 changed files with 991 additions and 1005 deletions

View 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

View file

@ -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
View file

@ -0,0 +1,6 @@
shop:
name: shop.test
domain: shop
body: WHOIS text
json:
name: shop.test

View file

@ -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

View file

@ -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

View 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

View 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

View 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

View 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

View file

@ -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