mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
Improve ip whitelist #2713
This commit is contained in:
parent
afb3d7ed1d
commit
a4ccc5749e
6 changed files with 19 additions and 13 deletions
|
@ -9,7 +9,7 @@ Fabricator(:registrar) do
|
|||
country_code 'EE'
|
||||
code { sequence(:code) { |i| "REGISTRAR#{i}" } }
|
||||
reference_no { sequence(:reference_no) { |i| "RF#{i}" } }
|
||||
white_ips { [Fabricate(:white_ip)] }
|
||||
white_ips { [Fabricate(:white_ip), Fabricate(:white_ip, interface: WhiteIp::REGISTRAR)] }
|
||||
end
|
||||
|
||||
Fabricator(:registrar_with_no_account_activities, from: :registrar) do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Fabricator(:white_ip) do
|
||||
ipv4 '127.0.0.1'
|
||||
interface WhiteIp::GLOBAL
|
||||
interface WhiteIp::API
|
||||
end
|
||||
|
||||
Fabricator(:white_ip_registrar, from: :white_ip) do
|
||||
|
|
|
@ -3,6 +3,7 @@ require 'rails_helper'
|
|||
feature 'Sessions', type: :feature do
|
||||
context 'with invalid ip' do
|
||||
it 'should not see login page' do
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
WhiteIp.destroy_all
|
||||
visit registrar_login_path
|
||||
page.should have_text('Access denied')
|
||||
|
@ -36,6 +37,7 @@ feature 'Sessions', type: :feature do
|
|||
|
||||
it 'should get in with invalid when whitelist disabled' do
|
||||
Setting.registrar_ip_whitelist_enabled = false
|
||||
Setting.api_ip_whitelist_enabled = false
|
||||
Fabricate(:registrar, white_ips: [Fabricate(:white_ip), Fabricate(:white_ip_registrar)])
|
||||
@api_user_invalid_ip = Fabricate(
|
||||
:api_user, identity_code: '37810013294', registrar: Fabricate(:registrar, white_ips: [])
|
||||
|
@ -46,6 +48,7 @@ feature 'Sessions', type: :feature do
|
|||
click_button 'Log in'
|
||||
page.should have_text('Log out')
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
Setting.api_ip_whitelist_enabled = true
|
||||
end
|
||||
|
||||
it 'should not get in with invalid user' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue