2019-10-17 06:07:30 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-03 20:48:37 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
context 'U2F' do
|
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
2019-02-21 16:55:42 +00:00
|
|
|
let(:user) { create(:user, :two_factor_via_u2f, otp_secret: 'otpsecret:coolkids') }
|
2017-01-03 20:48:37 +00:00
|
|
|
|
|
|
|
before(:all) do
|
|
|
|
clean_frontend_fixtures('u2f/')
|
|
|
|
end
|
|
|
|
|
|
|
|
describe SessionsController, '(JavaScript fixtures)', type: :controller do
|
2017-07-09 08:51:59 +00:00
|
|
|
include DeviseHelpers
|
|
|
|
|
2017-01-03 20:48:37 +00:00
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
2017-07-09 08:51:59 +00:00
|
|
|
set_devise_mapping(context: @request)
|
2017-01-03 20:48:37 +00:00
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'u2f/authenticate.html' do
|
2017-01-03 20:48:37 +00:00
|
|
|
allow(controller).to receive(:find_user).and_return(user)
|
|
|
|
|
2018-12-19 19:50:20 +00:00
|
|
|
post :create, params: { user: { login: user.username, password: user.password } }
|
2017-01-03 20:48:37 +00:00
|
|
|
|
2019-07-17 22:15:53 +00:00
|
|
|
expect(response).to be_successful
|
2017-01-03 20:48:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe Profiles::TwoFactorAuthsController, '(JavaScript fixtures)', type: :controller do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2019-11-14 03:06:25 +00:00
|
|
|
allow_next_instance_of(Profiles::TwoFactorAuthsController) do |instance|
|
|
|
|
allow(instance).to receive(:build_qr_code).and_return('qrcode:blackandwhitesquares')
|
|
|
|
end
|
2017-01-03 20:48:37 +00:00
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'u2f/register.html' do
|
2017-01-03 20:48:37 +00:00
|
|
|
get :show
|
|
|
|
|
2019-07-17 22:15:53 +00:00
|
|
|
expect(response).to be_successful
|
2017-01-03 20:48:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|