Skip to content
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
4 changes: 2 additions & 2 deletions app/controllers/openid_connect/logout_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def handle_successful_logout_request(result, redirect_uri)
def handle_logout(result, redirect_uri)
analytics.logout_initiated(**to_event(result))

sign_out

redirect_user(redirect_uri, @logout_form.service_provider&.issuer, current_user&.uuid)

sign_out
end

# Convert FormResponse into loggable analytics event
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/delete_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def delete
send_push_notifications
notify_user_via_email_of_deletion
notify_user_via_sms_of_deletion
analytics.account_delete_submitted(success: true)
delete_user
sign_out
flash[:success] = t('devise.registrations.destroyed')
analytics.account_delete_submitted(success: true)
redirect_to root_url
end

Expand Down
18 changes: 8 additions & 10 deletions spec/controllers/users/delete_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@
end

it 'logs a failed submit' do
stub_analytics
stub_signed_in_user

expect(@analytics).to receive(:track_event).
with('Account Delete submitted', success: false)
user = stub_signed_in_user
stub_analytics(user:)

delete

expect(@analytics).to have_logged_event('Account Delete submitted', success: false)
end
end

Expand Down Expand Up @@ -82,13 +81,12 @@
end

it 'logs a succesful submit' do
stub_analytics
stub_signed_in_user

expect(@analytics).to receive(:track_event).
with('Account Delete submitted', success: true)
user = stub_signed_in_user
stub_analytics(user:)

delete

expect(@analytics).to have_logged_event('Account Delete submitted', success: true)
end

it 'does not delete identities to prevent uuid reuse' do
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/users/piv_cac_login_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

RSpec.describe Users::PivCacLoginController do
describe 'GET new' do
let(:user) {}

before do
stub_analytics
stub_analytics(user:)
end

context 'without a token' do
Expand Down Expand Up @@ -47,7 +49,6 @@
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 @@ -68,7 +69,6 @@
controller.session[:sp] = sp_session

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

context 'without a valid user' do
Expand Down
4 changes: 2 additions & 2 deletions spec/support/analytics_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ def stub_analytics(user: nil)
analytics = FakeAnalytics.new

if user
allow(controller).to receive(:analytics) do
expect(controller.analytics_user).to eq(user)
allow(controller).to receive(:analytics).and_wrap_original do |original|
expect(original.call.user).to eq(user)
analytics
end
else
Expand Down
3 changes: 3 additions & 0 deletions spec/support/controller_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def stub_sign_in(user = build(:user, password: VALID_PASSWORD))
allow(controller).to receive(:user_session).and_return({}.with_indifferent_access)
controller.auth_methods_session.authenticate!(TwoFactorAuthenticatable::AuthMethod::SMS)
allow(controller).to receive(:current_user).and_return(user)
allow(controller).to receive(:sign_out) do
allow(controller).to receive(:current_user).and_return(nil)
end
Comment thread
aduth marked this conversation as resolved.
allow(controller).to receive(:confirm_two_factor_authenticated).and_return(true)
allow(controller).to receive(:user_fully_authenticated?).and_return(true)
allow(controller).to receive(:remember_device_expired_for_sp?).and_return(false)
Expand Down