From 9cb204bdc28121b5d09dc807ec74f125ec51144f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 01:38:46 +0100 Subject: [PATCH] test: tighten googlechat auth redaction assertion --- .../src/google-auth.runtime.test.ts | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/extensions/googlechat/src/google-auth.runtime.test.ts b/extensions/googlechat/src/google-auth.runtime.test.ts index 3a13d5becfa..1f789ce24eb 100644 --- a/extensions/googlechat/src/google-auth.runtime.test.ts +++ b/extensions/googlechat/src/google-auth.runtime.test.ts @@ -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/, + ); }); });