Skip to content

Commit

Permalink
LG-10837: Add New Piv Cac Logging for login visited (#9294)
Browse files Browse the repository at this point in the history
* changelog: Internal Fixes, Authentication LG-10837: Piv Cac Logging fixes

* changelog: Internal, Authentication, Add Login visited for pivcac/change logging names to be uniform

* uniform spec test

* fix naming convention for piv cac

* update rspec

* add previous name
  • Loading branch information
mdiarra3 committed Oct 11, 2023
1 parent f9a0cd0 commit f1462fc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def submit_new_piv_cac
private

def track_piv_cac_setup_visit
analytics.piv_cac_setup_visit(**analytics_properties)
analytics.piv_cac_setup_visited(**analytics_properties)
end

def remove_piv_cac
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/piv_cac_login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def error
private

def render_prompt
analytics.piv_cac_setup_visit(in_account_creation_flow: false)
analytics.piv_cac_login_visited
@presenter = PivCacAuthenticationLoginPresenter.new(piv_cac_login_form, url_options)
render :new
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def decline
private

def render_prompt
analytics.piv_cac_setup_visit(in_account_creation_flow: false)
analytics.piv_cac_setup_visited(in_account_creation_flow: false)
render :prompt
end

Expand Down
21 changes: 15 additions & 6 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2652,13 +2652,14 @@ def multi_factor_auth_added_phone(enabled_mfa_methods_count:, **extra)
)
end

# @identity.idp.previous_event_name Multi-Factor Authentication: Added PIV_CAC
# Tracks when the user has added the MFA method piv_cac to their account
# @param [Integer] enabled_mfa_methods_count number of registered mfa methods for the user
# @param [Boolean] in_account_creation_flow whether user is going through creation flow
def multi_factor_auth_added_piv_cac(enabled_mfa_methods_count:, in_account_creation_flow:,
**extra)
track_event(
'Multi-Factor Authentication: Added PIV_CAC', # rubocop:disable IdentityIdp/AnalyticsEventNameLinter
:multi_factor_auth_added_piv_cac,
{
method_name: :piv_cac,
enabled_mfa_methods_count:,
Expand Down Expand Up @@ -2767,6 +2768,7 @@ def multi_factor_auth_enter_personal_key_visit(context:, **extra)
)
end

# @identity.idp.previous_event_name 'Multi-Factor Authentication: enter PIV CAC visited'
# @param ["authentication","reauthentication","confirmation"] context user session context
# @param ["piv_cac"] multi_factor_auth_method
# @param [Integer, nil] piv_cac_configuration_id PIV/CAC configuration database ID
Expand All @@ -2778,7 +2780,7 @@ def multi_factor_auth_enter_piv_cac(
**extra
)
track_event(
'Multi-Factor Authentication: enter PIV CAC visited', # rubocop:disable IdentityIdp/AnalyticsEventNameLinter
:multi_factor_auth_enter_piv_cac,
context: context,
multi_factor_auth_method: multi_factor_auth_method,
piv_cac_configuration_id: piv_cac_configuration_id,
Expand Down Expand Up @@ -3352,29 +3354,36 @@ def phone_deletion(success:, phone_configuration_id:, **extra)
end

# @identity.idp.previous_event_name User Registration: piv cac disabled
# @identity.idp.previous_event_name PIV CAC disabled
# Tracks when user's piv cac is disabled
def piv_cac_disabled
track_event('PIV CAC disabled') # rubocop:disable IdentityIdp/AnalyticsEventNameLinter
track_event(:piv_cac_disabled)
end

# @identity.idp.previous_event_name PIV/CAC login
# @param [Boolean] success
# @param [Hash] errors
# tracks piv cac login event
def piv_cac_login(success:, errors:, **extra)
track_event(
'PIV/CAC Login', # rubocop:disable IdentityIdp/AnalyticsEventNameLinter
:piv_cac_login,
success: success,
errors: errors,
**extra,
)
end

def piv_cac_login_visited
track_event(:piv_cac_login_visited)
end

# @identity.idp.previous_event_name User Registration: piv cac setup visited
# @identity.idp.previous_event_name PIV CAC setup visited
# Tracks when user's piv cac setup
# @param [Boolean] in_account_creation_flow
def piv_cac_setup_visit(in_account_creation_flow:, **extra)
def piv_cac_setup_visited(in_account_creation_flow:, **extra)
track_event(
'PIV CAC setup visited', # rubocop:disable IdentityIdp/AnalyticsEventNameLinter
:piv_cac_setup_visited,
in_account_creation_flow:,
**extra,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}

expect(@analytics).to receive(:track_event).
with('Multi-Factor Authentication: enter PIV CAC visited', attributes)
with(:multi_factor_auth_enter_piv_cac, attributes)

submit_attributes = {
success: true,
Expand Down Expand Up @@ -203,7 +203,7 @@
}

expect(@analytics).to receive(:track_event).
with('Multi-Factor Authentication: enter PIV CAC visited', attributes)
with(:multi_factor_auth_enter_piv_cac, attributes)

expect(@irs_attempts_api_tracker).to receive(:mfa_login_rate_limited).
with(mfa_device_type: 'piv_cac')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
it 'tracks the analytic event of visited' do
stub_analytics
expect(@analytics).to receive(:track_event).
with('PIV CAC setup visited', {
with(:piv_cac_setup_visited, {
in_account_creation_flow: false,
enabled_mfa_methods_count: 1,
})
Expand Down
11 changes: 5 additions & 6 deletions spec/controllers/users/piv_cac_login_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
context 'without a token' do
before { get :new }

it 'tracks the piv_cac setup' do
it 'tracks the piv cac login' do
expect(@analytics).to have_received(:track_event).with(
'PIV CAC setup visited',
in_account_creation_flow: false,
:piv_cac_login_visited,
)
end

Expand All @@ -29,7 +28,7 @@
before { get :new, params: { token: token } }
it 'tracks the login attempt' do
expect(@analytics).to have_received(:track_event).with(
'PIV/CAC Login',
:piv_cac_login,
{
errors: {},
key_id: nil,
Expand Down Expand Up @@ -74,7 +73,7 @@

it 'tracks the login attempt' do
expect(@analytics).to have_received(:track_event).with(
'PIV/CAC Login',
:piv_cac_login,
{
errors: {
type: 'user.not_found',
Expand Down Expand Up @@ -113,7 +112,7 @@

it 'tracks the login attempt' do
expect(@analytics).to have_received(:track_event).with(
'PIV/CAC Login',
:piv_cac_login,
{
errors: {},
key_id: nil,
Expand Down

0 comments on commit f1462fc

Please sign in to comment.