BigW Consortium Gitlab

u2f.rb 1012 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
require 'spec_helper'

context 'U2F' do
  include JavaScriptFixturesHelpers

  let(:user) { create(:user, :two_factor_via_u2f) }

  before(:all) do
    clean_frontend_fixtures('u2f/')
  end

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

15 16 17
    render_views

    before do
18
      set_devise_mapping(context: @request)
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 45
    end

    it 'u2f/authenticate.html.raw' do |example|
      allow(controller).to receive(:find_user).and_return(user)

      post :create, user: { login: user.username, password: user.password }

      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)
    end

    it 'u2f/register.html.raw' do |example|
      get :show

      expect(response).to be_success
      store_frontend_fixture(response, example.description)
    end
  end
end