mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Improve registrar sessions specs
registry-240
This commit is contained in:
parent
576c09b00d
commit
2643df8d21
7 changed files with 43 additions and 13 deletions
|
@ -101,12 +101,6 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
endpoint = "#{ENV['sk_digi_doc_service_endpoint']}"
|
||||
client = Digidoc::Client.new(endpoint)
|
||||
|
||||
if Rails.env.test? && phone == "123"
|
||||
@user = ApiUser.find_by(identity_code: "14212128025")
|
||||
sign_in(@user, event: :authentication)
|
||||
return redirect_to registrar_root_url
|
||||
end
|
||||
|
||||
# country_codes = {'+372' => 'EST'}
|
||||
phone.gsub!('+372', '')
|
||||
response = client.authenticate(
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
- error_class = f.object.errors.any? ? 'has-error' : ''
|
||||
%div{class: error_class}
|
||||
= f.text_field :tag, class: 'form-control', placeholder: t(:username), required: true
|
||||
= f.password_field :password, class: 'form-control',
|
||||
= f.password_field :password, class: 'form-control',
|
||||
autocomplete: 'off', placeholder: t(:password), required: true
|
||||
|
||||
%button.btn.btn-lg.btn-primary.btn-block{:type => 'submit'}= t(:log_in)
|
||||
%button.btn.btn-lg.btn-primary.btn-block{:type => 'submit'}= t('.login_btn')
|
||||
|
||||
%hr
|
||||
= link_to '/registrar/login/mid' do
|
||||
= link_to '/registrar/login/mid', id: 'login-with-mobile-id-btn' do
|
||||
= image_tag 'mid.gif'
|
||||
= link_to '/registrar/id', method: :post do
|
||||
= image_tag 'id_card.gif'
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
.form-signin.col-md-4.center-block.text-center
|
||||
%h2.form-signin-heading.text-center= t(:log_in_with_mid)
|
||||
%hr
|
||||
= form_for @user, url: registrar_mid_path, auto_html5_validation: false,
|
||||
= form_for @user, url: registrar_mid_path, auto_html5_validation: false,
|
||||
html: {class: 'form-signin'} do |f|
|
||||
= f.text_field :phone, class: 'form-control',
|
||||
= f.text_field :phone, class: 'form-control',
|
||||
placeholder: t(:phone_no), autocomplete: 'off', required: true
|
||||
%button.btn.btn-lg.btn-primary.btn-block.js-login{:type => 'submit'}= t(:log_in)
|
||||
%button.btn.btn-lg.btn-primary.btn-block.js-login{:type => 'submit'}= t('.login_btn')
|
||||
|
||||
- if ['development', 'alpha'].include?(Rails.env)
|
||||
%div.text-center
|
||||
|
|
|
@ -531,7 +531,6 @@ en:
|
|||
ident_update_error: 'Parameter value policy error. Update of ident data not allowed [ident]'
|
||||
invoices: 'Invoices'
|
||||
no_such_user: 'No such user'
|
||||
log_in: 'Log in'
|
||||
phone_no: 'Phone number'
|
||||
log_in_with_mid: 'Log in with mobile-id'
|
||||
confirmation_sms_was_sent_to_your_phone_verification_code_is: 'Confirmation sms was sent to your phone. Verification code is %{code}.'
|
||||
|
|
7
config/locales/registrar/sessions.en.yml
Normal file
7
config/locales/registrar/sessions.en.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
en:
|
||||
registrar:
|
||||
sessions:
|
||||
login:
|
||||
login_btn: Login
|
||||
login_mid:
|
||||
login_btn: Login
|
21
spec/features/registrar/login/mobile_id_spec.rb
Normal file
21
spec/features/registrar/login/mobile_id_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Mobile ID login', db: true do
|
||||
given!(:api_user) { Fabricate(:api_user, identity_code: 1234) }
|
||||
|
||||
background do
|
||||
Setting.registrar_ip_whitelist_enabled = false
|
||||
digidoc_client = instance_double(Digidoc::Client, authenticate: OpenStruct.new(user_id_code: 1234), session_code: 1234)
|
||||
allow(Digidoc::Client).to receive(:new).and_return(digidoc_client)
|
||||
end
|
||||
|
||||
scenario 'login with phone number' do
|
||||
visit registrar_login_path
|
||||
click_on 'login-with-mobile-id-btn'
|
||||
|
||||
fill_in 'user[phone]', with: '1234'
|
||||
click_button 'Login'
|
||||
|
||||
expect(page).to have_text('Confirmation sms was sent to your phone. Verification code is')
|
||||
end
|
||||
end
|
9
spec/routing/registrar/sessions_routing_spec.rb
Normal file
9
spec/routing/registrar/sessions_routing_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Registrar::SessionsController do
|
||||
describe 'routing' do
|
||||
it 'routes to #login' do
|
||||
expect(get: '/registrar/login').to route_to('registrar/sessions#login')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue