Add feature to disable IP whitelist #2707

This commit is contained in:
Martin Lensment 2015-06-29 12:31:47 +03:00
parent 5a0fd06e20
commit ffebff72dd
6 changed files with 32 additions and 2 deletions

View file

@ -8,6 +8,14 @@ feature 'Sessions', type: :feature do
page.should have_text('Access denied')
end
it 'should see login page when whitelist disabled' do
Setting.registrar_ip_whitelist_enabled = false
WhiteIp.destroy_all
visit registrar_login_path
page.should_not have_text('Access denied')
Setting.registrar_ip_whitelist_enabled = true
end
it 'should see log in' do
@fixed_registrar.white_ips = [Fabricate(:white_ip_registrar)]
visit registrar_login_path
@ -26,6 +34,20 @@ feature 'Sessions', type: :feature do
page.should have_text('Access denied')
end
it 'should get in with invalid when whitelist disabled' do
Setting.registrar_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: [])
)
visit registrar_login_path
fill_in 'depp_user_tag', with: @api_user_invalid_ip.username
fill_in 'depp_user_password', with: @api_user_invalid_ip.password
click_button 'Log in'
page.should have_text('Log out')
Setting.registrar_ip_whitelist_enabled = true
end
it 'should not get in with invalid user' do
visit registrar_login_path
fill_in 'depp_user_tag', with: 'bla'