mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
parent
787cca8e4c
commit
35afbf1f8c
15 changed files with 304 additions and 54 deletions
67
spec/requests/registrar/sessions_spec.rb
Normal file
67
spec/requests/registrar/sessions_spec.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Registrar session management', db: false do
|
||||
describe 'GET /registrar/login' do
|
||||
context 'when ip is allowed' do
|
||||
let(:restricted_ip) { instance_double(Authorization::RestrictedIP,
|
||||
can_access_registrar_area_sign_in_page?: true) }
|
||||
|
||||
before do
|
||||
allow(Authorization::RestrictedIP).to receive(:new).and_return(restricted_ip)
|
||||
end
|
||||
|
||||
specify do
|
||||
get registrar_login_path
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ip is not allowed' do
|
||||
let(:restricted_ip) { instance_double(Authorization::RestrictedIP,
|
||||
can_access_registrar_area_sign_in_page?: false) }
|
||||
|
||||
before do
|
||||
allow(Authorization::RestrictedIP).to receive(:new).and_return(restricted_ip)
|
||||
end
|
||||
|
||||
specify do
|
||||
get registrar_login_path
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /registrar/sessions' do
|
||||
context 'when ip is allowed' do
|
||||
let(:restricted_ip) { instance_double(Authorization::RestrictedIP,
|
||||
can_access_registrar_area_sign_in_page?: true) }
|
||||
|
||||
before do
|
||||
allow(Authorization::RestrictedIP).to receive(:new).and_return(restricted_ip)
|
||||
end
|
||||
|
||||
specify do
|
||||
make_request
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ip is not allowed' do
|
||||
let(:restricted_ip) { instance_double(Authorization::RestrictedIP,
|
||||
can_access_registrar_area_sign_in_page?: false) }
|
||||
|
||||
before do
|
||||
allow(Authorization::RestrictedIP).to receive(:new).and_return(restricted_ip)
|
||||
end
|
||||
|
||||
specify do
|
||||
make_request
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
end
|
||||
|
||||
def make_request
|
||||
post registrar_sessions_path, depp_user: { tag: 'test', password: 'test' }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue