debian-mirror-gitlab/spec/frontend/fixtures/u2f.rb

49 lines
1.1 KiB
Ruby
Raw Normal View History

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