Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #596 from philbrookes/gh-578
Browse files Browse the repository at this point in the history
update tests for HTTP expectations with TLS Policy
  • Loading branch information
philbrookes authored Sep 22, 2023
2 parents 0a747a1 + 95b14a2 commit 37d2951
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/integration/tlspolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ var _ = Describe("TLSPolicy", Ordered, func() {
}, TestTimeoutMedium, TestRetryIntervalMedium).ShouldNot(HaveOccurred())
})

It("should not create any certificates", func() {
It("should not create any certificates when TLS is not present", func() {
Consistently(func() []certmanv1.Certificate {
certList := &certmanv1.CertificateList{}
err := k8sClient.List(ctx, certList, &client.ListOptions{Namespace: testNamespace})
Expand All @@ -191,6 +191,25 @@ var _ = Describe("TLSPolicy", Ordered, func() {
}, time.Second*10, time.Second).Should(BeEmpty())
})

It("should create certificate when TLS is present", func() {
certNS := gatewayv1beta1.Namespace(testNamespace)
patch := client.MergeFrom(gateway.DeepCopy())
gateway.Spec.Listeners[0].TLS = &gatewayv1beta1.GatewayTLSConfig{
Mode: Pointer(gatewayv1beta1.TLSModeTerminate),
CertificateRefs: []gatewayv1beta1.SecretObjectReference{
{
Name: "test-tls-secret",
Namespace: &certNS,
},
},
}
Expect(k8sClient.Patch(ctx, gateway, patch)).To(BeNil())
Eventually(func() error {
cert := &certmanv1.Certificate{}
return k8sClient.Get(ctx, client.ObjectKey{Name: "test-tls-secret", Namespace: testNamespace}, cert)
}, time.Second*10, time.Second).Should(BeNil())
})

})

Context("with https listener", func() {
Expand Down

0 comments on commit 37d2951

Please sign in to comment.