From 60db9819ab4c106474ce7762e7a534b7afd78901 Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Thu, 10 Oct 2024 14:12:37 +0200 Subject: [PATCH] Rename `Decade` to `Century` We had an issue [1] with long expiration so I noticed the name was wrong [1] https://github.com/rh-ecosystem-edge/recert/pull/167 Signed-off-by: Omer Tuchfeld --- pkg/interceptors/server/server.go | 6 +++--- pkg/interceptors/server/server_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/interceptors/server/server.go b/pkg/interceptors/server/server.go index f5a154a6c..7a75fe859 100644 --- a/pkg/interceptors/server/server.go +++ b/pkg/interceptors/server/server.go @@ -33,7 +33,7 @@ import ( ) const ( - Decade = 100 * 365 * 24 * time.Hour + Century = 100 * 365 * 24 * time.Hour interceptorTLSSecretKey = "INTERCEPTOR_TLS_SECRET_NAME" interceptorTLSSvcKey = "INTERCEPTOR_TLS_SVC_NAME" ) @@ -159,7 +159,7 @@ func (is *Server) ExecuteInterceptor(r *http.Request) ([]byte, error) { } func CreateAndValidateCerts(ctx context.Context, coreV1Interface corev1.CoreV1Interface, logger *zap.SugaredLogger, service *Server, tc triggersv1alpha1.TriggersV1alpha1Interface) { - serverCert, caCert, err := createCerts(ctx, coreV1Interface, time.Now().Add(Decade), logger, false) + serverCert, caCert, err := createCerts(ctx, coreV1Interface, time.Now().Add(Century), logger, false) if err != nil { return } @@ -278,7 +278,7 @@ func (is *Server) checkCertValidity(ctx context.Context, serverCert, caCert []by if _, err := cert.Verify(opts); err != nil { logger.Errorf("failed to verify certificate: %v", err.Error()) - serverCertNew, caCertNew, err := createCerts(ctx, coreV1Interface, time.Now().Add(Decade), logger, true) + serverCertNew, caCertNew, err := createCerts(ctx, coreV1Interface, time.Now().Add(Century), logger, true) if err != nil { logger.Errorf("failed to create certs %v", err) } diff --git a/pkg/interceptors/server/server_test.go b/pkg/interceptors/server/server_test.go index 154f6fc85..a5bc108bb 100644 --- a/pkg/interceptors/server/server_test.go +++ b/pkg/interceptors/server/server_test.go @@ -212,7 +212,7 @@ func Test_SecretNotExist(t *testing.T) { logger := zaptest.NewLogger(t) ctx, _ := test.SetupFakeContext(t) clientSet := fakekubeclient.Get(ctx).CoreV1() - _, _, err := createCerts(ctx, clientSet, time.Now().Add(Decade), logger.Sugar(), false) + _, _, err := createCerts(ctx, clientSet, time.Now().Add(Century), logger.Sugar(), false) if err != nil && !strings.Contains(err.Error(), "not found") { t.Error(err) } @@ -241,7 +241,7 @@ func createSecret(t *testing.T, noAfter time.Time, certExpire bool) (v1.CoreV1In } func Test_CreateSecret(t *testing.T) { - _, sCert, caCert, err := createSecret(t, time.Now().Add(Decade), true) + _, sCert, caCert, err := createSecret(t, time.Now().Add(Century), true) if err != nil { t.Error(err) }