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
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { SSHPublicKey, 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 { testSshPublicKey } from "./fixtures.ts"; |
| 9 | |
| 10 | const { test } = Test.make({ providers: AWS.providers() }); |
| 11 | |
| 12 | describe("AWS.IAM.SSHPublicKey", { tags: ["provider:aws", "provider:aws:iam", "live"] }, () => { |
| 13 | // Canonical `list()` test: IAM is a global service and `listSSHPublicKeys` |
| 14 | // requires a `UserName`, so the provider enumerates every user first and then |
| 15 | // lists keys per user, hydrating each via `getSSHPublicKey`. Deploy a real |
| 16 | // user + SSH key (with a checked-in valid RSA public key), resolve the |
| 17 | // provider from context with the typed `findProvider`, call `list()`, and |
| 18 | // assert the deployed key appears in the exhaustively-paginated result. |
| 19 | test.provider("list enumerates the deployed SSH public key", (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("SSHKeyListOwner", {}); |
| 26 | const key = yield* SSHPublicKey("SSHKeyListKey", { |
| 27 | userName: user.userName, |
| 28 | sshPublicKeyBody: testSshPublicKey, |
| 29 | }); |
| 30 | return { user, key }; |
| 31 | }), |
| 32 | ); |
| 33 | |
| 34 | const provider = yield* Provider.findProvider(SSHPublicKey); |
| 35 | const all = yield* provider.list(); |
| 36 | |
| 37 | const found = all.find((entry) => entry.sshPublicKeyId === deployed.key.sshPublicKeyId); |
| 38 | expect(found).toBeDefined(); |
| 39 | expect(found?.userName).toBe(deployed.user.userName); |
| 40 | expect(found?.sshPublicKeyBody).toBeDefined(); |
| 41 | expect(found?.fingerprint).toBeDefined(); |
| 42 | |
| 43 | yield* stack.destroy(); |
| 44 | |
| 45 | // The user (and with it the SSH public key) is gone. |
| 46 | const deletedUser = yield* IAM.getUser({ UserName: deployed.user.userName }).pipe( |
| 47 | Effect.option, |
| 48 | ); |
| 49 | expect(deletedUser._tag).toBe("None"); |
| 50 | }), |
| 51 | ); |
| 52 | }); |