fix: update default authorization header to include empty Bearer token and improve validation logic

This commit is contained in:
Kent C. Dodds 2025-09-30 15:17:10 -06:00
commit 34534ed062

View file

@ -914,14 +914,14 @@ describe("useConnection", () => {
expect(headers).toHaveProperty("Authorization", "Bearer mock-token");
});
test("replaces empty Bearer token placeholder with OAuth token", async () => {
test("warns of enabled empty Bearer token", async () => {
// This test prevents regression of the bug where default "Bearer " header
// prevented OAuth token injection, causing infinite auth loops
const customHeaders: CustomHeaders = [
{
name: "Authorization",
value: "Bearer ", // Empty Bearer token placeholder
enabled: true,
enabled: true, // enabled
},
];
@ -937,8 +937,8 @@ describe("useConnection", () => {
});
const headers = mockSSETransport.options?.requestInit?.headers;
// Should replace the empty "Bearer " with actual OAuth token
expect(headers).toHaveProperty("Authorization", "Bearer mock-token");
expect(headers).toHaveProperty("Authorization", "Bearer");
// Should not have the x-custom-auth-headers since Authorization is standard
expect(headers).not.toHaveProperty("x-custom-auth-headers");