Sha256: 8ccc557ffeeb38d45bd492c1fcbeb010786b6a514d9650388cf5c71f2529f970

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

require "test_helper"
require "integration_tests_helper"

class ResetTokenTest < ActionDispatch::IntegrationTest

  def setup
    # log in 1fa
    @user = enable_otp_and_sign_in
    assert_equal user_otp_credential_path, current_path

    # otp 2fa
    fill_in "token", with: ROTP::TOTP.new(@user.otp_auth_secret).at(Time.now)
    click_button "Submit Token"
    assert_equal root_path, current_path
  end


  def teardown
    Capybara.reset_sessions!
  end

  test "redirects to otp_tokens#edit page" do
    reset_otp

    assert_equal "/users/otp/token/edit", current_path
  end

  test "generates new token secrets" do
    # get auth secrets
    auth_secret = @user.otp_auth_secret
    recovery_secret = @user.otp_recovery_secret

    # reset otp
    reset_otp

    # compare auth secrets
    @user.reload
    assert_not_nil @user.otp_auth_secret
    assert_not_equal @user.otp_auth_secret, auth_secret

    assert_not_nil @user.otp_recovery_secret
    assert_not_equal @user.otp_recovery_secret, recovery_secret
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise-otp-0.8.0 test/integration/reset_token_test.rb
devise-otp-0.7.1 test/integration/reset_token_test.rb
devise-otp-0.7.0 test/integration/reset_token_test.rb