Sha256: 78a73edba7ff542d6195f78cbedbdc118555698a3c7db0146fabf611572aec43
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 KB
Contents
require "test_helper" require "integration_tests_helper" class EnableOtpFormTest < ActionDispatch::IntegrationTest def teardown Capybara.reset_sessions! end test "a user should be able enable their OTP authentication by entering a confirmation code" do user = sign_user_in visit edit_user_otp_token_path user.reload fill_in "confirmation_code", with: ROTP::TOTP.new(user.otp_auth_secret).at(Time.now) click_button "Continue..." assert_equal user_otp_token_path, current_path assert page.has_content?("Enabled") within "#alerts" do assert page.has_content? 'Your Two-Factor Authentication settings have been updated.' end user.reload assert user.otp_enabled? end test "a user should not be able enable their OTP authentication with an incorrect confirmation code" do user = sign_user_in visit edit_user_otp_token_path fill_in "confirmation_code", with: "123456" click_button "Continue..." assert page.has_content?("To Enable Two-Factor Authentication") user.reload assert_not user.otp_enabled? within "#alerts" do assert page.has_content? 'The Confirmation Code you entered did not match the QR code shown below.' end visit "/" within "#alerts" do assert !page.has_content?('The Confirmation Code you entered did not match the QR code shown below.') end end test "a user should not be able enable their OTP authentication with a blank confirmation code" do user = sign_user_in visit edit_user_otp_token_path fill_in "confirmation_code", with: "" click_button "Continue..." assert page.has_content?("To Enable Two-Factor Authentication") within "#alerts" do assert page.has_content? 'The Confirmation Code you entered did not match the QR code shown below.' end user.reload assert_not user.otp_enabled? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
devise-otp-1.0.0 | test/integration/enable_otp_form_test.rb |