test: tighten googlechat auth redaction assertion

This commit is contained in:
Peter Steinberger
2026-05-09 01:38:46 +01:00
parent f0b0988b04
commit 9cb204bdc2

View File

@@ -506,24 +506,23 @@ describe("googlechat google auth runtime", () => {
it("does not disclose raw credential paths or OS errors when file reads fail", async () => {
const missingPath = path.join(os.tmpdir(), "googlechat-auth-missing", "service-account.json");
await expect(
resolveValidatedGoogleChatCredentials({
let thrown: unknown;
try {
await resolveValidatedGoogleChatCredentials({
accountId: "default",
config: {},
credentialSource: "file",
credentialsFile: missingPath,
enabled: true,
}),
).rejects.toThrow("Failed to load Google Chat service account file.");
});
} catch (error) {
thrown = error;
}
await expect(
resolveValidatedGoogleChatCredentials({
accountId: "default",
config: {},
credentialSource: "file",
credentialsFile: missingPath,
enabled: true,
}),
).rejects.not.toThrow(/ENOENT|service-account\.json|googlechat-auth-missing/);
expect(thrown).toBeInstanceOf(Error);
expect((thrown as Error).message).toBe("Failed to load Google Chat service account file.");
expect((thrown as Error).message).not.toMatch(
/ENOENT|service-account\.json|googlechat-auth-missing/,
);
});
});