Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

environmentHttpAuth.test.ts

606 lines21.7 KB

1import { describe, expect, it } from "@effect/vitest";
2import {
3 EnvironmentId,
4 ORCHESTRATION_PROTOCOL_HEADER,
5 ORCHESTRATION_PROTOCOL_VERSION_TEXT,
6 ProjectId,
7 ThreadId,
8 type AuthSessionState,
9 type OrchestrationV2ShellSnapshot,
10 OrchestrationV2ThreadDetailSnapshot,
11 OrchestrationV2ThreadBoundedSnapshot,
12 OrchestrationV2ThreadTranscript,
13 type OrchestrationV2ThreadHistoryPage,
14} from "@t3tools/contracts";
15import * as Effect from "effect/Effect";
16import * as Layer from "effect/Layer";
17import * as Option from "effect/Option";
18import * as Schema from "effect/Schema";
19import type { HttpClient } from "effect/http";
20​
21import * as RemoteEnvironmentAuthorization from "../authorization/service.ts";
22import {
23 ConnectionTransientError,
24 RelayConnectionTarget,
25 type PreparedConnection,
26 type PreparedHttpAuthorization,
27} from "../connection/model.ts";
28import * as ManagedRelay from "../relay/managedRelay.ts";
29import { type RemoteEnvironmentRequestError } from "../rpc/http.ts";
30import * as RpcHttp from "../rpc/http.ts";
31import * as PullRequestDiffLoader from "./pullRequestDiffHttp.ts";
32import { fetchEnvironmentSessionState } from "./session.ts";
33import { fetchEnvironmentShellSnapshot } from "./shellSnapshotHttp.ts";
34import * as ThreadSnapshotLoader from "./threadSnapshotHttp.ts";
35import { fetchEnvironmentThreadTranscript } from "./threadTranscriptHttp.ts";
36import { fetchEnvironmentBoundedThreadSnapshot } from "./boundedThreadSnapshotHttp.ts";
37import * as BoundedThreadSnapshotHttp from "./boundedThreadSnapshotHttp.ts";
38import { fetchEnvironmentThreadHistoryPage } from "./threadHistoryHttp.ts";
39import { v2Projection } from "./orchestrationV2TestFixtures.ts";
40​
41const encodeThreadSnapshot = Schema.encodeSync(OrchestrationV2ThreadDetailSnapshot);
42const encodeBoundedSnapshot = Schema.encodeSync(OrchestrationV2ThreadBoundedSnapshot);
43const encodeThreadTranscript = Schema.encodeSync(OrchestrationV2ThreadTranscript);
44​
45const TARGET = new RelayConnectionTarget({
46 environmentId: EnvironmentId.make("environment-1"),
47 label: "Remote environment",
48});
49const PREPARED: PreparedConnection = {
50 environmentId: TARGET.environmentId,
51 label: TARGET.label,
52 httpBaseUrl: "https://previous.example.test",
53 socketUrl: "wss://previous.example.test/ws",
54 httpAuthorization: { _tag: "Dpop", accessToken: "expired-token", expiresAtEpochMs: 0 },
55 target: TARGET,
56};
57const CURRENT_ORIGIN = "https://current.example.test";
58const RENEWED_ORIGIN = "https://renewed.example.test";
59const DIFF = {
60 projectId: ProjectId.make("project-1"),
61 repository: "owner/repository",
62 number: 42,
63};
64const DIFF_RESULT = { patch: "diff --git a/file.ts b/file.ts", truncated: false, nextCursor: null };
65const AUTH = {
66 policy: "remote-reachable",
67 bootstrapMethods: ["one-time-token"],
68 sessionMethods: ["dpop-access-token"],
69 sessionCookieName: "t3_session",
70} satisfies AuthSessionState["auth"];
71const SESSION = {
72 authenticated: true,
73 auth: AUTH,
74 scopes: ["orchestration:read", "orchestration:operate"],
75 sessionMethod: "dpop-access-token",
76} satisfies AuthSessionState;
77const UNAUTHENTICATED_SESSION = { authenticated: false, auth: AUTH } satisfies AuthSessionState;
78const SHELL = {
79 schemaVersion: 1,
80 snapshotSequence: 1,
81 projects: [],
82 threads: [],
83 archivedThreads: [],
84} satisfies OrchestrationV2ShellSnapshot;
85const THREAD = {
86 snapshotSequence: 2,
87 projection: v2Projection,
88} satisfies OrchestrationV2ThreadDetailSnapshot;
89const TRANSCRIPT = {
90 threadId: v2Projection.thread.id,
91 title: v2Projection.thread.title,
92 updatedAt: v2Projection.updatedAt,
93 items: v2Projection.visibleTurnItems,
94} satisfies OrchestrationV2ThreadTranscript;
95const BOUNDED_THREAD = {
96 ...THREAD,
97 historyCursor: "older-page",
98 hasMoreHistory: true,
99 latestLocalTurnOrdinal: 3,
100} satisfies OrchestrationV2ThreadBoundedSnapshot;
101const THREAD_HISTORY = {
102 snapshotSequence: 2,
103 items: [],
104 nextCursor: null,
105 hasMoreHistory: false,
106} satisfies OrchestrationV2ThreadHistoryPage;
107​
108function credentialRejectedResponse(reason = "invalid_credential") {
109 return Response.json(
110 {
111 _tag: "EnvironmentAuthInvalidError",
112 code: "auth_invalid",
113 reason,
114 traceId: "trace-rejected",
115 },
116 { status: 401 },
117 );
119​
120function makeHarness(reply: (requestNumber: number) => Response | Promise<Response>) {
121 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
122 const authorizations: Array<
123 Parameters<
124 RemoteEnvironmentAuthorization.RemoteEnvironmentAuthorization["Service"]["authorizeDpopHttp"]
125 >[0]
126 > = [];
127 const proofs: Array<ManagedRelay.ManagedRelayDpopProofInput> = [];
128 const remoteAuthorization = RemoteEnvironmentAuthorization.RemoteEnvironmentAuthorization.of({
129 authorizeBearer: () => Effect.die("Unexpected bearer connection preparation."),
130 authorizeDpop: () => Effect.die("HTTP requests must not prepare a WebSocket connection."),
131 authorizeDpopHttp: (input) =>
132 Effect.sync(() => {
133 authorizations.push(input);
134 const rejected = input.rejectedAccessToken !== undefined;
135 return {
136 environmentId: TARGET.environmentId,
137 label: TARGET.label,
138 httpBaseUrl: rejected ? RENEWED_ORIGIN : CURRENT_ORIGIN,
139 httpAuthorization: {
140 _tag: "Dpop" as const,
141 accessToken: rejected ? "renewed-token" : "current-token",
142 expiresAtEpochMs: 3_600_000,
143 },
144 };
145 }),
146 });
147 const signer = ManagedRelay.ManagedRelayDpopSigner.of({
148 thumbprint: Effect.succeed("test-thumbprint"),
149 createProof: (input) =>
150 Effect.sync(() => {
151 proofs.push(input);
152 return `proof-${proofs.length}`;
153 }),
154 });
155 const fetchFn: typeof fetch = async (request, init) => {
156 calls.push({ url: String(request), init: init ?? {} });
157 return reply(calls.length);
158 };
159 return {
160 calls,
161 authorizations,
162 proofs,
163 remoteAuthorization,
164 input: {
165 prepared: PREPARED,
166 signer: Option.some(signer),
167 remoteAuthorization: Option.some(remoteAuthorization),
168 },
169 httpLayer: RpcHttp.layerRemoteHttpClient(fetchFn),
170 };
172​
173type HttpInput = ReturnType<typeof makeHarness>["input"];
174const LOADERS: ReadonlyArray<{
175 readonly name: string;
176 readonly method: string;
177 readonly path: string;
178 readonly response: unknown;
179 readonly expected: unknown;
180 readonly load: (
181 input: HttpInput,
182 ) => Effect.Effect<
183 unknown,
184 RemoteEnvironmentRequestError | PullRequestDiffLoader.PullRequestDiffCredentialRejectedError,
185 HttpClient.HttpClient
186 >;
187}> = [
188 {
189 name: "PR diff",
190 method: "POST",
191 path: "/api/pull-requests/diff",
192 response: DIFF_RESULT,
193 expected: DIFF_RESULT,
194 load: (input: HttpInput) =>
195 PullRequestDiffLoader.fetchEnvironmentPullRequestDiff({ ...input, diff: DIFF }),
196 },
197 {
198 name: "session permissions",
199 method: "GET",
200 path: "/api/auth/session",
201 response: SESSION,
202 expected: SESSION,
203 load: fetchEnvironmentSessionState,
204 },
205 {
206 name: "shell snapshot",
207 method: "GET",
208 path: "/api/orchestration/shell",
209 response: SHELL,
210 expected: SHELL,
211 load: (input: HttpInput) =>
212 fetchEnvironmentShellSnapshot(input).pipe(
213 Effect.map(({ loadPullRequests: _links, ...snapshot }) => snapshot),
214 ),
215 },
216 {
217 name: "thread snapshot",
218 method: "GET",
219 path: `/api/orchestration/threads/${THREAD.projection.thread.id}`,
220 response: encodeThreadSnapshot(THREAD),
221 expected: THREAD,
222 load: (input: HttpInput) =>
223 ThreadSnapshotLoader.fetchEnvironmentThreadSnapshot({
224 ...input,
225 threadId: THREAD.projection.thread.id,
226 }),
227 },
228 {
229 name: "thread transcript",
230 method: "GET",
231 path: `/api/orchestration/threads/${TRANSCRIPT.threadId}/transcript`,
232 response: encodeThreadTranscript(TRANSCRIPT),
233 expected: TRANSCRIPT,
234 load: (input: HttpInput) =>
235 fetchEnvironmentThreadTranscript({ ...input, threadId: TRANSCRIPT.threadId }),
236 },
237 {
238 name: "bounded thread snapshot",
239 method: "GET",
240 path: `/api/orchestration/threads/${THREAD.projection.thread.id}/bounded`,
241 response: encodeBoundedSnapshot(BOUNDED_THREAD),
242 expected: BOUNDED_THREAD,
243 load: (input: HttpInput) =>
244 fetchEnvironmentBoundedThreadSnapshot({ ...input, threadId: THREAD.projection.thread.id }),
245 },
246 {
247 name: "older thread history",
248 method: "GET",
249 path: `/api/orchestration/threads/${THREAD.projection.thread.id}/history`,
250 response: THREAD_HISTORY,
251 expected: THREAD_HISTORY,
252 load: (input: HttpInput) =>
253 fetchEnvironmentThreadHistoryPage({
254 ...input,
255 threadId: THREAD.projection.thread.id,
256 cursor: "older-page",
257 }),
258 },
259];
260​
261describe("authenticated environment HTTP requests", () => {
262 it.effect.each(LOADERS)("rejects an invalid $name response", (loader) =>
263 Effect.gen(function* () {
264 const harness = makeHarness(() => Response.json({}));
265 const result = yield* loader
266 .load(harness.input)
267 .pipe(Effect.provide(harness.httpLayer), Effect.asVoid, Effect.flip);
268 expect(result._tag).toBe("RemoteEnvironmentAuthInvalidJsonError");
269 expect(harness.calls).toHaveLength(1);
270 }),
271 );
272​
273 it.effect("keeps the status of a shell snapshot error that is not a declared error", () =>
274 Effect.gen(function* () {
275 const harness = makeHarness(() => Response.json({ error: "bad_gateway" }, { status: 502 }));
276 const error = yield* fetchEnvironmentShellSnapshot(harness.input).pipe(
277 Effect.provide(harness.httpLayer),
278 Effect.flip,
279 );
280 expect(error).toMatchObject({
281 _tag: "RemoteEnvironmentAuthUndeclaredStatusError",
282 status: 502,
283 });
284 }),
285 );
286​
287 it.effect.each(LOADERS)("uses current relay authorization and endpoint for $name", (loader) =>
288 Effect.gen(function* () {
289 const harness = makeHarness(() => Response.json(loader.response));
290 const result = yield* loader.load(harness.input).pipe(Effect.provide(harness.httpLayer));
291​
292 expect(result).toEqual(loader.expected);
293 expect(harness.calls).toHaveLength(1);
294 const call = harness.calls[0]!;
295 const url = new URL(call.url);
296 expect(url.origin).toBe(CURRENT_ORIGIN);
297 expect(url.pathname).toBe(loader.path);
298 expect(call.init.method).toBe(loader.method);
299 expect(new Headers(call.init.headers).get("authorization")).toBe("DPoP current-token");
300 expect(new Headers(call.init.headers).get("dpop")).toBe("proof-1");
301 expect(call.init.credentials).toBeUndefined();
302 if (loader.path.startsWith("/api/orchestration/")) {
303 expect(new Headers(call.init.headers).get(ORCHESTRATION_PROTOCOL_HEADER)).toBe(
304 ORCHESTRATION_PROTOCOL_VERSION_TEXT,
305 );
306 }
307 expect(harness.authorizations).toEqual([{ expectedEnvironmentId: TARGET.environmentId }]);
308 // The proof signs exactly the URL sent; signers drop the query for `htu`.
309 expect(harness.proofs).toEqual([
310 { method: loader.method, url: call.url, accessToken: "current-token" },
311 ]);
312 if (loader.name === "older thread history") {
313 expect(url.searchParams.get("cursor")).toBe("older-page");
314 }
315 expect(PREPARED.httpAuthorization).toMatchObject({ accessToken: "expired-token" });
316 }),
317 );
318​
319 // MCP-created thread ids contain ":", which the request path percent-encodes.
320 // The DPoP proof must sign the URL that is actually sent, or the environment
321 // rejects it as a URL mismatch.
322 const MCP_THREAD_ID = ThreadId.make("mcp:3534bc83-1c17-4a1e-9118-601c2766d355");
323 const MCP_THREAD_LOADERS: ReadonlyArray<
324 Pick<(typeof LOADERS)[number], "name" | "response" | "load">
325 > = [
326 {
327 name: "thread transcript",
328 response: encodeThreadTranscript(TRANSCRIPT),
329 load: (input: HttpInput) =>
330 fetchEnvironmentThreadTranscript({ ...input, threadId: MCP_THREAD_ID }),
331 },
332 {
333 name: "thread snapshot",
334 response: encodeThreadSnapshot(THREAD),
335 load: (input: HttpInput) =>
336 ThreadSnapshotLoader.fetchEnvironmentThreadSnapshot({ ...input, threadId: MCP_THREAD_ID }),
337 },
338 {
339 name: "bounded thread snapshot",
340 response: encodeBoundedSnapshot(BOUNDED_THREAD),
341 load: (input: HttpInput) =>
342 fetchEnvironmentBoundedThreadSnapshot({ ...input, threadId: MCP_THREAD_ID }),
343 },
344 {
345 name: "older thread history",
346 response: THREAD_HISTORY,
347 load: (input: HttpInput) =>
348 fetchEnvironmentThreadHistoryPage({
349 ...input,
350 threadId: MCP_THREAD_ID,
351 cursor: "older-page",
352 }),
353 },
354 ];
355 it.effect.each(MCP_THREAD_LOADERS)(
356 "signs the sent URL for a $name of a thread id that needs encoding",
357 (loader) =>
358 Effect.gen(function* () {
359 const harness = makeHarness(() => Response.json(loader.response));
360 yield* loader.load(harness.input).pipe(Effect.provide(harness.httpLayer));
361​
362 const sent = harness.calls[0]!.url;
363 expect(new URL(sent).pathname).toContain("/mcp%3A3534bc83-");
364 expect(harness.proofs.map((proof) => proof.url)).toEqual([sent]);
365 }),
366 );
367​
368 it.effect("retries a rejected diff once with a new token, endpoint, and proof", () =>
369 Effect.gen(function* () {
370 const harness = makeHarness((requestNumber) =>
371 requestNumber === 1 ? credentialRejectedResponse() : Response.json(DIFF_RESULT),
372 );
373 const result = yield* PullRequestDiffLoader.fetchEnvironmentPullRequestDiff({
374 ...harness.input,
375 diff: DIFF,
376 }).pipe(Effect.provide(harness.httpLayer));
377​
378 expect(result).toEqual(DIFF_RESULT);
379 expect(harness.authorizations).toEqual([
380 { expectedEnvironmentId: TARGET.environmentId },
381 { expectedEnvironmentId: TARGET.environmentId, rejectedAccessToken: "current-token" },
382 ]);
383 expect(harness.calls.map((call) => call.url)).toEqual([
384 `${CURRENT_ORIGIN}/api/pull-requests/diff`,
385 `${RENEWED_ORIGIN}/api/pull-requests/diff`,
386 ]);
387 expect(
388 harness.calls.map((call) => new Headers(call.init.headers).get("authorization")),
389 ).toEqual(["DPoP current-token", "DPoP renewed-token"]);
390 expect(harness.calls.map((call) => new Headers(call.init.headers).get("dpop"))).toEqual([
391 "proof-1",
392 "proof-2",
393 ]);
394 expect(harness.proofs[1]).toEqual({
395 method: "POST",
396 url: `${RENEWED_ORIGIN}/api/pull-requests/diff`,
397 accessToken: "renewed-token",
398 });
399 expect(harness.calls[1]!.init.body).toEqual(harness.calls[0]!.init.body);
400 }),
401 );
402​
403 it.effect("renews credentials captured by the bounded snapshot loader", () =>
404 Effect.gen(function* () {
405 const harness = makeHarness((requestNumber) =>
406 requestNumber === 1
407 ? credentialRejectedResponse()
408 : Response.json(encodeBoundedSnapshot(BOUNDED_THREAD)),
409 );
410 const layerLoader = BoundedThreadSnapshotHttp.layer.pipe(
411 Layer.provide(
412 Layer.mergeAll(
413 harness.httpLayer,
414 Layer.succeed(
415 ManagedRelay.ManagedRelayDpopSigner,
416 Option.getOrThrow(harness.input.signer),
417 ),
418 Layer.succeed(
419 RemoteEnvironmentAuthorization.RemoteEnvironmentAuthorization,
420 harness.remoteAuthorization,
421 ),
422 ),
423 ),
424 );
425 const loader = yield* ThreadSnapshotLoader.ThreadSnapshotLoader.pipe(
426 Effect.provide(layerLoader),
427 );
428 const result = yield* loader.load(PREPARED, THREAD.projection.thread.id);
429 expect(result).toEqual({
430 _tag: "present",
431 snapshot: { ...THREAD, latestLocalTurnOrdinal: BOUNDED_THREAD.latestLocalTurnOrdinal },
432 history: {
433 historyCursor: BOUNDED_THREAD.historyCursor,
434 hasMoreHistory: true,
435 latestLocalTurnOrdinal: BOUNDED_THREAD.latestLocalTurnOrdinal,
436 },
437 });
438 expect(harness.calls).toHaveLength(2);
439 expect(new Headers(harness.calls[1]!.init.headers).get("authorization")).toBe(
440 "DPoP renewed-token",
441 );
442 }),
443 );
444​
445 it.effect("preserves the credential rejection after the one recovery attempt fails", () =>
446 Effect.gen(function* () {
447 const harness = makeHarness(() => credentialRejectedResponse());
448 const error = yield* PullRequestDiffLoader.fetchEnvironmentPullRequestDiff({
449 ...harness.input,
450 diff: DIFF,
451 }).pipe(Effect.provide(harness.httpLayer), Effect.flip);
452​
453 expect(error).toMatchObject({
454 _tag: "PullRequestDiffCredentialRejectedError",
455 traceId: "trace-rejected",
456 });
457 expect(harness.calls).toHaveLength(2);
458 expect(harness.authorizations).toHaveLength(2);
459 }),
460 );
461​
462 it.effect.each([
463 {
464 name: "insufficient scope",
465 reply: () =>
466 Response.json(
467 {
468 _tag: "EnvironmentScopeRequiredError",
469 code: "insufficient_scope",
470 requiredScope: "orchestration:read",
471 traceId: "trace-scope",
472 },
473 { status: 403 },
474 ),
475 errorTag: "EnvironmentScopeRequiredError",
476 },
477 {
478 name: "missing credential",
479 reply: () => credentialRejectedResponse("missing_credential"),
480 errorTag: "EnvironmentAuthInvalidError",
481 },
482 {
483 name: "Cloudflare 530",
484 reply: () => new Response("error code: 1033", { status: 530 }),
485 errorTag: "RemoteEnvironmentAuthUndeclaredStatusError",
486 },
487 {
488 name: "network failure",
489 reply: () => Promise.reject(new Error("Network unreachable")),
490 errorTag: "RemoteEnvironmentAuthFetchError",
491 },
492 ])("does not renew or retry on $name", ({ reply, errorTag }) =>
493 Effect.gen(function* () {
494 const harness = makeHarness(reply);
495 const error = yield* PullRequestDiffLoader.fetchEnvironmentPullRequestDiff({
496 ...harness.input,
497 diff: DIFF,
498 }).pipe(Effect.provide(harness.httpLayer), Effect.flip);
499​
500 expect(error._tag).toBe(errorTag);
501 expect(harness.calls).toHaveLength(1);
502 expect(harness.authorizations).toEqual([{ expectedEnvironmentId: TARGET.environmentId }]);
503 }),
504 );
505​
506 it.effect("recovers a session's unauthenticated 200 response before checking permissions", () =>
507 Effect.gen(function* () {
508 const harness = makeHarness((requestNumber) =>
509 Response.json(requestNumber === 1 ? UNAUTHENTICATED_SESSION : SESSION),
510 );
511 const result = yield* fetchEnvironmentSessionState(harness.input).pipe(
512 Effect.provide(harness.httpLayer),
513 );
514​
515 expect(result).toEqual(SESSION);
516 expect(harness.authorizations[1]).toEqual({
517 expectedEnvironmentId: TARGET.environmentId,
518 rejectedAccessToken: "current-token",
519 });
520 expect(harness.calls).toHaveLength(2);
521 }),
522 );
523​
524 it.effect("reports persistent session rejection instead of showing missing permissions", () =>
525 Effect.gen(function* () {
526 const harness = makeHarness(() => Response.json(UNAUTHENTICATED_SESSION));
527 const error = yield* fetchEnvironmentSessionState(harness.input).pipe(
528 Effect.provide(harness.httpLayer),
529 Effect.flip,
530 );
531​
532 expect(error).toMatchObject({
533 _tag: "RemoteEnvironmentAuthFetchError",
534 message: "The environment rejected the renewed session authorization.",
535 });
536 expect(harness.calls).toHaveLength(2);
537 }),
538 );
539​
540 it.effect.each([
541 { name: "cookie", authorization: null },
542 { name: "bearer", authorization: { _tag: "Bearer", token: "bearer-token" } },
543 ] satisfies ReadonlyArray<{ name: string; authorization: PreparedHttpAuthorization | null }>)(
544 "leaves $name sessions unchanged without relay services",
545 ({ authorization }) =>
546 Effect.gen(function* () {
547 const harness = makeHarness(() => Response.json(UNAUTHENTICATED_SESSION));
548 const result = yield* fetchEnvironmentSessionState({
549 prepared: { ...PREPARED, httpAuthorization: authorization },
550 signer: Option.none(),
551 }).pipe(Effect.provide(harness.httpLayer));
552​
553 expect(result).toEqual(UNAUTHENTICATED_SESSION);
554 expect(harness.calls).toHaveLength(1);
555 expect(harness.authorizations).toEqual([]);
556 expect(new Headers(harness.calls[0]!.init.headers).get("authorization")).toBe(
557 authorization === null ? null : "Bearer bearer-token",
558 );
559 expect(harness.calls[0]!.init.credentials).toBe(
560 authorization === null ? "include" : undefined,
561 );
562 }),
563 );
564​
565 it.effect("reports renewal failure without sending the expired prepared token", () =>
566 Effect.gen(function* () {
567 const harness = makeHarness(() => Response.json(SESSION));
568 const failure = new ConnectionTransientError({
569 reason: "transport",
570 detail: "Relay unavailable",
571 });
572 const remoteAuthorization = RemoteEnvironmentAuthorization.RemoteEnvironmentAuthorization.of({
573 ...harness.remoteAuthorization,
574 authorizeDpopHttp: () => Effect.fail(failure),
575 });
576 const error = yield* fetchEnvironmentSessionState({
577 ...harness.input,
578 remoteAuthorization: Option.some(remoteAuthorization),
579 }).pipe(Effect.provide(harness.httpLayer), Effect.flip);
580​
581 expect(error).toMatchObject({
582 _tag: "RemoteEnvironmentAuthFetchError",
583 message: "Could not authorize the environment request.",
584 cause: failure,
585 });
586 expect(harness.calls).toEqual([]);
587 expect(harness.proofs).toEqual([]);
588 }),
589 );
590​
591 it.effect("does not fall back to a captured DPoP token when authorization is unavailable", () =>
592 Effect.gen(function* () {
593 const harness = makeHarness(() => Response.json(SESSION));
594 const error = yield* fetchEnvironmentSessionState({
595 prepared: PREPARED,
596 signer: harness.input.signer,
597 }).pipe(Effect.provide(harness.httpLayer), Effect.flip);
598​
599 expect(error).toMatchObject({
600 _tag: "RemoteEnvironmentAuthFetchError",
601 message: "No relay authorization service is available for the environment request.",
602 });
603 expect(harness.calls).toEqual([]);
604 }),
605 );
606});