Skip to content

Commit

Permalink
add 365 days instead of 1 year to account for leap years (hashicorp#1969
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wilkermichael authored Mar 2, 2023
1 parent 2e8eeb2 commit 968eb42
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion control-plane/subcommand/tls-init/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ func TestRun_CreatesServerCertificatesWithExpiryWithinSpecifiedDays(t *testing.T
certBlock, _ := pem.Decode(newServerCert)
certificate, err := x509.ParseCertificate(certBlock.Bytes)
require.NoError(t, err)
require.Equal(t, time.Now().AddDate(1, 0, 0).Unix(), certificate.NotAfter.Unix())

// Add 365 days instead of 1 year to account for leap years
require.Equal(t, time.Now().AddDate(0, 0, 365).Unix(), certificate.NotAfter.Unix())
}

func TestRun_CreatesServerCertificatesWithProvidedHosts(t *testing.T) {
Expand Down

0 comments on commit 968eb42

Please sign in to comment.