|
1 | 1 | import { http, HttpResponse } from 'msw'; |
2 | 2 | import { describe, expect, it } from 'vitest'; |
3 | 3 |
|
| 4 | +import jwksJson from '../../fixtures/jwks.json'; |
4 | 5 | import userJson from '../../fixtures/user.json'; |
5 | 6 | import { server, validateHeaders } from '../../mock-server'; |
6 | 7 | import { createBackendApiClient } from '../factory'; |
@@ -275,4 +276,30 @@ describe('api.client', () => { |
275 | 276 | expect(data[0].token).toBe('<token>'); |
276 | 277 | expect(data[0].scopes).toEqual(['email', 'profile']); |
277 | 278 | }); |
| 279 | + |
| 280 | + describe('JWKS', () => { |
| 281 | + it('executes a successful backend API request for a single resource and returns the raw response', async () => { |
| 282 | + server.use( |
| 283 | + http.get( |
| 284 | + `https://api.clerk.test/v1/jwks`, |
| 285 | + validateHeaders(() => { |
| 286 | + return HttpResponse.json(jwksJson); |
| 287 | + }), |
| 288 | + ), |
| 289 | + ); |
| 290 | + |
| 291 | + const response = await apiClient.jwks.getJwks(); |
| 292 | + const key = response.keys?.[0]; |
| 293 | + |
| 294 | + expect(key).toBeDefined(); |
| 295 | + expect(key?.kid).toBe('ins_1234'); |
| 296 | + expect(key?.alg).toBe('RS256'); |
| 297 | + expect(key?.kty).toBe('RSA'); |
| 298 | + expect(key?.use).toBe('sig'); |
| 299 | + expect(key?.e).toBe('BQGF'); |
| 300 | + expect(key?.n).toBe( |
| 301 | + 'xV3jihnMy4sr5jJ4S66YTc6FxnFsVy3weiyJFYOAdo515AZMrpMMdraAiVmnXZfolZpv7CcnsnG290cg-XfGRNk-Jil_tJt2SLGtiT9LtWT_iev4zN8veRGzTaOb6C-Qb6T_8xsjP_sp0a92zyNgyc4UxR-acMmOqxjkHmx1q0U1fCom83WI59Yu5VmvLM4MA-1sLkmAE1bTzp4ie-_xu9anwsS3H97MONGtildB4nAG0L-lj7tReNHoYLkciEKCqqUMoK-o6JN29OKozpqiI4dVv0oityWw2ygf6eR5qrKZZjrjbAMt_emXBFGQ5Y1QSsriJoRoykGcdbXaU7S_QV', |
| 302 | + ); |
| 303 | + }); |
| 304 | + }); |
278 | 305 | }); |
0 commit comments