-
Notifications
You must be signed in to change notification settings - Fork 8
Frontend/revoke tokens #1790
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
Merged
isabeleliassen
merged 6 commits into
csg-org:main
from
InspiringApps:frontend/revoke-token
Aug 7, 2026
Merged
Frontend/revoke tokens #1790
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
85fa1e4
Update postcss dep
jsandoval81 ef2b43e
Revoke tokens
jsandoval81 b50f1b8
Merge branch 'main' into frontend/revoke-token
jsandoval81 1ac849c
Revoke retry + logging
jsandoval81 a892441
Test improvement
jsandoval81 01c0b7b
PR review feedback
jsandoval81 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| // | ||
| // Logout.spec.ts | ||
| // CompactConnect | ||
| // | ||
| // Created by InspiringApps on 7/29/2026. | ||
| // | ||
|
|
||
| import sinon from 'sinon'; | ||
| import axios from 'axios'; | ||
| import { mountShallow } from '@tests/helpers/setup'; | ||
| import Logout from '@pages/Logout/Logout.vue'; | ||
| import { authStorage, tokens, AuthTypes } from '@utils/auth'; | ||
| import { config as envConfig } from '@plugins/EnvConfig/envConfig.plugin'; | ||
|
|
||
| const chaiMatchPattern = require('chai-match-pattern'); | ||
| const chai = require('chai').use(chaiMatchPattern); | ||
|
|
||
| const { expect } = chai; | ||
|
|
||
| describe('Logout page', async () => { | ||
| let logoutStub; | ||
| let originalCognitoConfig; | ||
|
|
||
| beforeEach(() => { | ||
| // Prevent created() from running real logout (clears shared store / redirects) | ||
| logoutStub = sinon.stub(Logout.methods, 'logout').resolves(); | ||
|
|
||
| originalCognitoConfig = { | ||
| cognitoClientIdStaff: envConfig.cognitoClientIdStaff, | ||
| cognitoAuthDomainStaff: envConfig.cognitoAuthDomainStaff, | ||
| }; | ||
| envConfig.cognitoClientIdStaff = 'test-staff-client-id'; | ||
| envConfig.cognitoAuthDomainStaff = 'https://staff-auth.test.example.com'; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| logoutStub.restore(); | ||
| envConfig.cognitoClientIdStaff = originalCognitoConfig.cognitoClientIdStaff; | ||
| envConfig.cognitoAuthDomainStaff = originalCognitoConfig.cognitoAuthDomainStaff; | ||
| authStorage.removeItem(tokens.staff.REFRESH_TOKEN); | ||
| }); | ||
|
|
||
| it('should mount the page component', async () => { | ||
| const wrapper = await mountShallow(Logout); | ||
|
|
||
| expect(wrapper.exists()).to.equal(true); | ||
| expect(wrapper.findComponent(Logout).exists()).to.equal(true); | ||
| expect(logoutStub.calledOnce).to.equal(true); | ||
| }); | ||
|
|
||
| it('should successfully revoke tokens before logoutRequest in logoutChecklist', async () => { | ||
| const wrapper = await mountShallow(Logout); | ||
| const component = wrapper.vm; | ||
| const revokeStub = sinon.stub(component, 'revokeTokens').resolves(); | ||
| const dispatchSpy = sinon.spy(component.$store, 'dispatch'); | ||
|
|
||
| await component.logoutChecklist(false); | ||
|
|
||
| expect(revokeStub.calledOnce).to.equal(true); | ||
| expect(revokeStub.firstCall.args[0]).to.equal(AuthTypes.STAFF); | ||
| expect(dispatchSpy.calledWith('user/logoutRequest', AuthTypes.STAFF)).to.equal(true); | ||
| expect(revokeStub.calledBefore( | ||
| dispatchSpy.withArgs('user/logoutRequest', AuthTypes.STAFF) | ||
| )).to.equal(true); | ||
|
|
||
| revokeStub.restore(); | ||
| dispatchSpy.restore(); | ||
| }); | ||
|
|
||
| it('should successfully revoke licensee tokens when logged in as licensee only', async () => { | ||
| const wrapper = await mountShallow(Logout); | ||
| const component = wrapper.vm; | ||
| const revokeStub = sinon.stub(component, 'revokeTokens').resolves(); | ||
|
|
||
| await component.logoutChecklist(true); | ||
|
|
||
| expect(revokeStub.firstCall.args[0]).to.equal(AuthTypes.LICENSEE); | ||
|
|
||
| revokeStub.restore(); | ||
| }); | ||
|
|
||
| it('should successfully swallow revoke errors and log to analytics', async () => { | ||
| const wrapper = await mountShallow(Logout); | ||
| const component = wrapper.vm; | ||
| const axiosPostStub = sinon.stub(axios, 'post').rejects(new Error('network')); | ||
| const logEventStub = sinon.stub(component.$analytics, 'logEvent').returns(undefined); | ||
|
jlkravitz marked this conversation as resolved.
|
||
| let didThrow = false; | ||
|
|
||
| authStorage.setItem(tokens.staff.REFRESH_TOKEN, 'staff-refresh-token'); | ||
|
|
||
| await component.revokeTokens(AuthTypes.STAFF).catch(() => { | ||
| didThrow = true; | ||
| }); | ||
|
|
||
| expect(didThrow).to.equal(false); | ||
| expect(logEventStub.calledOnce).to.equal(true); | ||
| expect(logEventStub.firstCall.args[0]).to.equal('cognito_token_revoke_failed'); // https://console.statsig.com/3KcYv8LC2YCc1vsTkVi3Fb/metrics/metrics_catalog/Cognito%20Token%20Revocation%20Failure/event_count_custom?unitType=overall | ||
| expect(logEventStub.firstCall.args[1]).to.equal(1); | ||
| expect(logEventStub.firstCall.args[2]).to.matchPattern({ | ||
| authType: AuthTypes.STAFF, | ||
| appMode: component.appMode, | ||
| appGroupMode: component.appGroupMode, | ||
| errorName: 'Error', | ||
| errorCode: undefined, | ||
| httpStatus: undefined, | ||
| }); | ||
|
|
||
| axiosPostStub.restore(); | ||
| logEventStub.restore(); | ||
| }); | ||
| }); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.