mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Merge branch 'master' into registry-790
This commit is contained in:
commit
3d51a93f95
104 changed files with 728 additions and 557 deletions
|
@ -45,6 +45,6 @@ RSpec.describe Repp::ContactV1, db: true do
|
|||
end
|
||||
|
||||
def http_auth_key
|
||||
ActionController::HttpAuthentication::Basic.encode_credentials(user.username, user.password)
|
||||
ActionController::HttpAuthentication::Basic.encode_credentials(user.username, user.plain_text_password)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FactoryBot.define do
|
||||
factory :api_user do
|
||||
sequence(:username) { |n| "test#{n}" }
|
||||
password 'a' * ApiUser.min_password_length
|
||||
plain_text_password 'a' * ApiUser.min_password_length
|
||||
roles ['super']
|
||||
registrar
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Registrar area home link', db: true do
|
||||
scenario 'is visible' do
|
||||
visit registrar_login_url
|
||||
expect(page).to have_link('registrar-home-btn', href: registrar_root_path)
|
||||
end
|
||||
end
|
|
@ -1,39 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Registrar area password sign-in' do
|
||||
scenario 'signs in the user with valid credentials' do
|
||||
create(:api_user_with_unlimited_balance,
|
||||
active: true,
|
||||
login: 'test',
|
||||
password: 'testtest')
|
||||
|
||||
visit registrar_login_path
|
||||
sign_in_with 'test', 'testtest'
|
||||
|
||||
expect(page).to have_text(t('registrar.base.current_user.sign_out'))
|
||||
end
|
||||
|
||||
scenario 'notifies the user with invalid credentials' do
|
||||
create(:api_user, login: 'test', password: 'testtest')
|
||||
|
||||
visit registrar_login_path
|
||||
sign_in_with 'test', 'invalid'
|
||||
|
||||
expect(page).to have_text('No such user')
|
||||
end
|
||||
|
||||
scenario 'notifies the user with inactive account' do
|
||||
create(:api_user, active: false, login: 'test', password: 'testtest')
|
||||
|
||||
visit registrar_login_path
|
||||
sign_in_with 'test', 'testtest'
|
||||
|
||||
expect(page).to have_text('User is not active')
|
||||
end
|
||||
|
||||
def sign_in_with(username, password)
|
||||
fill_in 'depp_user_tag', with: username
|
||||
fill_in 'depp_user_password', with: password
|
||||
click_button 'Login'
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Registrar area sign-out', settings: false do
|
||||
background do
|
||||
sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance))
|
||||
end
|
||||
|
||||
scenario 'signs the user out' do
|
||||
visit registrar_root_path
|
||||
click_on t('registrar.base.current_user.sign_out')
|
||||
|
||||
expect(page).to have_text('Signed out successfully.')
|
||||
end
|
||||
end
|
|
@ -2,11 +2,11 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe 'Registrar area IP restriction', settings: false do
|
||||
before do
|
||||
@original_registrar_ip_whitelist_enabled = Setting.registrar_ip_whitelist_enabled
|
||||
@original_registrar_ip_whitelist_enabled_setting = Setting.registrar_ip_whitelist_enabled
|
||||
end
|
||||
|
||||
after do
|
||||
Setting.registrar_ip_whitelist_enabled = @original_registrar_ip_whitelist_enabled
|
||||
Setting.registrar_ip_whitelist_enabled = @original_registrar_ip_whitelist_enabled_setting
|
||||
end
|
||||
|
||||
context 'when authenticated' do
|
||||
|
@ -22,12 +22,11 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
context 'when ip is allowed' do
|
||||
let!(:white_ip) { create(:white_ip,
|
||||
ipv4: '127.0.0.1',
|
||||
registrar: controller.current_user.registrar,
|
||||
registrar: controller.current_registrar_user.registrar,
|
||||
interfaces: [WhiteIp::REGISTRAR]) }
|
||||
|
||||
specify do
|
||||
get registrar_root_url
|
||||
follow_redirect!
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
@ -35,13 +34,12 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
context 'when ip is not allowed' do
|
||||
it 'signs the user out' do
|
||||
get registrar_root_url
|
||||
follow_redirect!
|
||||
expect(controller.current_user).to be_nil
|
||||
expect(controller.current_registrar_user).to be_nil
|
||||
end
|
||||
|
||||
it 'redirects to login url' do
|
||||
get registrar_root_url
|
||||
expect(response).to redirect_to(registrar_login_url)
|
||||
expect(response).to redirect_to(new_registrar_user_session_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +47,6 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
context 'when IP restriction is disabled' do
|
||||
specify do
|
||||
get registrar_root_url
|
||||
follow_redirect!
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
@ -67,14 +64,14 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
interfaces: [WhiteIp::REGISTRAR]) }
|
||||
|
||||
specify do
|
||||
get registrar_login_path
|
||||
get new_registrar_user_session_path
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ip is not allowed' do
|
||||
specify do
|
||||
get registrar_login_path
|
||||
get new_registrar_user_session_path
|
||||
expect(response.body).to match "Access denied"
|
||||
end
|
||||
end
|
||||
|
@ -82,7 +79,7 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
|
||||
context 'when IP restriction is disabled' do
|
||||
specify do
|
||||
get registrar_login_path
|
||||
get new_registrar_user_session_path
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
let!(:current_user) { create(:api_user, id: 1, identity_code: 'code') }
|
||||
|
||||
before do
|
||||
sign_in_to_registrar_area(user: current_user)
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
context 'when ip is allowed' do
|
||||
|
@ -23,7 +23,7 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
it 'signs in as a new user' do
|
||||
put '/registrar/current_user/switch/2', nil, { HTTP_REFERER: registrar_contacts_url }
|
||||
follow_redirect!
|
||||
expect(controller.current_user.id).to eq(2)
|
||||
expect(controller.current_registrar_user.id).to eq(2)
|
||||
end
|
||||
|
||||
it 'redirects back' do
|
||||
|
@ -40,15 +40,6 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
put '/registrar/current_user/switch/2', nil, { HTTP_REFERER: registrar_contacts_path }
|
||||
end.to raise_error('Cannot switch to unlinked user')
|
||||
end
|
||||
|
||||
it 'does not sign in as a new user' do
|
||||
suppress StandardError do
|
||||
put '/registrar/current_user/switch/2', nil, { HTTP_REFERER: registrar_contacts_path }
|
||||
end
|
||||
|
||||
follow_redirect!
|
||||
expect(controller.current_user.id).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -62,7 +53,7 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
|
||||
specify do
|
||||
put '/registrar/current_user/switch/2'
|
||||
expect(response).to redirect_to(registrar_login_url)
|
||||
expect(response).to redirect_to(new_registrar_user_session_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -70,7 +61,7 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
context 'when user is not authenticated' do
|
||||
specify do
|
||||
put '/registrar/current_user/switch/2'
|
||||
expect(response).to redirect_to(registrar_login_url)
|
||||
expect(response).to redirect_to(new_registrar_user_session_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Registrar area password sign-in', settings: false do
|
||||
let!(:user) { create(:api_user, active: true, login: 'test', password: 'testtest') }
|
||||
|
||||
it 'signs the user in' do
|
||||
post registrar_sessions_path, depp_user: { tag: 'test', password: 'testtest' }
|
||||
follow_redirect!
|
||||
expect(controller.current_user).to eq(user)
|
||||
end
|
||||
|
||||
it 'redirects to root url' do
|
||||
post registrar_sessions_path, depp_user: { tag: 'test', password: 'testtest' }
|
||||
expect(response).to redirect_to(registrar_root_url)
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Registrar area sign-out', settings: false do
|
||||
before do
|
||||
sign_in_to_registrar_area
|
||||
end
|
||||
|
||||
it 'signs the user out' do
|
||||
delete registrar_destroy_user_session_path
|
||||
follow_redirect!
|
||||
expect(controller.current_user).to be_nil
|
||||
end
|
||||
|
||||
it 'redirects to login url' do
|
||||
delete registrar_destroy_user_session_path
|
||||
expect(response).to redirect_to(registrar_login_url)
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Registrar::DomainsController do
|
||||
describe 'routing' do
|
||||
it 'routes to #index' do
|
||||
expect(get: '/registrar/domains').to route_to('registrar/domains#index')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Registrar::SessionsController do
|
||||
describe 'routing' do
|
||||
it 'routes to #login' do
|
||||
expect(get: '/registrar/login').to route_to('registrar/sessions#login')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,19 +1,19 @@
|
|||
module Features
|
||||
module SessionHelpers
|
||||
def sign_in_to_admin_area(user: create(:admin_user))
|
||||
visit admin_login_url
|
||||
visit new_admin_user_session_url
|
||||
|
||||
fill_in 'admin_user[username]', with: user.username
|
||||
fill_in 'admin_user[password]', with: user.password
|
||||
|
||||
click_button 'Log in'
|
||||
click_button 'Sign in'
|
||||
end
|
||||
|
||||
def sign_in_to_registrar_area(user: create(:api_user))
|
||||
visit registrar_login_url
|
||||
visit new_registrar_user_session_url
|
||||
|
||||
fill_in 'depp_user_tag', with: user.username
|
||||
fill_in 'depp_user_password', with: user.password
|
||||
fill_in 'registrar_user_username', with: user.username
|
||||
fill_in 'registrar_user_password', with: user.plain_text_password
|
||||
|
||||
click_button 'Login'
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
module Requests
|
||||
module SessionHelpers
|
||||
def sign_in_to_admin_area(user: create(:admin_user))
|
||||
post admin_sessions_path, admin_user: { username: user.username, password: user.password }
|
||||
post admin_user_session_path, admin_user: { username: user.username, password: user.password }
|
||||
end
|
||||
|
||||
def sign_in_to_registrar_area(user: create(:api_user))
|
||||
post registrar_sessions_path, { depp_user: { tag: user.username, password: user.password } }
|
||||
post registrar_user_session_path, { registrar_user: { username: user.username, password: user.plain_text_password } }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue