Fix passing expiresInHours query parameter

This commit is contained in:
Alexis Tual 2024-09-11 09:32:04 +02:00 committed by Daz DeBoer
parent a122cf5aa7
commit 765a73447c
2 changed files with 11 additions and 1 deletions

View file

@ -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',

View file

@ -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"}]})
})
})