@@ -14,14 +14,14 @@ vi.spyOn(verifySignatureModule, "verifySignatureFromApiUrl").mockImplementation(
14
14
if ( signature !== "mocked_signature" ) {
15
15
throw new Error ( "Wrong signature" ) ;
16
16
}
17
- }
17
+ } ,
18
18
) ;
19
19
vi . spyOn ( verifySignatureModule , "verifySignatureWithJwks" ) . mockImplementation (
20
20
async ( domain , signature ) => {
21
21
if ( signature !== "mocked_signature" ) {
22
22
throw new Error ( "Wrong signature" ) ;
23
23
}
24
- }
24
+ } ,
25
25
) ;
26
26
27
27
describe ( "SaleorWebhookValidator" , ( ) => {
@@ -33,7 +33,7 @@ describe("SaleorWebhookValidator", () => {
33
33
const validHeaders = {
34
34
saleorApiUrl : mockAPL . workingSaleorApiUrl ,
35
35
event : "product_updated" ,
36
- schemaVersion : 3.2 ,
36
+ schemaVersion : "3.20" ,
37
37
signature : "mocked_signature" ,
38
38
authorizationBearer : "mocked_bearer" ,
39
39
domain : "example.com" ,
@@ -316,10 +316,10 @@ describe("SaleorWebhookValidator", () => {
316
316
expect ( mockAPL . set ) . toHaveBeenCalledWith (
317
317
expect . objectContaining ( {
318
318
jwks : "new-jwks" ,
319
- } )
319
+ } ) ,
320
320
) ;
321
321
expect ( fetchRemoteJwksModule . fetchRemoteJwks ) . toHaveBeenCalledWith (
322
- authDataNoJwks . saleorApiUrl
322
+ authDataNoJwks . saleorApiUrl ,
323
323
) ;
324
324
// it's called only once because jwks was missing initially, so we skipped first validation
325
325
expect ( verifySignatureModule . verifySignatureWithJwks ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -351,21 +351,21 @@ describe("SaleorWebhookValidator", () => {
351
351
expect ( mockAPL . set ) . toHaveBeenCalledWith (
352
352
expect . objectContaining ( {
353
353
jwks : "new-jwks" ,
354
- } )
354
+ } ) ,
355
355
) ;
356
356
expect ( fetchRemoteJwksModule . fetchRemoteJwks ) . toHaveBeenCalledWith (
357
- authDataNoJwks . saleorApiUrl
357
+ authDataNoJwks . saleorApiUrl ,
358
358
) ;
359
359
expect ( verifySignatureModule . verifySignatureWithJwks ) . toHaveBeenCalledTimes ( 2 ) ;
360
360
} ) ;
361
361
362
362
it ( "Returns an error when new JWKS cannot be fetched" , async ( ) => {
363
363
vi . spyOn ( mockAPL , "get" ) . mockResolvedValue ( authDataNoJwks ) ;
364
364
vi . spyOn ( verifySignatureModule , "verifySignatureWithJwks" ) . mockRejectedValue (
365
- new Error ( "Initial verification failed" )
365
+ new Error ( "Initial verification failed" ) ,
366
366
) ;
367
367
vi . spyOn ( fetchRemoteJwksModule , "fetchRemoteJwks" ) . mockRejectedValue (
368
- new Error ( "JWKS fetch failed" )
368
+ new Error ( "JWKS fetch failed" ) ,
369
369
) ;
370
370
371
371
const result = await validator . validateRequest ( {
@@ -408,7 +408,7 @@ describe("SaleorWebhookValidator", () => {
408
408
409
409
expect ( verifySignatureModule . verifySignatureWithJwks ) . toHaveBeenCalledTimes ( 2 ) ;
410
410
expect ( fetchRemoteJwksModule . fetchRemoteJwks ) . toHaveBeenCalledWith (
411
- authDataNoJwks . saleorApiUrl
411
+ authDataNoJwks . saleorApiUrl ,
412
412
) ;
413
413
} ) ;
414
414
} ) ;
0 commit comments