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 { SigningCertificate, 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 { testCertificateBody } from "./fixtures.ts"; |
| 9 | import { withSigningCertificateFixture } from "./SigningCertificateTestLease.ts"; |
| 10 | |
| 11 | const { test } = Test.make({ providers: AWS.providers() }); |
| 12 | |
| 13 | describe( |
| 14 | "AWS.IAM.SigningCertificate", |
| 15 | { tags: ["provider:aws", "provider:aws:iam", "live"] }, |
| 16 | () => { |
| 17 | // Canonical `list()` test: IAM is a global service and |
| 18 | // `listSigningCertificates` requires a `UserName`, so the provider enumerates |
| 19 | // every user first and then lists certificates per user. Deploy a real user + |
| 20 | // signing certificate (with a checked-in valid X.509 certificate body), |
| 21 | // resolve the provider from context with the typed `findProvider`, call |
| 22 | // `list()`, and assert the deployed certificate appears in the |
| 23 | // exhaustively-paginated result. |
| 24 | test.provider("list enumerates the deployed signing certificate", (stack) => |
| 25 | withSigningCertificateFixture( |
| 26 | Effect.gen(function* () { |
| 27 | yield* stack.destroy(); |
| 28 | |
| 29 | const deployed = yield* stack.deploy( |
| 30 | Effect.gen(function* () { |
| 31 | const user = yield* User("SigningCertListOwner", {}); |
| 32 | const certificate = yield* SigningCertificate("SigningCertListCert", { |
| 33 | userName: user.userName, |
| 34 | certificateBody: testCertificateBody, |
| 35 | }); |
| 36 | return { user, certificate }; |
| 37 | }), |
| 38 | ); |
| 39 | |
| 40 | const provider = yield* Provider.findProvider(SigningCertificate); |
| 41 | const all = yield* provider.list(); |
| 42 | |
| 43 | const found = all.find( |
| 44 | (entry) => entry.certificateId === deployed.certificate.certificateId, |
| 45 | ); |
| 46 | expect(found).toBeDefined(); |
| 47 | expect(found?.userName).toBe(deployed.user.userName); |
| 48 | expect(found?.certificateBody).toBeDefined(); |
| 49 | expect(found?.status).toBe("Active"); |
| 50 | |
| 51 | yield* stack.destroy(); |
| 52 | |
| 53 | // The user (and with it the signing certificate) is gone. |
| 54 | const deletedUser = yield* IAM.getUser({ UserName: deployed.user.userName }).pipe( |
| 55 | Effect.option, |
| 56 | ); |
| 57 | expect(deletedUser._tag).toBe("None"); |
| 58 | }), |
| 59 | ), |
| 60 | ); |
| 61 | }, |
| 62 | ); |