mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 18:26:06 +02:00
parent
26eb47ae09
commit
6e597f39e8
9 changed files with 178 additions and 124 deletions
12
spec/features/registrar/ip_restriction_spec.rb
Normal file
12
spec/features/registrar/ip_restriction_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Registrar area IP restriction', settings: false do
|
||||
background do
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
end
|
||||
|
||||
scenario 'notifies the user if his IP is not allowed' do
|
||||
visit registrar_root_path
|
||||
expect(page).to have_text('Access denied from IP 127.0.0.1')
|
||||
end
|
||||
end
|
|
@ -1,42 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Registrar area ip restriction', settings: false do
|
||||
context 'when enabled' do
|
||||
background do
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
end
|
||||
|
||||
context 'when ip is allowed' do
|
||||
given!(:white_ip) { create(:white_ip,
|
||||
ipv4: '127.0.0.1',
|
||||
interfaces: [WhiteIp::REGISTRAR]) }
|
||||
|
||||
it 'does not show error message' do
|
||||
visit registrar_login_path
|
||||
expect(page).to_not have_text(error_message)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ip is not allowed' do
|
||||
it 'shows error message' do
|
||||
visit registrar_login_path
|
||||
expect(page).to have_text(error_message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when disabled' do
|
||||
background do
|
||||
Setting.registrar_ip_whitelist_enabled = false
|
||||
end
|
||||
|
||||
it 'does not show error message' do
|
||||
visit registrar_login_path
|
||||
expect(page).to_not have_text(error_message)
|
||||
end
|
||||
end
|
||||
|
||||
def error_message
|
||||
t('registrar.authorization.ip_not_allowed', ip: '127.0.0.1')
|
||||
end
|
||||
end
|
43
spec/features/registrar/sign_in/password_spec.rb
Normal file
43
spec/features/registrar/sign_in/password_spec.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Registrar area password sign-in' do
|
||||
background do
|
||||
Setting.registrar_ip_whitelist_enabled = false
|
||||
end
|
||||
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue