File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
packages/cloudfront-signer/src Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -606,8 +606,9 @@ describe("getSignedCookies", () => {
606606} ) ;
607607
608608describe ( "getSignedUrl- when signing a URL with a date range" , ( ) => {
609- const dateString = "2024-05-17 " ;
609+ const dateString = "2024-05-17T12:30:45.000Z " ;
610610 const dateNumber = 1125674245900 ;
611+ const dateObject = new Date ( dateString ) ;
611612 it ( "allows string input compatible with Date constructor" , ( ) => {
612613 const epochDateLessThan = Math . round ( new Date ( dateString ) . getTime ( ) / 1000 ) ;
613614 const resultUrl = getSignedUrl ( {
@@ -646,6 +647,26 @@ describe("getSignedUrl- when signing a URL with a date range", () => {
646647 passphrase,
647648 } ) ;
648649
650+ expect ( resultUrl ) . toContain ( `Expires=${ epochDateLessThan } ` ) ;
651+ expect ( resultCookies [ "CloudFront-Expires" ] ) . toBe ( epochDateLessThan ) ;
652+ } ) ;
653+ it ( "allows Date object input" , ( ) => {
654+ const epochDateLessThan = Math . round ( dateObject . getTime ( ) / 1000 ) ;
655+ const resultUrl = getSignedUrl ( {
656+ url,
657+ keyPairId,
658+ dateLessThan : dateObject as unknown as string ,
659+ privateKey,
660+ passphrase,
661+ } ) ;
662+ const resultCookies = getSignedCookies ( {
663+ url,
664+ keyPairId,
665+ dateLessThan : dateObject as unknown as string ,
666+ privateKey,
667+ passphrase,
668+ } ) ;
669+
649670 expect ( resultUrl ) . toContain ( `Expires=${ epochDateLessThan } ` ) ;
650671 expect ( resultCookies [ "CloudFront-Expires" ] ) . toBe ( epochDateLessThan ) ;
651672 } ) ;
You can’t perform that action at this time.
0 commit comments