@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 65 lines 2.7 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { ServiceSpecificCredential, User } from "@alchemy.run/aws/IAM";
3 import { describe, expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as IAM from "@distilled.cloud/aws/iam";
6 import * as Provider from "alchemy/Provider";
7 import * as Effect from "effect/Effect";
8
9 const { test } = Test.make({ providers: AWS.providers() });
10
11 describe(
12 "AWS.IAM.ServiceSpecificCredential",
13 { tags: ["provider:aws", "provider:aws:iam", "live"] },
14 () => {
15 // Canonical `list()` test: IAM is a global service and service-specific
16 // credentials are owned per IAM user, so the provider enumerates every user
17 // first and then lists credentials per user. Deploy a real user + credential,
18 // resolve the provider from context with the typed `findProvider`, call
19 // `list()`, and assert the deployed credential appears in the result.
20 test.provider("list enumerates the deployed service-specific credential", (stack) =>
21 Effect.gen(function* () {
22 yield* stack.destroy();
23
24 const deployed = yield* stack.deploy(
25 Effect.gen(function* () {
26 const user = yield* User("SsCredListOwner", {});
27 const credential = yield* ServiceSpecificCredential("SsCredListCred", {
28 userName: user.userName,
29 serviceName: "codecommit.amazonaws.com",
30 // Duration.Input prop — converted to whole wire days.
31 credentialAge: "30 days",
32 });
33 return { user, credential };
34 }),
35 );
36
37 // The Duration prop round-trips as an expiration ~30 days out, and
38 // the creation-only secret is captured as a Redacted output.
39 expect(deployed.credential.expirationDate).toBeDefined();
40 expect(deployed.credential.servicePassword).toBeDefined();
41
42 const provider = yield* Provider.findProvider(ServiceSpecificCredential);
43 const all = yield* provider.list();
44
45 const found = all.find(
46 (entry) =>
47 entry.serviceSpecificCredentialId === deployed.credential.serviceSpecificCredentialId,
48 );
49 expect(found).toBeDefined();
50 expect(found?.userName).toBe(deployed.user.userName);
51 expect(found?.serviceName).toBe("codecommit.amazonaws.com");
52 expect(found?.servicePassword).toBeUndefined();
53 expect(found?.serviceCredentialSecret).toBeUndefined();
54
55 yield* stack.destroy();
56
57 // The user (and with it the service-specific credential) is gone.
58 const deletedUser = yield* IAM.getUser({ UserName: deployed.user.userName }).pipe(
59 Effect.option,
60 );
61 expect(deletedUser._tag).toBe("None");
62 }),
63 );
64 },
65 );