-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(authentication-jwt): implementation of refresh token
feature refresh token implementation through Service chore(authentication-jwt): readme updated readme.md to use refresh token and extra configurations chore(context): readmemd refactor Apply suggestions from code review Co-authored-by: Diana Lau <[email protected]> feat: implemented awthentication-jwt refreshtoken services Signed-off-by: Madaky <[email protected]>
- Loading branch information
Showing
16 changed files
with
532 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,8 @@ describe('jwt authentication', () => { | |
let client: Client; | ||
let token: string; | ||
let userRepo: UserRepository; | ||
|
||
let refreshToken: string; | ||
let tokenAuth: string; | ||
before(givenRunningApplication); | ||
before(() => { | ||
client = createRestAppClient(app); | ||
|
@@ -50,6 +51,29 @@ describe('jwt authentication', () => { | |
expect(spec.components?.securitySchemes).to.eql(SECURITY_SCHEME_SPEC); | ||
}); | ||
|
||
it(`user login and token granted successfully`, async () => { | ||
const credentials = {email: '[email protected]', password: 'opensesame'}; | ||
const res = await client | ||
.post('/users/refresh-login') | ||
.send(credentials) | ||
.expect(200); | ||
refreshToken = res.body.refreshToken; | ||
}); | ||
|
||
it(`user sends refresh token and new access token issued`, async () => { | ||
const tokenArg = {refreshToken: refreshToken}; | ||
const res = await client.post('/refresh/').send(tokenArg).expect(200); | ||
tokenAuth = res.body.accessToken; | ||
}); | ||
|
||
it('whoAmI returns the login user id using token generated from refresh', async () => { | ||
const res = await client | ||
.get('/whoAmI') | ||
.set('Authorization', 'Bearer ' + tokenAuth) | ||
.expect(200); | ||
expect(res.text).to.equal('f48b7167-8d95-451c-bbfc-8a12cd49e763'); | ||
}); | ||
|
||
/* | ||
============================================================================ | ||
TEST HELPERS | ||
|
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
Oops, something went wrong.