Skip to content
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

LG-12706: Include user_id in piv_cac_login event #10584

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -46,14 +46,14 @@ def render_prompt

def process_piv_cac_login
result = piv_cac_login_form.submit
analytics.piv_cac_login(**result.to_h)
clear_piv_cac_information
clear_piv_cac_nonce
if result.success?
process_valid_submission
else
process_invalid_submission
end
analytics.piv_cac_login(**result.to_h)
end

def piv_cac_login_form
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/users/piv_cac_login_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
end

context 'with a valid token' do
let(:user) {}
let(:service_provider) { create(:service_provider) }
let(:sp_session) { { ial: 1, issuer: service_provider.issuer, vtr: vtr } }
let(:nonce) { SecureRandom.base64(20) }
Expand All @@ -65,6 +66,7 @@
subject.session[:sp] = sp_session

allow(PivCacService).to receive(:decode_token).with(token) { data }
stub_analytics(user:)
get :new, params: { token: token }
end

Expand Down
16 changes: 13 additions & 3 deletions spec/support/analytics_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
module AnalyticsHelper
def stub_analytics
controller.analytics = FakeAnalytics.new
@analytics = controller.analytics
def stub_analytics(user: nil)
analytics = FakeAnalytics.new

if user
allow(controller).to receive(:analytics) do
expect(controller.analytics_user).to eq(user)
analytics
end
else
controller.analytics = analytics
end

@analytics = analytics
end

def unstub_analytics
Expand Down