-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deletion): revoke fxa tokens when deleting accounts (#897)
* feat(deletion): revoke fxa tokens when deleting accounts This data was deleted before on the Pocket side, but now it will remove Pocket from integrations on the Mozilla account page. [POCKET-9990] * fix(test): add reference to user_firefox_account for test seeds * chore: fix a lost import and nock
- Loading branch information
1 parent
8980227
commit c943522
Showing
15 changed files
with
282 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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
52 changes: 52 additions & 0 deletions
52
servers/account-data-deleter/src/dataService/FxaRevoker.spec.ts
This file contains 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,52 @@ | ||
import { FxaRevoker } from './FxaRevoker'; | ||
|
||
describe('FxARevoker', () => { | ||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
describe('with an access token', () => { | ||
beforeEach(() => { | ||
jest | ||
.spyOn(FxaRevoker.prototype, 'fetchAccessToken') | ||
.mockResolvedValue('accessme123'); | ||
}); | ||
it('returns false if revoking throws an error', async () => { | ||
jest | ||
.spyOn(FxaRevoker.prototype, 'requestRevokeToken') | ||
.mockRejectedValueOnce(new Error('error fetching')); | ||
const res = await new FxaRevoker('abc123').revokeToken(); | ||
expect(res).toBeFalse(); | ||
}); | ||
it('returns false if revoking response is not ok', async () => { | ||
jest | ||
.spyOn(FxaRevoker.prototype, 'requestRevokeToken') | ||
.mockResolvedValueOnce(new Response(null, { status: 500 })); | ||
const res = await new FxaRevoker('abc123').revokeToken(); | ||
expect(res).toBeFalse(); | ||
}); | ||
it('returns false if db delete method throws error', async () => { | ||
jest | ||
.spyOn(FxaRevoker.prototype, 'deleteAuthRecord') | ||
.mockRejectedValueOnce(new Error('error deleting')); | ||
const res = await new FxaRevoker('abc123').revokeToken(); | ||
expect(res).toBeFalse(); | ||
}); | ||
it('returns true if process does not error', async () => { | ||
jest | ||
.spyOn(FxaRevoker.prototype, 'requestRevokeToken') | ||
.mockResolvedValueOnce(new Response(null, { status: 200 })); | ||
jest | ||
.spyOn(FxaRevoker.prototype, 'deleteAuthRecord') | ||
.mockResolvedValueOnce(1); | ||
const res = await new FxaRevoker('abc123').revokeToken(); | ||
expect(res).toBeTrue(); | ||
}); | ||
}); | ||
it('returns true if no FxA tokens exist', async () => { | ||
jest | ||
.spyOn(FxaRevoker.prototype, 'fetchAccessToken') | ||
.mockResolvedValueOnce(undefined); | ||
const res = await new FxaRevoker('abc123').revokeToken(); | ||
expect(res).toBeTrue(); | ||
}); | ||
}); |
Oops, something went wrong.