Skip to content

Commit

Permalink
MAT-6819 fix auth guard test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
CeciliaLiu8 committed Apr 12, 2024
1 parent 091463f commit ae387dd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/auth/auth.guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('AuthGuard', () => {
expect(guard).toBeDefined();
});

it.skip('should have a fully mocked Execution Context with good auth token', async () => {
it('should have a fully mocked Execution Context with good auth token', async () => {
const mockExecutionContext = createMock<ExecutionContext>();
expect(mockExecutionContext.switchToHttp()).toBeDefined();

Expand All @@ -37,6 +37,18 @@ describe('AuthGuard', () => {
}),
});

jest.mock('@okta/jwt-verifier', () => {
return jest.fn().mockImplementation(() => ({
verifyAccessToken: () => ({
oktaToken: {
claims: {
sub: '[email protected]',
},
},
}),
}));
});

jest
.spyOn(mockExecutionContext.switchToHttp(), 'getRequest')
.mockImplementation(() => {
Expand All @@ -48,7 +60,7 @@ describe('AuthGuard', () => {
body: undefined,
headers: {
authorization:
'Bearer eyJraWQiOiJNNG9CMW9DSmthdC0tYTNENFFXUFA3RWZCbUl3NG9BV05KYWJxdEJhUnM4IiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULlBlN3hEc000MksyTnhHSW5vSWV1UEVEVmgxY3YydDVqQ1FKZmU1Sm9ZbkUiLCJpc3MiOiJodHRwczovL2Rldi0xODA5MjU3OC5va3RhLmNvbS9vYXV0aDIvZGVmYXVsdCIsImF1ZCI6ImFwaTovL2RlZmF1bHQiLCJpYXQiOjE3MTI4NjMyNzcsImV4cCI6MTcxMjg2Njg3NywiY2lkIjoiMG9hMmZxdGF6OTVmcUpxYmY1ZDciLCJ1aWQiOiIwMHUyNWh3c3AxUG04MW5jTzVkNyIsInNjcCI6WyJvcGVuaWQiLCJlbWFpbCIsInByb2ZpbGUiXSwiYXV0aF90aW1lIjoxNzEyODYzMjc2LCJzdW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ic6Tidq8WFgVVIBXTusKUHopaIP8z4gzapPo6hxLtJ6farGZcC1URHMk2o6DeyGuvO4i4y8vpowwqIHKLZ55P9kLgtbehC4LYPaRqoqWzngjF3Zy_4StmdxaFM2U_xulO5L3LysporElvVlU11HQAluXCff_PYYeV25u1Xbnp3_-W34Q',
},
} as unknown as Request;
});
Expand Down

0 comments on commit ae387dd

Please sign in to comment.