Skip to content

Commit

Permalink
Fix passing expiresInHours query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
alextu authored and bigdaz committed Sep 13, 2024
1 parent a122cf5 commit 765a734
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sources/src/develocity/short-lived-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ShortLivedTokenClient {
retryInterval = 1000

async fetchToken(serverUrl: string, accessKey: HostnameAccessKey, expiry: string): Promise<HostnameAccessKey> {
const queryParams = expiry ? `?expiresInHours${expiry}` : ''
const queryParams = expiry ? `?expiresInHours=${expiry}` : ''
const sanitizedServerUrl = !serverUrl.endsWith('/') ? `${serverUrl}/` : serverUrl
const headers = {
'Content-Type': 'application/json',
Expand Down
10 changes: 10 additions & 0 deletions sources/test/jest/short-lived-token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,14 @@ describe('short lived tokens', () => {
.resolves
.toBeNull()
})

it('get short lived token with custom expiry', async () => {
nock('https://dev')
.post('/api/auth/token?expiresInHours=4')
.reply(200, 'token')
expect.assertions(1)
await expect(getToken('dev=key1', '4'))
.resolves
.toEqual({"keys": [{"hostname": "dev", "key": "token"}]})
})
})

0 comments on commit 765a734

Please # to comment.