The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import { adopt } from "alchemy/AdoptPolicy"; |
| 5 | import * as Provider from "alchemy/Provider"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | import * as Redacted from "effect/Redacted"; |
| 8 | import { MinimumLogLevel } from "effect/References"; |
| 9 | import { testName } from "../../names.ts"; |
| 10 | |
| 11 | const { test } = Test.make({ providers: Cloudflare.providers() }); |
| 12 | |
| 13 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 14 | |
| 15 | // Deterministic per-test names — same on every run. |
| 16 | const SET_LIST = testName("alchemy-vulnscanner-cred-list-set"); |
| 17 | const CRED_LIST = testName("alchemy-vulnscanner-cred-list"); |
| 18 | |
| 19 | test.provider( |
| 20 | "list enumerates the deployed credential", |
| 21 | (stack) => |
| 22 | Effect.gen(function* () { |
| 23 | yield* stack.destroy(); |
| 24 | |
| 25 | const deployed = yield* stack.deploy( |
| 26 | Effect.gen(function* () { |
| 27 | const set = yield* Cloudflare.VulnerabilityScanner.VulnScannerCredentialSet("ListSet", { |
| 28 | name: SET_LIST, |
| 29 | }).pipe(adopt(true)); |
| 30 | const credential = yield* Cloudflare.VulnerabilityScanner.VulnScannerCredential( |
| 31 | "ListCred", |
| 32 | { |
| 33 | credentialSetId: set.credentialSetId, |
| 34 | name: CRED_LIST, |
| 35 | location: "header", |
| 36 | locationName: "authorization", |
| 37 | value: Redacted.make("Bearer alchemy-list-test"), |
| 38 | }, |
| 39 | ).pipe(adopt(true)); |
| 40 | return { set, credential }; |
| 41 | }), |
| 42 | ); |
| 43 | |
| 44 | const provider = yield* Provider.findProvider( |
| 45 | Cloudflare.VulnerabilityScanner.VulnScannerCredential, |
| 46 | ); |
| 47 | const all = yield* provider.list(); |
| 48 | |
| 49 | // Parent fan-out over credential sets contains the deployed credential, |
| 50 | // each element shaped exactly like `read`'s Attributes (value is |
| 51 | // write-only and absent from both). |
| 52 | expect(all.some((x) => x.credentialId === deployed.credential.credentialId)).toBe(true); |
| 53 | const found = all.find((x) => x.credentialId === deployed.credential.credentialId); |
| 54 | expect(found?.credentialSetId).toEqual(deployed.set.credentialSetId); |
| 55 | expect(found?.name).toEqual(CRED_LIST); |
| 56 | expect(found?.location).toEqual("header"); |
| 57 | expect(found?.locationName).toEqual("authorization"); |
| 58 | expect(found?.accountId).toEqual(deployed.credential.accountId); |
| 59 | |
| 60 | yield* stack.destroy(); |
| 61 | }).pipe(logLevel), |
| 62 | { tags: ["provider:cloudflare", "provider:cloudflare:vulnerabilityscanner", "live"] }, |
| 63 | ); |