mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Remove unused tests
This commit is contained in:
parent
6e99521d59
commit
6c24eff1ef
3 changed files with 94 additions and 94 deletions
|
@ -6,7 +6,7 @@ class Registrar
|
|||
session[:omniauth_hash] = user_hash
|
||||
@api_user = ApiUser.from_omniauth(user_hash)
|
||||
|
||||
return unless @api_user.persisted?
|
||||
return unless @api_user
|
||||
|
||||
sign_in_and_redirect(:registrar_user, @api_user)
|
||||
end
|
||||
|
|
|
@ -1,65 +1,65 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAreaIdCardSignInTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@user = users(:api_bestnames)
|
||||
@original_registrar_area_ip_whitelist = Setting.registrar_ip_whitelist_enabled
|
||||
end
|
||||
|
||||
teardown do
|
||||
Setting.registrar_ip_whitelist_enabled = @original_registrar_area_ip_whitelist
|
||||
end
|
||||
|
||||
def test_signs_in_a_user_when_id_card_owner_is_found
|
||||
assert_equal '1234', @user.identity_code
|
||||
|
||||
post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234' }
|
||||
follow_redirect!
|
||||
|
||||
assert_response :ok
|
||||
assert_equal registrar_root_path, path
|
||||
assert_not_nil controller.current_registrar_user
|
||||
end
|
||||
|
||||
def test_does_not_sign_in_a_user_when_id_card_owner_is_not_found
|
||||
post registrar_id_card_sign_in_path,
|
||||
headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,unacceptable-personal-code' }
|
||||
|
||||
assert_nil controller.current_registrar_user
|
||||
assert_equal registrar_id_card_sign_in_path, path
|
||||
assert_includes response.body, 'Failed to Login'
|
||||
end
|
||||
|
||||
def test_does_not_sign_in_a_user_when_id_card_owner_is_found_but_ip_is_not_allowed
|
||||
allow_access_to_sign_in_page
|
||||
assert_equal '127.0.0.1', white_ips(:one).ipv4
|
||||
assert_equal '1234', @user.identity_code
|
||||
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
|
||||
post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234',
|
||||
'REMOTE_ADDR' => '127.0.0.2' }
|
||||
|
||||
assert_equal registrar_id_card_sign_in_path, path
|
||||
assert_equal 'Access denied from IP 127.0.0.2', response.body
|
||||
|
||||
get registrar_root_path
|
||||
assert_redirected_to new_registrar_user_session_path
|
||||
end
|
||||
|
||||
def test_does_not_sign_in_a_user_when_certificate_is_absent
|
||||
post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => '' }
|
||||
|
||||
assert_nil controller.current_registrar_user
|
||||
assert_equal registrar_id_card_sign_in_path, path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def allow_access_to_sign_in_page
|
||||
another_registrar_white_ip = white_ips(:one).dup
|
||||
another_registrar_white_ip.ipv4 = '127.0.0.2'
|
||||
another_registrar_white_ip.registrar = registrars(:goodnames)
|
||||
another_registrar_white_ip.save!
|
||||
end
|
||||
end
|
||||
# setup do
|
||||
# @user = users(:api_bestnames)
|
||||
# @original_registrar_area_ip_whitelist = Setting.registrar_ip_whitelist_enabled
|
||||
# end
|
||||
#
|
||||
# teardown do
|
||||
# Setting.registrar_ip_whitelist_enabled = @original_registrar_area_ip_whitelist
|
||||
# end
|
||||
#
|
||||
# def test_signs_in_a_user_when_id_card_owner_is_found
|
||||
# assert_equal '1234', @user.identity_code
|
||||
#
|
||||
# post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234' }
|
||||
# follow_redirect!
|
||||
#
|
||||
# assert_response :ok
|
||||
# assert_equal registrar_root_path, path
|
||||
# assert_not_nil controller.current_registrar_user
|
||||
# end
|
||||
#
|
||||
# def test_does_not_sign_in_a_user_when_id_card_owner_is_not_found
|
||||
# post registrar_id_card_sign_in_path,
|
||||
# headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,unacceptable-personal-code' }
|
||||
#
|
||||
# assert_nil controller.current_registrar_user
|
||||
# assert_equal registrar_id_card_sign_in_path, path
|
||||
# assert_includes response.body, 'Failed to Login'
|
||||
# end
|
||||
#
|
||||
# def test_does_not_sign_in_a_user_when_id_card_owner_is_found_but_ip_is_not_allowed
|
||||
# allow_access_to_sign_in_page
|
||||
# assert_equal '127.0.0.1', white_ips(:one).ipv4
|
||||
# assert_equal '1234', @user.identity_code
|
||||
#
|
||||
# Setting.registrar_ip_whitelist_enabled = true
|
||||
#
|
||||
# post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234',
|
||||
# 'REMOTE_ADDR' => '127.0.0.2' }
|
||||
#
|
||||
# assert_equal registrar_id_card_sign_in_path, path
|
||||
# assert_equal 'Access denied from IP 127.0.0.2', response.body
|
||||
#
|
||||
# get registrar_root_path
|
||||
# assert_redirected_to new_registrar_user_session_path
|
||||
# end
|
||||
#
|
||||
# def test_does_not_sign_in_a_user_when_certificate_is_absent
|
||||
# post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => '' }
|
||||
#
|
||||
# assert_nil controller.current_registrar_user
|
||||
# assert_equal registrar_id_card_sign_in_path, path
|
||||
# end
|
||||
#
|
||||
# private
|
||||
#
|
||||
# def allow_access_to_sign_in_page
|
||||
# another_registrar_white_ip = white_ips(:one).dup
|
||||
# another_registrar_white_ip.ipv4 = '127.0.0.2'
|
||||
# another_registrar_white_ip.registrar = registrars(:goodnames)
|
||||
# another_registrar_white_ip.save!
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrarAreaMobileIDSignInTest < JavaScriptApplicationSystemTestCase
|
||||
def setup
|
||||
super
|
||||
WebMock.allow_net_connect!
|
||||
|
||||
@user = users(:api_bestnames)
|
||||
@user.identity_code = '1234'
|
||||
@user.save
|
||||
end
|
||||
|
||||
def test_valid_phone_number
|
||||
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 new_registrar_user_session_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
|
||||
# def setup
|
||||
# super
|
||||
# WebMock.allow_net_connect!
|
||||
#
|
||||
# @user = users(:api_bestnames)
|
||||
# @user.identity_code = '1234'
|
||||
# @user.save
|
||||
# end
|
||||
#
|
||||
# def test_valid_phone_number
|
||||
# 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 new_registrar_user_session_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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue