@@ -56,7 +56,7 @@ describe('signer', () => {
56
56
let bucket : BucketI ;
57
57
let file : FileI ;
58
58
59
- const NOW = new Date ( '2019-03-18T00:00:00Z ' ) ;
59
+ const NOW = new Date ( '2019-03-18T00:00:00.999Z ' ) ;
60
60
let fakeTimers : sinon . SinonFakeTimers ;
61
61
62
62
beforeEach ( ( ) => ( fakeTimers = sinon . useFakeTimers ( NOW ) ) ) ;
@@ -554,7 +554,7 @@ describe('signer', () => {
554
554
signer = new URLSigner ( authClient , bucket , file ) ;
555
555
CONFIG = {
556
556
method : 'GET' ,
557
- expiration : Math . floor ( ( NOW . valueOf ( ) + 2000 ) / 1000 ) ,
557
+ expiration : ( NOW . valueOf ( ) + 2000 ) / 1000 ,
558
558
bucket : bucket . name ,
559
559
} ;
560
560
} ) ;
@@ -573,6 +573,30 @@ describe('signer', () => {
573
573
) ;
574
574
} ) ;
575
575
576
+ it ( 'should not throw with expiration of exactly 7 days' , async ( ) => {
577
+ const ACCESSIBLE_AT = NOW . valueOf ( ) ;
578
+ const SEVEN_DAYS_IN_SECONDS = 7 * 24 * 60 * 60 ;
579
+ const SEVEN_DAYS_IN_MS = SEVEN_DAYS_IN_SECONDS * 1000 ;
580
+ await assert . doesNotReject (
581
+ async ( ) => {
582
+ await signer . getSignedUrl ( {
583
+ method : 'GET' ,
584
+ expires : ACCESSIBLE_AT + SEVEN_DAYS_IN_MS ,
585
+ accessibleAt : ACCESSIBLE_AT ,
586
+ version : 'v4' ,
587
+ } ) ;
588
+ } ,
589
+ err => {
590
+ assert ( err instanceof Error ) ;
591
+ assert . strictEqual (
592
+ err . message ,
593
+ `Max allowed expiration is seven days (${ SEVEN_DAYS_IN_SECONDS } seconds).`
594
+ ) ;
595
+ return true ;
596
+ }
597
+ ) ;
598
+ } ) ;
599
+
576
600
describe ( 'headers' , ( ) => {
577
601
it ( 'should add path-styled host header' , async ( ) => {
578
602
const getCanonicalHeaders = sandbox
@@ -988,7 +1012,7 @@ describe('signer', () => {
988
1012
989
1013
it ( 'returns expiration date in seconds' , ( ) => {
990
1014
const expires = signer . parseExpires ( NOW ) ;
991
- assert . strictEqual ( expires , Math . round ( NOW . valueOf ( ) / 1000 ) ) ;
1015
+ assert . strictEqual ( expires , Math . floor ( NOW . valueOf ( ) / 1000 ) ) ;
992
1016
} ) ;
993
1017
} ) ;
994
1018
} ) ;
0 commit comments