Skip to content

Commit

Permalink
fix: include spaceId as part of cacheKey (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
jensbodal authored Mar 25, 2022
1 parent dffae49 commit 92fc4c5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/keys/get-management-token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('getManagementToken', () => {
assert.strictEqual(result, mockToken)

// Overwrite TTL expiry to 5ms
const cacheKey = APP_ID + ENVIRONMENT_ID + PRIVATE_KEY.slice(32, 132)
const cacheKey = APP_ID + SPACE_ID + ENVIRONMENT_ID + PRIVATE_KEY.slice(32, 132)
cache.set(cacheKey, result, 0.005)

// Sleep 10ms
Expand Down
3 changes: 2 additions & 1 deletion src/keys/get-management-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const createGetManagementToken = (log: Logger, http: HttpClient, cache: N
opts.reuseToken = true
}

const cacheKey = opts.appInstallationId + opts.environmentId + privateKey.slice(32, 132)
const cacheKey =
opts.appInstallationId + opts.spaceId + opts.environmentId + privateKey.slice(32, 132)
if (opts.reuseToken) {
const existing = cache.get(cacheKey) as string
if (existing) {
Expand Down

0 comments on commit 92fc4c5

Please sign in to comment.