From 656e738af9abbbeaf426c279c4fc292bf518b563 Mon Sep 17 00:00:00 2001 From: Konstantin Wohlwend Date: Wed, 3 Sep 2025 15:30:37 -0700 Subject: [PATCH] More --- apps/e2e/tests/backend/backend-helpers.ts | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/apps/e2e/tests/backend/backend-helpers.ts b/apps/e2e/tests/backend/backend-helpers.ts index b94e63bec..066fac459 100644 --- a/apps/e2e/tests/backend/backend-helpers.ts +++ b/apps/e2e/tests/backend/backend-helpers.ts @@ -108,12 +108,17 @@ export async function niceBackendFetch(url: string | URL, options?: Omit, + userAuth?: { + accessToken?: string, + refreshToken?: string, + }, }): Promise { - const { body, headers, accessType, ...otherOptions } = options ?? {}; + const { body, headers, accessType, userAuth: userAuthOverride, ...otherOptions } = options ?? {}; if (typeof body === "object") { expectSnakeCase(body, "req.body"); } - const { projectKeys, userAuth } = backendContext.value; + const projectKeys = backendContext.value.projectKeys; + const userAuth = userAuthOverride ?? backendContext.value.userAuth; const fullUrl = new URL(url, STACK_BACKEND_BASE_URL); if (fullUrl.origin !== new URL(STACK_BACKEND_BASE_URL).origin) throw new StackAssertionError(`Invalid niceBackendFetch origin: ${fullUrl.origin}`); if (fullUrl.protocol !== new URL(STACK_BACKEND_BASE_URL).protocol) throw new StackAssertionError(`Invalid niceBackendFetch protocol: ${fullUrl.protocol}`); @@ -207,9 +212,24 @@ export namespace Auth { const response = await niceBackendFetch("/api/v1/auth/sessions/current/refresh", { method: "POST", accessType: "client", - headers: { "x-stack-access-token": "" }, + userAuth: { + refreshToken: backendContext.value.userAuth?.refreshToken, + }, }); - expect(response).toMatchInlineSnapshot(); + expect(response).toMatchInlineSnapshot(` + NiceResponse { + "status": 401, + "body": { + "code": "ADMIN_ACCESS_TOKEN_EXPIRED", + "details": { "expired_at_millis": 1756938402000 }, + "error": "Admin access token has expired. Please refresh it and try again. (The access token expired at 2025-09-03T22:26:42.000Z.)", + }, + "headers": Headers { + "x-stack-known-error": "ADMIN_ACCESS_TOKEN_EXPIRED", +