@@ -618,14 +618,29 @@ func TestWithParameterForAcceptSignatureBuild(t *testing.T) {
618618func TestWithValidityTolerance (t * testing.T ) {
619619 t .Parallel ()
620620
621- v := & verifier {}
622- exp := & verificationPolicy {}
623-
624- err := WithValidityTolerance (1 * time .Minute ).applyVerifierOption (v , exp , false )
625- require .NoError (t , err )
621+ for uc , tc := range map [string ]struct {
622+ tolerance time.Duration
623+ wantError bool
624+ }{
625+ "positive tolerance" : {tolerance : time .Minute },
626+ "zero tolerance" : {},
627+ "negative tolerance" : {tolerance : - time .Second , wantError : true },
628+ "minus one nanosecond" : {tolerance : - 1 , wantError : true },
629+ } {
630+ t .Run (uc , func (t * testing.T ) {
631+ policy := & verificationPolicy {}
626632
627- assert .Empty (t , v .tagPolicies )
628- assert .Equal (t , 1 * time .Minute , exp .tolerance )
633+ err := WithValidityTolerance (tc .tolerance ).applyVerifierOption (& verifier {}, policy , false )
634+ if tc .wantError {
635+ require .ErrorIs (t , err , ErrParameter )
636+ assert .Nil (t , policy .tolerance )
637+ } else {
638+ require .NoError (t , err )
639+ require .NotNil (t , policy .tolerance )
640+ assert .Equal (t , tc .tolerance , * policy .tolerance )
641+ }
642+ })
643+ }
629644}
630645
631646func TestWithMaxAge (t * testing.T ) {
@@ -654,7 +669,7 @@ func TestWithRequiredTag(t *testing.T) {
654669 require .NoError (t , err )
655670 require .NotNil (t , exp )
656671 assert .Empty (t , exp .identifiers )
657- assert .Equal (t , time . Duration ( - 1 ), exp .tolerance ) //nolint:testifylint
672+ assert .Nil (t , exp .tolerance )
658673 },
659674 },
660675 "with identifiers only" : {
@@ -668,7 +683,7 @@ func TestWithRequiredTag(t *testing.T) {
668683 require .NotNil (t , exp )
669684 assert .Len (t , exp .identifiers , 1 )
670685 assert .Equal (t , "@status" , exp .identifiers [0 ].Value )
671- assert .Equal (t , time . Duration ( - 1 ), exp .tolerance ) //nolint:testifylint
686+ assert .Nil (t , exp .tolerance )
672687 },
673688 },
674689 "with tolerance only" : {
@@ -681,7 +696,8 @@ func TestWithRequiredTag(t *testing.T) {
681696 require .NoError (t , err )
682697 require .NotNil (t , exp )
683698 assert .Empty (t , exp .identifiers )
684- assert .Equal (t , 5 * time .Minute , exp .tolerance )
699+ require .NotNil (t , exp .tolerance )
700+ assert .Equal (t , 5 * time .Minute , * exp .tolerance )
685701 },
686702 },
687703 "with all possible options" : {
@@ -696,7 +712,8 @@ func TestWithRequiredTag(t *testing.T) {
696712 require .NotNil (t , exp )
697713 assert .Len (t , exp .identifiers , 1 )
698714 assert .Equal (t , "@status" , exp .identifiers [0 ].Value )
699- assert .Equal (t , 5 * time .Minute , exp .tolerance )
715+ require .NotNil (t , exp .tolerance )
716+ assert .Equal (t , 5 * time .Minute , * exp .tolerance )
700717 },
701718 },
702719 "with unsupported identifier" : {
0 commit comments