Skip to content

Commit

Permalink
Merge pull request #10964 from 18F/stages/rc-2024-07-18-patch-1
Browse files Browse the repository at this point in the history
Deploy RC 398.1 to Production
  • Loading branch information
aduth authored Jul 18, 2024
2 parents 5301482 + 81030ec commit 3cbb3d8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 85 deletions.
1 change: 0 additions & 1 deletion app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ def track_authentication_attempt(email)
bad_password_count: session[:bad_password_count].to_i,
sp_request_url_present: sp_session[:request_url].present?,
remember_device: remember_device_cookie.present?,
new_device: success ? new_device? : nil,
)
end

Expand Down
4 changes: 0 additions & 4 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,6 @@ def edit_password_visit
# @param [String] bad_password_count represents number of prior login failures
# @param [Boolean] sp_request_url_present if was an SP request URL in the session
# @param [Boolean] remember_device if the remember device cookie was present
# @param [Boolean, nil] new_device Whether the user is authenticating from a new device. Nil if
# there is the attempt was unsuccessful, since it cannot be known whether it's a new device.
# Tracks authentication attempts at the email/password screen
def email_and_password_auth(
success:,
Expand All @@ -415,7 +413,6 @@ def email_and_password_auth(
bad_password_count:,
sp_request_url_present:,
remember_device:,
new_device:,
**extra
)
track_event(
Expand All @@ -427,7 +424,6 @@ def email_and_password_auth(
bad_password_count:,
sp_request_url_present:,
remember_device:,
new_device:,
**extra,
)
end
Expand Down
144 changes: 64 additions & 80 deletions spec/controllers/users/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
bad_password_count: 0,
sp_request_url_present: false,
remember_device: false,
new_device: true,
)
end

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -248,7 +229,6 @@
valid_captcha_result: false,
bad_password_count: 0,
remember_device: false,
new_device: nil,
sp_request_url_present: false,
)
end
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 3cbb3d8

Please sign in to comment.