| 1 | import * as AWS from "@/AWS"; |
| 2 | import { Instance } from "@/AWS/IdentityCenter"; |
| 3 | import * as Provider from "@/Provider"; |
| 4 | import * as Test from "@/Test/Alchemy"; |
| 5 | import { expect } from "alchemy-test"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: AWS.providers() }); |
| 9 | |
| 10 | // An IAM Identity Center instance is a pre-existing account/organization |
| 11 | // singleton — you generally cannot create one inside a test. `list()` |
| 12 | // enumerates every visible instance via `ListInstances` and returns the |
| 13 | // exact `read` Attributes shape. Accounts without SSO enabled return `[]` |
| 14 | // (not an error), so this test asserts a well-typed `Attributes[]` and |
| 15 | // validates the element shape only when at least one instance exists. |
| 16 | test.provider( |
| 17 | "list enumerates visible Identity Center instances", |
| 18 | () => |
| 19 | Effect.gen(function* () { |
| 20 | const provider = yield* Provider.findProvider(Instance); |
| 21 | const all = yield* provider.list(); |
| 22 | |
| 23 | expect(Array.isArray(all)).toBe(true); |
| 24 | |
| 25 | for (const instance of all) { |
| 26 | expect(typeof instance.instanceArn).toBe("string"); |
| 27 | expect(instance.instanceArn.length).toBeGreaterThan(0); |
| 28 | expect(typeof instance.identityStoreId).toBe("string"); |
| 29 | expect(instance.identityStoreId.length).toBeGreaterThan(0); |
| 30 | expect(instance.mode).toBe("existing"); |
| 31 | } |
| 32 | }), |
| 33 | { tags: ["provider:aws", "provider:aws:identitycenter", "live"] }, |
| 34 | ); |