Skip to content

Commit 2eb5a7f

Browse files
committed
style(client): format scope accumulation tests
1 parent a4b48e1 commit 2eb5a7f

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

.changeset/fix-scope-overwrite-infinite-reauth.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44

55
Fix: accumulate OAuth scopes on 401/403 instead of overwriting
66

7-
When an HTTP transport receives a 401 or 403 with a `WWW-Authenticate` header
8-
containing new scopes, the scopes are now merged with any previously-acquired scopes
9-
rather than replacing them. The previous behaviour could cause an infinite re-auth loop
10-
where the client repeatedly lost its original scopes each time it attempted to upscope.
7+
When an HTTP transport receives a 401 or 403 with a `WWW-Authenticate` header containing new scopes, the scopes are now merged with any previously-acquired scopes rather than replacing them. The previous behaviour could cause an infinite re-auth loop where the client repeatedly
8+
lost its original scopes each time it attempted to upscope.

packages/client/test/client/streamableHttp.test.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,7 @@ describe('StreamableHTTPClientTransport', () => {
840840
await transport.send(testMessage);
841841

842842
expect(authSpy).toHaveBeenCalledTimes(2);
843-
expect(authSpy).toHaveBeenNthCalledWith(
844-
1,
845-
expect.anything(),
846-
expect.objectContaining({ scope: 'read:op1' })
847-
);
843+
expect(authSpy).toHaveBeenNthCalledWith(1, expect.anything(), expect.objectContaining({ scope: 'read:op1' }));
848844
expect(authSpy).toHaveBeenNthCalledWith(
849845
2,
850846
expect.anything(),
@@ -969,12 +965,14 @@ describe('StreamableHTTPClientTransport', () => {
969965
const authSpy = vi.spyOn(authModule, 'auth');
970966
authSpy.mockResolvedValue('AUTHORIZED');
971967

972-
await expect(transport.send({
973-
jsonrpc: '2.0',
974-
method: 'test',
975-
params: {},
976-
id: 'test-id'
977-
})).rejects.toThrow('Server returned 403 after trying upscoping');
968+
await expect(
969+
transport.send({
970+
jsonrpc: '2.0',
971+
method: 'test',
972+
params: {},
973+
id: 'test-id'
974+
})
975+
).rejects.toThrow('Server returned 403 after trying upscoping');
978976

979977
expect(authSpy).toHaveBeenCalledTimes(1);
980978
authSpy.mockRestore();

0 commit comments

Comments
 (0)