Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#468 from stuggi/enhance_ge…
Browse files Browse the repository at this point in the history
…tissuerbylabels_tests

[certmanager] enhance GetIssuerByLabels tests
  • Loading branch information
vakwetu committed Feb 27, 2024
2 parents ffd4137 + a6d0eec commit 7f3f843
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions modules/certmanager/test/functional/certmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
. "github.com/onsi/gomega"
"github.com/openstack-k8s-operators/lib-common/modules/certmanager"
corev1 "k8s.io/api/core/v1"
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"

certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
Expand Down Expand Up @@ -60,6 +61,37 @@ var _ = Describe("certmanager module", func() {
g.Expect(issuer.Spec.SelfSigned).NotTo(BeNil())
g.Expect(issuer.ObjectMeta.Labels["f"]).To(Equal("l"))
}, timeout, interval).Should(Succeed())
Eventually(func(g Gomega) {
_, err := certmanager.GetIssuerByLabels(
th.Ctx,
h,
names.SelfSignedIssuerName.Namespace,
map[string]string{"not": "exist"})
g.Expect(err).To(HaveOccurred())
g.Expect(k8s_errors.IsNotFound(err)).To(BeTrue())
}, timeout, interval).Should(Succeed())

// Create another issuer with same labels to test
// GetIssuerByLabels retrieving >1 issuers
i = certmanager.NewIssuer(
certmanager.SelfSignedIssuer(
"anotherissuer",
namespace,
map[string]string{"f": "l"},
),
timeout,
)
_, err = i.CreateOrPatch(ctx, h)
Expect(err).ShouldNot(HaveOccurred())
Eventually(func(g Gomega) {
_, err := certmanager.GetIssuerByLabels(
th.Ctx,
h,
names.SelfSignedIssuerName.Namespace,
map[string]string{"f": "l"})
g.Expect(err).To(HaveOccurred())
g.Expect(err.Error()).Should(ContainSubstring("more then one issuer found in namespace"))
}, timeout, interval).Should(Succeed())
})

It("creates CA issuer", func() {
Expand Down

0 comments on commit 7f3f843

Please sign in to comment.