Skip to content

Commit f8533fa

Browse files
committed
test(console): give the Response doubles behind the Setup doors a headers member
The authenticated fetch reads the response's headers for a rotated session token, as a real Response always has them; the doubles of the settings, connector and Packages page tests carried only ok, status and json. The changeset no longer names the held package list read. Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
1 parent b76cf7e commit f8533fa

25 files changed

Lines changed: 39 additions & 19 deletions

‎.changeset/36981-setup-doors-bearer.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ Metadata-protocol: none
1010

1111
These Setup surfaces called their endpoints with the session cookie only (`credentials: 'include'`), while the rest of the console sends the stored bearer token through its authenticated fetch. A session held by its bearer token alone (a second local runtime on the same host replaced the cookie, the cookie was blocked as a third-party cookie, or the cookie jar was cleared) therefore worked everywhere except here, where each page printed the server's `401` instead: "Authentication is required to access this endpoint.", a bare `UNAUTHENTICATED`, or, on the Audit Log, the raw response body followed by "No audit entries".
1212

13-
They now go through `createAuthenticatedFetch` from `@object-ui/auth`, the path every other console request takes: every `/api/settings` call and the judged client-address read of the Authentication and Access policy pages, the Audit Log read, the connector credential and connection doors, the Packages list (the Installed Apps address included) and the session's held package list, and this runtime's own install ledger (`/api/v1/marketplace/install-local*`) and cloud-connection reads (`installed`, `org-packages`). The session cookie still rides along (`credentials: 'include'` is unchanged), so a cookie session behaves exactly as before, and a `401` now reaches the console's session-ended check as it does on every other page. Nothing changes in what the server accepts.
13+
They now go through `createAuthenticatedFetch` from `@object-ui/auth`, the path every other console request takes: every `/api/settings` call and the judged client-address read of the Authentication and Access policy pages, the Audit Log read, the connector credential and connection doors, the Packages list (the Installed Apps address included), and this runtime's own install ledger (`/api/v1/marketplace/install-local*`) and cloud-connection reads (`installed`, `org-packages`). The session cookie still rides along (`credentials: 'include'` is unchanged), so a cookie session behaves exactly as before, and a `401` now reaches the console's session-ended check as it does on every other page. Nothing changes in what the server accepts.
1414

1515
A failed Audit Log read no longer draws the "No audit entries" empty state, and its alert shows the refusal's own sentence when the response envelope carries one, or "Failed to load audit log" otherwise, never the raw response body.

‎ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ let extraManifests: unknown[] = [];
158158
let aiPayload: Record<string, unknown> | null = null;
159159

160160
function ok(data: unknown) {
161-
return { ok: true, status: 200, statusText: 'OK', json: async () => ({ success: true, data }) } as unknown as Response;
161+
return { ok: true, status: 200, statusText: 'OK', headers: new Headers(), json: async () => ({ success: true, data }) } as unknown as Response;
162162
}
163163

164164
const fetchMock = vi.fn();
@@ -177,14 +177,14 @@ function routeFetch() {
177177
}
178178
if (url === '/api/settings/localization' && method === 'PUT') {
179179
if (putRefusal) {
180-
return { ok: false, status: 400, statusText: 'Bad Request', json: async () => putRefusal } as unknown as Response;
180+
return { ok: false, status: 400, statusText: 'Bad Request', headers: new Headers(), json: async () => putRefusal } as unknown as Response;
181181
}
182182
const body = JSON.parse(String(init?.body)) as Record<string, unknown>;
183183
const written = Object.fromEntries(Object.entries(body).map(([k, v]) => [k, resolved(v, 'tenant')]));
184184
localizationValues = { ...localizationValues, ...written };
185185
return ok({ values: written });
186186
}
187-
return { ok: false, status: 404, statusText: 'Not Found', json: async () => ({}) } as unknown as Response;
187+
return { ok: false, status: 404, statusText: 'Not Found', headers: new Headers(), json: async () => ({}) } as unknown as Response;
188188
});
189189
}
190190

‎ui/apps/console/src/pages/settings/__tests__/SettingsField.actionRowOneLabel-12610.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ afterEach(() => {
5252
});
5353

5454
function ok(body: unknown): Response {
55-
return { ok: true, status: 200, statusText: 'OK', json: async () => body } as unknown as Response;
55+
return { ok: true, status: 200, statusText: 'OK', headers: new Headers(), json: async () => body } as unknown as Response;
5656
}
5757

5858
function withI18n(ui: ReactElement) {

‎ui/apps/console/src/pages/settings/__tests__/SettingsHub.adminManaged-29085.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function serveManifests(manifests: unknown[]) {
4848
ok: true,
4949
status: 200,
5050
statusText: 'OK',
51+
headers: new Headers(),
5152
json: async () => ({ success: true, data: { manifests } }),
5253
})),
5354
);

‎ui/apps/console/src/pages/settings/__tests__/SettingsHub.pageHeader-12553.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ beforeEach(() => {
4242
ok: true,
4343
status: 200,
4444
statusText: 'OK',
45+
headers: new Headers(),
4546
json: async () => ({ success: true, data: { manifests: MANIFESTS } }),
4647
})),
4748
);

‎ui/apps/console/src/pages/settings/__tests__/SettingsIcons.knownName-11679.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ afterEach(() => {
6262
});
6363

6464
function ok(body: unknown): Response {
65-
return { ok: true, status: 200, statusText: 'OK', json: async () => body } as unknown as Response;
65+
return { ok: true, status: 200, statusText: 'OK', headers: new Headers(), json: async () => body } as unknown as Response;
6666
}
6767

6868
/**

‎ui/apps/console/src/pages/settings/__tests__/SettingsView.clearBeneathPin-30665.test.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const REREAD_IP_RANGES = pinned('', 'OS_AUTH_ALLOWED_IP_RANGES', [
105105
const fetchMock = vi.fn();
106106

107107
function ok(body: unknown): Response {
108-
return { ok: true, status: 200, statusText: 'OK', json: async () => body } as unknown as Response;
108+
return { ok: true, status: 200, statusText: 'OK', headers: new Headers(), json: async () => body } as unknown as Response;
109109
}
110110

111111
/** GET answers the page; a PUT answers `putValues` and the next GET reads `rereadValues`. */
@@ -256,6 +256,7 @@ describe('clear the value saved beneath an env pin (objectstack#30665)', () => {
256256
ok: false,
257257
status: 409,
258258
statusText: 'Conflict',
259+
headers: new Headers(),
259260
json: async () => ({
260261
success: false,
261262
error: {

‎ui/apps/console/src/pages/settings/__tests__/SettingsView.clientAddress-30313.test.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ const LOCALIZATION = {
6969
};
7070

7171
const ok = (data: unknown) =>
72-
({ ok: true, status: 200, statusText: 'OK', json: async () => ({ success: true, data }) }) as unknown as Response;
72+
({ ok: true, status: 200, statusText: 'OK', headers: new Headers(), json: async () => ({ success: true, data }) }) as unknown as Response;
7373

7474
const refused = (status: number, code: string) =>
7575
({
7676
ok: false,
7777
status,
7878
statusText: status === 401 ? 'Unauthorized' : 'Forbidden',
79+
headers: new Headers(),
7980
json: async () => ({ success: false, error: { code, message: 'Platform admin required.' } }),
8081
}) as unknown as Response;
8182

@@ -192,6 +193,7 @@ describe('SettingsView — Allowed IP ranges shows the address the server judges
192193
ok: false,
193194
status: 400,
194195
statusText: 'Bad Request',
196+
headers: new Headers(),
195197
json: async () => ({
196198
success: false,
197199
error: {
@@ -319,6 +321,7 @@ describe('SettingsView — Access policy shows the address the server judges (ob
319321
ok: false,
320322
status: 404,
321323
statusText: 'Not Found',
324+
headers: new Headers(),
322325
json: async () => ({ success: false, error: { code: 'NOT_FOUND', message: 'Not found.' } }),
323326
}) as unknown as Response,
324327
],

‎ui/apps/console/src/pages/settings/__tests__/SettingsView.confirmOff-30500.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function payloadOf(passwordOn: boolean, extra: Partial<Spec> = {}) {
7979
const fetchMock = vi.fn();
8080

8181
function ok(body: unknown): Response {
82-
return { ok: true, status: 200, statusText: 'OK', json: async () => body } as unknown as Response;
82+
return { ok: true, status: 200, statusText: 'OK', headers: new Headers(), json: async () => body } as unknown as Response;
8383
}
8484

8585
/** GET answers the page; PUT answers the values it was sent. */

‎ui/apps/console/src/pages/settings/__tests__/SettingsView.envelope.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ afterEach(() => {
7878
});
7979

8080
function ok(body: unknown): Response {
81-
return { ok: true, status: 200, statusText: 'OK', json: async () => body } as unknown as Response;
81+
return { ok: true, status: 200, statusText: 'OK', headers: new Headers(), json: async () => body } as unknown as Response;
8282
}
8383

8484
function renderView() {

0 commit comments

Comments
 (0)