2017-01-03 15:48:37 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
context 'U2F' do
|
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
2019-02-21 11:55:42 -05:00
|
|
|
let(:user) { create(:user, :two_factor_via_u2f, otp_secret: 'otpsecret:coolkids') }
|
2017-01-03 15:48:37 -05:00
|
|
|
|
|
|
|
before(:all) do
|
|
|
|
clean_frontend_fixtures('u2f/')
|
|
|
|
end
|
|
|
|
|
|
|
|
describe SessionsController, '(JavaScript fixtures)', type: :controller do
|
2017-07-09 04:51:59 -04:00
|
|
|
include DeviseHelpers
|
|
|
|
|
2017-01-03 15:48:37 -05:00
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
2017-07-09 04:51:59 -04:00
|
|
|
set_devise_mapping(context: @request)
|
2017-01-03 15:48:37 -05:00
|
|
|
end
|
|
|
|
|
2019-03-26 12:03:28 -04:00
|
|
|
it 'u2f/authenticate.html' do |example|
|
2017-01-03 15:48:37 -05:00
|
|
|
allow(controller).to receive(:find_user).and_return(user)
|
|
|
|
|
2018-12-19 14:50:20 -05:00
|
|
|
post :create, params: { user: { login: user.username, password: user.password } }
|
2017-01-03 15:48:37 -05:00
|
|
|
|
|
|
|
expect(response).to be_success
|
|
|
|
store_frontend_fixture(response, example.description)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe Profiles::TwoFactorAuthsController, '(JavaScript fixtures)', type: :controller do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2019-02-21 11:55:42 -05:00
|
|
|
allow_any_instance_of(Profiles::TwoFactorAuthsController).to receive(:build_qr_code).and_return('qrcode:blackandwhitesquares')
|
2017-01-03 15:48:37 -05:00
|
|
|
end
|
|
|
|
|
2019-03-26 12:03:28 -04:00
|
|
|
it 'u2f/register.html' do |example|
|
2017-01-03 15:48:37 -05:00
|
|
|
get :show
|
|
|
|
|
|
|
|
expect(response).to be_success
|
|
|
|
store_frontend_fixture(response, example.description)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|