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

main
ts 51 lines 2.04 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { LoginProfile, 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 import * as Redacted from "effect/Redacted";
9
10 const { test } = Test.make({ providers: AWS.providers() });
11
12 describe("AWS.IAM.LoginProfile", { tags: ["provider:aws", "provider:aws:iam", "live"] }, () => {
13 // Canonical `list()` test: IAM is a global service and there is no
14 // list-login-profiles API, so the provider enumerates every user first and
15 // then probes `getLoginProfile` per user (skipping users without console
16 // access). Deploy a real user + login profile, resolve the provider from
17 // context with the typed `findProvider`, call `list()`, and assert the
18 // deployed profile appears in the result.
19 test.provider("list enumerates the deployed login profile", (stack) =>
20 Effect.gen(function* () {
21 yield* stack.destroy();
22
23 const deployed = yield* stack.deploy(
24 Effect.gen(function* () {
25 const user = yield* User("LoginProfileListOwner", {});
26 const profile = yield* LoginProfile("LoginProfileListProfile", {
27 userName: user.userName,
28 password: Redacted.make("TempPassword123!"),
29 passwordResetRequired: true,
30 });
31 return { user, profile };
32 }),
33 );
34
35 const provider = yield* Provider.findProvider(LoginProfile);
36 const all = yield* provider.list();
37
38 const found = all.find((entry) => entry.userName === deployed.user.userName);
39 expect(found).toBeDefined();
40 expect(found?.userName).toBe(deployed.user.userName);
41
42 yield* stack.destroy();
43
44 // The user (and with it the login profile) is gone.
45 const deletedUser = yield* IAM.getUser({ UserName: deployed.user.userName }).pipe(
46 Effect.option,
47 );
48 expect(deletedUser._tag).toBe("None");
49 }),
50 );
51 });