-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10964 from 18F/stages/rc-2024-07-18-patch-1
Deploy RC 398.1 to Production
- Loading branch information
Showing
3 changed files
with
64 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,6 @@ | |
bad_password_count: 0, | ||
sp_request_url_present: false, | ||
remember_device: false, | ||
new_device: true, | ||
) | ||
end | ||
|
||
|
@@ -114,24 +113,6 @@ | |
|
||
response | ||
end | ||
|
||
it 'tracks as not being from a new device' do | ||
stub_analytics | ||
|
||
response | ||
|
||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
success: true, | ||
user_id: user.uuid, | ||
user_locked_out: false, | ||
valid_captcha_result: true, | ||
bad_password_count: 0, | ||
sp_request_url_present: false, | ||
remember_device: false, | ||
new_device: false, | ||
) | ||
end | ||
end | ||
end | ||
|
||
|
@@ -169,41 +150,41 @@ | |
user = create(:user, :fully_registered) | ||
|
||
stub_analytics | ||
expect(SCrypt::Engine).to receive(:hash_secret).once.and_call_original | ||
|
||
post :create, params: { user: { email: user.email.upcase, password: 'invalid_password' } } | ||
|
||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
analytics_hash = { | ||
success: false, | ||
user_id: user.uuid, | ||
user_locked_out: false, | ||
valid_captcha_result: true, | ||
bad_password_count: 1, | ||
sp_request_url_present: false, | ||
remember_device: false, | ||
new_device: nil, | ||
) | ||
} | ||
expect(SCrypt::Engine).to receive(:hash_secret).once.and_call_original | ||
|
||
expect(@analytics).to receive(:track_event). | ||
with('Email and Password Authentication', analytics_hash) | ||
|
||
post :create, params: { user: { email: user.email.upcase, password: 'invalid_password' } } | ||
expect(subject.session[:sign_in_flow]).to eq(:sign_in) | ||
end | ||
|
||
it 'tracks the authentication attempt for nonexistent user' do | ||
stub_analytics | ||
expect(SCrypt::Engine).to receive(:hash_secret).once.and_call_original | ||
|
||
post :create, params: { user: { email: '[email protected]', password: 'password' } } | ||
|
||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
analytics_hash = { | ||
success: false, | ||
user_id: 'anonymous-uuid', | ||
user_locked_out: false, | ||
valid_captcha_result: true, | ||
bad_password_count: 1, | ||
sp_request_url_present: false, | ||
remember_device: false, | ||
new_device: nil, | ||
) | ||
} | ||
expect(SCrypt::Engine).to receive(:hash_secret).once.and_call_original | ||
|
||
expect(@analytics).to receive(:track_event). | ||
with('Email and Password Authentication', analytics_hash) | ||
|
||
post :create, params: { user: { email: '[email protected]', password: 'password' } } | ||
end | ||
|
||
it 'tracks unsuccessful authentication for locked out user' do | ||
|
@@ -214,20 +195,20 @@ | |
) | ||
|
||
stub_analytics | ||
|
||
post :create, params: { user: { email: user.email.upcase, password: user.password } } | ||
|
||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
analytics_hash = { | ||
success: false, | ||
user_id: user.uuid, | ||
user_locked_out: true, | ||
valid_captcha_result: true, | ||
bad_password_count: 0, | ||
sp_request_url_present: false, | ||
remember_device: false, | ||
new_device: nil, | ||
) | ||
} | ||
|
||
expect(@analytics).to receive(:track_event). | ||
with('Email and Password Authentication', analytics_hash) | ||
|
||
post :create, params: { user: { email: user.email.upcase, password: user.password } } | ||
end | ||
|
||
it 'tracks unsuccessful authentication for failed reCAPTCHA' do | ||
|
@@ -248,7 +229,6 @@ | |
valid_captcha_result: false, | ||
bad_password_count: 0, | ||
remember_device: false, | ||
new_device: nil, | ||
sp_request_url_present: false, | ||
) | ||
end | ||
|
@@ -261,38 +241,39 @@ | |
|
||
stub_analytics | ||
|
||
post :create, params: { user: { email: user.email.upcase, password: 'invalid' } } | ||
post :create, params: { user: { email: user.email.upcase, password: 'invalid' } } | ||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
analytics_hash = { | ||
success: false, | ||
user_id: user.uuid, | ||
user_locked_out: false, | ||
valid_captcha_result: true, | ||
bad_password_count: 2, | ||
sp_request_url_present: false, | ||
remember_device: false, | ||
new_device: nil, | ||
) | ||
} | ||
|
||
post :create, params: { user: { email: user.email.upcase, password: 'invalid' } } | ||
expect(@analytics).to receive(:track_event). | ||
with('Email and Password Authentication', analytics_hash) | ||
post :create, params: { user: { email: user.email.upcase, password: 'invalid' } } | ||
end | ||
|
||
it 'tracks the presence of SP request_url in session' do | ||
subject.session[:sp] = { request_url: mock_valid_site } | ||
stub_analytics | ||
|
||
post :create, params: { user: { email: '[email protected]', password: 'password' } } | ||
|
||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
analytics_hash = { | ||
success: false, | ||
user_id: 'anonymous-uuid', | ||
user_locked_out: false, | ||
valid_captcha_result: true, | ||
bad_password_count: 1, | ||
sp_request_url_present: true, | ||
remember_device: false, | ||
new_device: nil, | ||
) | ||
} | ||
|
||
expect(@analytics).to receive(:track_event). | ||
with('Email and Password Authentication', analytics_hash) | ||
|
||
post :create, params: { user: { email: '[email protected]', password: 'password' } } | ||
end | ||
|
||
context 'IAL1 user' do | ||
|
@@ -450,24 +431,27 @@ | |
) | ||
|
||
stub_analytics | ||
|
||
post :create, params: { user: { email: user.email, password: user.password } } | ||
|
||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
analytics_hash = { | ||
success: true, | ||
user_id: user.uuid, | ||
user_locked_out: false, | ||
valid_captcha_result: true, | ||
bad_password_count: 0, | ||
sp_request_url_present: false, | ||
remember_device: false, | ||
new_device: true, | ||
) | ||
expect(@analytics).to have_logged_event( | ||
'Profile Encryption: Invalid', | ||
} | ||
|
||
expect(@analytics).to receive(:track_event). | ||
with('Email and Password Authentication', analytics_hash) | ||
|
||
profile_encryption_error = { | ||
error: 'Unable to parse encrypted payload', | ||
) | ||
} | ||
expect(@analytics).to receive(:track_event). | ||
with('Profile Encryption: Invalid', profile_encryption_error) | ||
|
||
post :create, params: { user: { email: user.email, password: user.password } } | ||
|
||
expect(controller.user_session[:encrypted_profiles]).to be_nil | ||
expect(profile.reload).to_not be_active | ||
end | ||
|
@@ -574,20 +558,20 @@ | |
} | ||
|
||
stub_analytics | ||
|
||
post :create, params: { user: { email: user.email, password: user.password } } | ||
|
||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
analytics_hash = { | ||
success: true, | ||
user_id: user.uuid, | ||
user_locked_out: false, | ||
valid_captcha_result: true, | ||
bad_password_count: 0, | ||
sp_request_url_present: false, | ||
remember_device: true, | ||
new_device: true, | ||
) | ||
} | ||
|
||
expect(@analytics).to receive(:track_event). | ||
with('Email and Password Authentication', analytics_hash) | ||
|
||
post :create, params: { user: { email: user.email, password: user.password } } | ||
end | ||
end | ||
|
||
|
@@ -600,20 +584,20 @@ | |
} | ||
|
||
stub_analytics | ||
|
||
post :create, params: { user: { email: user.email, password: user.password } } | ||
|
||
expect(@analytics).to have_logged_event( | ||
'Email and Password Authentication', | ||
analytics_hash = { | ||
success: true, | ||
user_id: user.uuid, | ||
user_locked_out: false, | ||
valid_captcha_result: true, | ||
bad_password_count: 0, | ||
sp_request_url_present: false, | ||
remember_device: true, | ||
new_device: true, | ||
) | ||
} | ||
|
||
expect(@analytics).to receive(:track_event). | ||
with('Email and Password Authentication', analytics_hash) | ||
|
||
post :create, params: { user: { email: user.email, password: user.password } } | ||
end | ||
end | ||
|
||
|