t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/Cloudflare/VulnerabilityScanner/Credential.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

80 lines
2.6 KiB
TypeScript

import * as Cloudflare from "@/Cloudflare";
import { adopt } from "@/AdoptPolicy";
import * as Provider from "@/Provider";
import * as Test from "@/Test/Alchemy";
import { expect } from "alchemy-test";
import * as Effect from "effect/Effect";
import * as Redacted from "effect/Redacted";
import { MinimumLogLevel } from "effect/References";
const { test } = Test.make({ providers: Cloudflare.providers() });
const logLevel = Effect.provideService(
MinimumLogLevel,
process.env.DEBUG ? "Debug" : "Info",
);
// Deterministic per-test names — same on every run.
const SET_LIST = "alchemy-vulnscanner-cred-list-set";
const CRED_LIST = "alchemy-vulnscanner-cred-list";
test.provider(
"list enumerates the deployed credential",
(stack) =>
Effect.gen(function* () {
yield* stack.destroy();
const deployed = yield* stack.deploy(
Effect.gen(function* () {
const set =
yield* Cloudflare.VulnerabilityScanner.VulnScannerCredentialSet(
"ListSet",
{
name: SET_LIST,
},
).pipe(adopt(true));
const credential =
yield* Cloudflare.VulnerabilityScanner.VulnScannerCredential(
"ListCred",
{
credentialSetId: set.credentialSetId,
name: CRED_LIST,
location: "header",
locationName: "authorization",
value: Redacted.make("Bearer alchemy-list-test"),
},
).pipe(adopt(true));
return { set, credential };
}),
);
const provider = yield* Provider.findProvider(
Cloudflare.VulnerabilityScanner.VulnScannerCredential,
);
const all = yield* provider.list();
// Parent fan-out over credential sets contains the deployed credential,
// each element shaped exactly like `read`'s Attributes (value is
// write-only and absent from both).
expect(
all.some((x) => x.credentialId === deployed.credential.credentialId),
).toBe(true);
const found = all.find(
(x) => x.credentialId === deployed.credential.credentialId,
);
expect(found?.credentialSetId).toEqual(deployed.set.credentialSetId);
expect(found?.name).toEqual(CRED_LIST);
expect(found?.location).toEqual("header");
expect(found?.locationName).toEqual("authorization");
expect(found?.accountId).toEqual(deployed.credential.accountId);
yield* stack.destroy();
}).pipe(logLevel),
{
tags: [
"provider:cloudflare",
"provider:cloudflare:vulnerabilityscanner",
"live",
],
},
);