Skip to content

Commit ee7b918

Browse files
kapelamekapelame
authored andcommitted
test(auth): align refresh mock with new response shape
The 'returns a fresh token when refresh succeeds' test mock and fetch interceptor predated the OAuth response-shape changes: - mock body: add status:'success', rename expires_in -> expired_in - fetch interceptor: match 'oauth2/token' (was 'oauth/token')
1 parent 2be7c33 commit ee7b918

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

test/auth/timeout-fix.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe('refreshAccessToken: timeout and error handling', () => {
127127
// eslint-disable-next-line @typescript-eslint/no-explicit-any
128128
(globalThis as any).fetch = async (input: RequestInfo | URL, init?: RequestInit) => {
129129
const url = typeof input === 'string' ? input : input.toString();
130-
if (url.includes('oauth/token')) {
130+
if (url.includes('oauth2/token')) {
131131
return origFetch(`${server.url}/v1/oauth/token`, init);
132132
}
133133
return origFetch(input, init);
@@ -147,9 +147,10 @@ describe('refreshAccessToken: timeout and error handling', () => {
147147
routes: {
148148
'/v1/oauth/token': () =>
149149
jsonResponse({
150+
status: 'success',
150151
access_token: 'new-access-token',
151152
refresh_token: 'new-refresh-token',
152-
expires_in: 3600,
153+
expired_in: 3600,
153154
token_type: 'Bearer',
154155
}),
155156
},
@@ -160,7 +161,7 @@ describe('refreshAccessToken: timeout and error handling', () => {
160161
// eslint-disable-next-line @typescript-eslint/no-explicit-any
161162
(globalThis as any).fetch = async (input: RequestInfo | URL, init?: RequestInit) => {
162163
const url = typeof input === 'string' ? input : input.toString();
163-
if (url.includes('oauth/token')) {
164+
if (url.includes('oauth2/token')) {
164165
return origFetch(`${server.url}/v1/oauth/token`, init);
165166
}
166167
return origFetch(input, init);
@@ -169,7 +170,7 @@ describe('refreshAccessToken: timeout and error handling', () => {
169170
try {
170171
const tokens = await mod.refreshAccessToken('valid-refresh-token');
171172
expect(tokens.access_token).toBe('new-access-token');
172-
expect(tokens.expires_in).toBe(3600);
173+
expect(tokens.expired_in).toBe(3600);
173174
} finally {
174175
globalThis.fetch = origFetch;
175176
}

0 commit comments

Comments
 (0)