mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Add some registrar session specs
This commit is contained in:
parent
63c9ed83ee
commit
61da96d18a
3 changed files with 52 additions and 0 deletions
BIN
app/assets/images/test.png
Normal file
BIN
app/assets/images/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
|
@ -2,6 +2,7 @@
|
|||
Fabricator(:api_user) do
|
||||
username { sequence(:username) { |i| "username#{i}" } }
|
||||
password 'ghyt9e4fu'
|
||||
identity_code '14212128025'
|
||||
registrar
|
||||
active true
|
||||
end
|
||||
|
|
51
spec/features/registrar/sessions_spec.rb
Normal file
51
spec/features/registrar/sessions_spec.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Sessions', type: :feature do
|
||||
before :all do
|
||||
create_settings
|
||||
Fabricate(:api_user)
|
||||
end
|
||||
|
||||
scenario 'Api user should not get in when external service fails' do
|
||||
client = instance_double("Digidoc::Client")
|
||||
allow(client).to receive(:authenticate).and_return(
|
||||
OpenStruct.new(
|
||||
faultcode: 'Fault',
|
||||
detail: OpenStruct.new(
|
||||
message: 'Something is wrong'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
allow(Digidoc::Client).to receive(:new) { client }
|
||||
|
||||
visit registrar_login_path
|
||||
page.should have_css('a[href="/registrar/login/mid"]')
|
||||
|
||||
page.find('a[href="/registrar/login/mid"]').click
|
||||
|
||||
fill_in 'user_phone', with: '00007'
|
||||
click_button 'Log in'
|
||||
page.should have_text('Something is wrong')
|
||||
end
|
||||
|
||||
scenario 'Api user should not get in when there is not such user' do
|
||||
client = instance_double("Digidoc::Client")
|
||||
allow(client).to receive(:authenticate).and_return(
|
||||
OpenStruct.new(
|
||||
user_id_code: '123'
|
||||
)
|
||||
)
|
||||
|
||||
allow(Digidoc::Client).to receive(:new) { client }
|
||||
|
||||
visit registrar_login_path
|
||||
page.should have_css('a[href="/registrar/login/mid"]')
|
||||
|
||||
page.find('a[href="/registrar/login/mid"]').click
|
||||
|
||||
fill_in 'user_phone', with: '00007'
|
||||
click_button 'Log in'
|
||||
page.should have_text('No such user')
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue