| 1 | import * as AWS from "@/AWS"; |
| 2 | import { SAMLProvider } from "@/AWS/IAM"; |
| 3 | import * as Provider from "@/Provider"; |
| 4 | import * as Test from "@/Test/Alchemy"; |
| 5 | import * as IAM from "@distilled.cloud/aws/iam"; |
| 6 | import { describe, expect } from "alchemy-test"; |
| 7 | import * as Effect from "effect/Effect"; |
| 8 | import * as Redacted from "effect/Redacted"; |
| 9 | import { testPrivateKey, testSamlMetadataDocument } from "./fixtures.ts"; |
| 10 | |
| 11 | const { test } = Test.make({ providers: AWS.providers() }); |
| 12 | |
| 13 | describe( |
| 14 | "AWS.IAM.SAMLProvider", |
| 15 | { tags: ["provider:aws", "provider:aws:iam", "live"] }, |
| 16 | () => { |
| 17 | test.provider("list enumerates the deployed SAML provider", (stack) => |
| 18 | Effect.gen(function* () { |
| 19 | yield* stack.destroy(); |
| 20 | |
| 21 | const deployed = yield* stack.deploy( |
| 22 | Effect.gen(function* () { |
| 23 | return yield* SAMLProvider("ListResource", { |
| 24 | samlMetadataDocument: testSamlMetadataDocument, |
| 25 | // Redacted prop — unwrapped to the wire private key at create. |
| 26 | assertionEncryptionMode: "Allowed", |
| 27 | addPrivateKey: Redacted.make(testPrivateKey), |
| 28 | }); |
| 29 | }), |
| 30 | ); |
| 31 | |
| 32 | expect(deployed.assertionEncryptionMode).toBe("Allowed"); |
| 33 | |
| 34 | const provider = yield* Provider.findProvider(SAMLProvider); |
| 35 | const all = yield* provider.list(); |
| 36 | |
| 37 | expect( |
| 38 | all.some((x) => x.samlProviderArn === deployed.samlProviderArn), |
| 39 | ).toBe(true); |
| 40 | |
| 41 | yield* stack.destroy(); |
| 42 | |
| 43 | const deleted = yield* IAM.getSAMLProvider({ |
| 44 | SAMLProviderArn: deployed.samlProviderArn, |
| 45 | }).pipe(Effect.option); |
| 46 | expect(deleted._tag).toBe("None"); |
| 47 | }), |
| 48 | ); |
| 49 | }, |
| 50 | ); |