Sha256: b7409952440d90c3f1385ab6bc33dfa071210e4ef82c959f4283db7928162a89

Contents?: true

Size: 958 Bytes

Versions: 2

Compression:

Stored size: 958 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Tokens' do
  subject (:user) { User.create(email: 'mb@geemail.com', password: 'iwantabigmac1') }

  it 'can be disabled by a user after successfully enabling' do
    enable_otp_and_sign_in user

    fill_in 'user_token', with: ROTP::TOTP.new(user.otp_auth_secret).at(Time.now)
    click_button 'Submit Token'

    expect(current_path).to eq(root_path)

    disable_otp
    sign_out user
    sign_in_user user

    expect(current_path).to eq(root_path)
  end

  xit 'cannot be reused' do
    enable_otp_and_sign_in user

    prev_token = ROTP::TOTP.new(user.otp_auth_secret).at(Time.now)

    fill_in 'user_token', with: prev_token
    click_button 'Submit Token'

    expect(current_path).to eq(root_path)

    sign_out user
    sign_in_user user

    fill_in 'user_token', with: prev_token
    click_button 'Submit Token'

    expect(current_path).to eq(new_user_session_path)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise-2fa-0.2.1 spec/system/token_spec.rb
devise-2fa-0.2.0 spec/system/token_spec.rb