The best way to control Claude Code, Codex and more from any computer or phone

main
ts 76 lines 2.77 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { ResourceServer, UserPool } from "@alchemy.run/aws/Cognito";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as cip from "@distilled.cloud/aws/cognito-identity-provider";
6 import * as Effect from "effect/Effect";
7
8 const { test } = Test.make({ providers: AWS.providers() });
9
10 test.provider(
11 "create, mutate scopes, delete resource server",
12 (stack) =>
13 Effect.gen(function* () {
14 yield* stack.destroy();
15
16 const outputs = yield* stack.deploy(
17 Effect.gen(function* () {
18 const pool = yield* UserPool("RSTestPool", {});
19 const server = yield* ResourceServer("Api", {
20 userPoolId: pool.userPoolId,
21 identifier: "https://api.alchemy-test.example.com",
22 name: "Test API",
23 scopes: [{ scopeName: "read", scopeDescription: "Read access" }],
24 });
25 return { pool, server };
26 }),
27 );
28
29 expect(outputs.server.identifier).toBe("https://api.alchemy-test.example.com");
30 expect(outputs.server.name).toBe("Test API");
31
32 // out-of-band verification via distilled
33 const created = yield* cip.describeResourceServer({
34 UserPoolId: outputs.pool.userPoolId,
35 Identifier: outputs.server.identifier,
36 });
37 expect(created.ResourceServer?.Name).toBe("Test API");
38 expect(created.ResourceServer?.Scopes).toHaveLength(1);
39
40 // scopes and name mutate in place
41 yield* stack.deploy(
42 Effect.gen(function* () {
43 const pool = yield* UserPool("RSTestPool", {});
44 const server = yield* ResourceServer("Api", {
45 userPoolId: pool.userPoolId,
46 identifier: "https://api.alchemy-test.example.com",
47 name: "Renamed API",
48 scopes: [
49 { scopeName: "read", scopeDescription: "Read access" },
50 { scopeName: "write", scopeDescription: "Write access" },
51 ],
52 });
53 return { pool, server };
54 }),
55 );
56 const afterUpdate = yield* cip.describeResourceServer({
57 UserPoolId: outputs.pool.userPoolId,
58 Identifier: outputs.server.identifier,
59 });
60 expect(afterUpdate.ResourceServer?.Name).toBe("Renamed API");
61 expect(afterUpdate.ResourceServer?.Scopes).toHaveLength(2);
62
63 yield* stack.destroy();
64 const gone = yield* cip
65 .describeResourceServer({
66 UserPoolId: outputs.pool.userPoolId,
67 Identifier: outputs.server.identifier,
68 })
69 .pipe(
70 Effect.map(() => false),
71 Effect.catchTag("ResourceNotFoundException", () => Effect.succeed(true)),
72 );
73 expect(gone).toBe(true);
74 }),
75 { tags: ["provider:aws", "provider:aws:cognito", "live"], timeout: 120_000 },
76 );