feat(rest)!: allow passing tokens per request (#10682)

BREAKING CHANGE: `RequestData.authPrefix` has been removed in favor of `RequestData.auth.prefix`
This commit is contained in:
ckohen
2025-01-12 21:36:05 -08:00
committed by GitHub
parent 11438c230b
commit ae0265eefc
8 changed files with 71 additions and 22 deletions

View File

@@ -184,7 +184,7 @@ test('getAuth', async () => {
(from) => ({ auth: (from.headers as unknown as Record<string, string | undefined>).Authorization ?? null }),
responseOptions,
)
.times(3);
.times(5);
// default
expect(await api.get('/getAuth')).toStrictEqual({ auth: 'Bot A-Very-Fake-Token' });
@@ -202,6 +202,20 @@ test('getAuth', async () => {
auth: true,
}),
).toStrictEqual({ auth: 'Bot A-Very-Fake-Token' });
// Custom Bot Auth
expect(
await api.get('/getAuth', {
auth: { token: 'A-Very-Different-Fake-Token' },
}),
).toStrictEqual({ auth: 'Bot A-Very-Different-Fake-Token' });
// Custom Bearer Auth
expect(
await api.get('/getAuth', {
auth: { token: 'A-Bearer-Fake-Token', prefix: 'Bearer' },
}),
).toStrictEqual({ auth: 'Bearer A-Bearer-Fake-Token' });
});
test('getReason', async () => {