Skip to content

Commit

Permalink
fix: ca rotation e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeelaChacha committed Sep 23, 2024
1 parent 966dd32 commit 95b34f0
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions tests/e2e/ca_certificate_rotation_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package e2e_test

import (
"context"
"errors"
"time"

certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
Expand Down Expand Up @@ -36,29 +34,24 @@ var _ = Describe("CA Certificate Rotation", Ordered, func() {
}
It("Then KCP TLS Certificate is removed", func() {
var err error
namespacedCertName := types.NamespacedName{
Name: caCertName,
namespacedSecretName := types.NamespacedName{
Name: watcher.ResolveTLSCertName(kyma.Name),
Namespace: "istio-system",
}
caCertificate, err = GetCACertificate(ctx, namespacedCertName, kcpClient)
tlsSecret, err := GetTlsSecret(ctx, namespacedSecretName, kcpClient)

Check failure on line 41 in tests/e2e/ca_certificate_rotation_test.go

View workflow job for this annotation

GitHub Actions / lint

undefined: GetTlsSecret
Expect(err).NotTo(HaveOccurred())

// The timeout used is 4 minutes bec the certificate gets rotated every 1 minute
Eventually(func(ctx context.Context, oldValue time.Time) error {
cert, err := GetCACertificate(ctx, namespacedCertName, kcpClient)
if err != nil {
return err
}
if cert.Status.NotAfter.Time == oldValue {
return errors.New("certificate not rotated")
}
return nil
}, 4*time.Minute).
Eventually(TlsSecretRotated, 4*time.Minute).

Check failure on line 45 in tests/e2e/ca_certificate_rotation_test.go

View workflow job for this annotation

GitHub Actions / lint

undefined: TlsSecretRotated (typecheck)
WithContext(ctx).
WithArguments(caCertificate.Status.NotAfter.Time).
WithArguments(tlsSecret.CreationTimestamp.Time, namespacedSecretName, kcpClient).
Should(Succeed())

By("And new TLS Certificate is created")
namespacedCertName := types.NamespacedName{
Name: caCertName,
Namespace: "istio-system",
}
caCertificate, err = GetCACertificate(ctx, namespacedCertName, kcpClient)
Expect(err).NotTo(HaveOccurred())
Eventually(CertificateSecretIsCreatedAfter).
Expand Down

0 comments on commit 95b34f0

Please sign in to comment.