-
Notifications
You must be signed in to change notification settings - Fork 166
LG-13497: Fix Session Logout Message #10873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df70443
3a0daca
53244a9
9cda797
3a58485
7cbceab
b541b1d
622e36e
3d25ca6
0f3768e
91adead
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.feature 'Visitor signs in with bad passwords and gets locked out' do | ||
| include ActionView::Helpers::DateHelper | ||
| let(:user) { create(:user, :fully_registered) } | ||
| let(:bad_password) { 'badpassword' } | ||
| let(:window) { IdentityConfig.store.max_bad_passwords_window_in_seconds.seconds } | ||
|
|
||
| scenario 'visitor tries too many bad passwords gets locked out then waits window seconds' do | ||
| visit new_user_session_path | ||
|
|
@@ -15,14 +17,33 @@ | |
| expect(page).to have_content(error_message) | ||
| expect(page).to have_current_path(new_user_session_path) | ||
| end | ||
| locked_at = Time.zone.at(page.get_rack_session['max_bad_passwords_at']) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice that you found a way to get at the session from the feature specs 👍
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea it was a little annoying because calling that changes page. So I had to call a visit afterwards. railsware/rack_session_access#10 Very weird |
||
| # Need to do this because getting rack session changes the url. | ||
| visit new_user_session_path | ||
| 2.times do | ||
| fill_in_credentials_and_submit(user.email, bad_password) | ||
|
|
||
| expect(page).to have_current_path(new_user_session_path) | ||
| expect(page).to have_content(t('errors.sign_in.bad_password_limit')) | ||
| new_time = Time.zone.at(locked_at) + window | ||
| time_left = distance_of_time_in_words(Time.zone.now, new_time, true) | ||
| expect(page).to have_content( | ||
| t( | ||
| 'errors.sign_in.bad_password_limit', | ||
| time_left: time_left, | ||
| ), | ||
| ) | ||
| end | ||
| fill_in_credentials_and_submit(user.email, user.password) | ||
| expect(page).to have_current_path(new_user_session_path) | ||
| expect(page).to have_content(t('errors.sign_in.bad_password_limit')) | ||
| new_time = Time.zone.at(locked_at) + window | ||
| time_left = distance_of_time_in_words(Time.zone.now, new_time, true) | ||
| expect(page).to have_content( | ||
| t( | ||
| 'errors.sign_in.bad_password_limit', | ||
| time_left: time_left, | ||
| ), | ||
| ) | ||
|
|
||
| travel_to(IdentityConfig.store.max_bad_passwords_window_in_seconds.seconds.from_now) do | ||
| fill_in_credentials_and_submit(user.email, bad_password) | ||
| expect(page).to have_content(error_message) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.