test: tighten channel readonly assertion

This commit is contained in:
Shakker
2026-05-08 21:07:53 +01:00
parent 94314ef8cf
commit 558cc44e74

View File

@@ -31,6 +31,19 @@ function stubChannelPlugin(params: {
};
}
function requireReadOnlyResolutionFinding(
findings: Awaited<ReturnType<typeof collectChannelSecurityFindings>>,
) {
const finding = findings.find(
(entry) => entry.checkId === "channels.zalouser.account.read_only_resolution",
);
expect(finding).toBeDefined();
if (!finding) {
throw new Error("Expected Zalo read-only resolution warning");
}
return finding;
}
describe("security audit channel read-only resolution", () => {
it("adds a read-only resolution warning when channel account resolveAccount throws", async () => {
const plugin = stubChannelPlugin({
@@ -54,12 +67,10 @@ describe("security audit channel read-only resolution", () => {
plugins: [plugin],
});
const finding = findings.find(
(entry) => entry.checkId === "channels.zalouser.account.read_only_resolution",
);
expect(finding?.severity).toBe("warn");
expect(finding?.title).toContain("could not be fully resolved");
expect(finding?.detail).toContain("zalouser:default: failed to resolve account");
expect(finding?.detail).toContain("missing SecretRef");
const finding = requireReadOnlyResolutionFinding(findings);
expect(finding.severity).toBe("warn");
expect(finding.title).toContain("could not be fully resolved");
expect(finding.detail).toContain("zalouser:default: failed to resolve account");
expect(finding.detail).toContain("missing SecretRef");
});
});