Welcome to mirror list, hosted at ThFree Co, Russian Federation.

webauthn.rb « fixtures « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ed6180118f008ff9502755fec3c11b6483393420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

require 'spec_helper'

RSpec.context 'WebAuthn' do
  include JavaScriptFixturesHelpers

  let(:user) { create(:user, :two_factor_via_webauthn, otp_secret: 'otpsecret:coolkids') }

  describe SessionsController, '(JavaScript fixtures)', type: :controller do
    include DeviseHelpers

    render_views

    before do
      set_devise_mapping(context: @request)
    end

    it 'webauthn/authenticate.html' do
      allow(controller).to receive(:find_user).and_return(user)
      post :create, params: { user: { login: user.username, password: user.password } }

      expect(response).to be_successful
    end
  end

  describe Profiles::TwoFactorAuthsController, '(JavaScript fixtures)', type: :controller do
    render_views

    before do
      sign_in(user)
      allow_next_instance_of(Profiles::TwoFactorAuthsController) do |instance|
        allow(instance).to receive(:build_qr_code).and_return('qrcode:blackandwhitesquares')
      end
      stub_feature_flags(webauthn_without_totp: false)
    end

    it 'webauthn/register.html' do
      get :show

      expect(response).to be_successful
    end
  end
end