Skip to content

Commit

Permalink
Merge pull request #719 from fabriziosestito/fix/flaky-webhook-nil-la…
Browse files Browse the repository at this point in the history
…bels-annotations-test

fix: flaky webhook nil labels/annotations test
  • Loading branch information
viccuad authored Apr 15, 2024
2 parents 685769c + c0682bc commit 73b58b8
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions controllers/admissionpolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ var _ = Describe("AdmissionPolicy controller", func() {
HaveField("Webhooks", Equal(originalValidatingWebhookConfiguration.Webhooks)),
),
)
})

It("should reconcile unitialized label and annotation maps (behavior of Kubewarden <= 1.9.0))", func() {
By("changing the ValidatingWebhookConfiguration")
validatingWebhookConfiguration, err := getTestValidatingWebhookConfiguration(fmt.Sprintf("namespaced-%s-%s", policyNamespace, policyName))
Expect(err).ToNot(HaveOccurred())
originalValidatingWebhookConfiguration := validatingWebhookConfiguration.DeepCopy()
// simulate unitialized labels and annotation maps (behaviour of Kubewarden <= 1.9.0), or user change
By("setting the ValidatingWebhookConfiguration labels and annotation to nil")
validatingWebhookConfiguration, err = getTestValidatingWebhookConfiguration(fmt.Sprintf("namespaced-%s-%s", policyNamespace, policyName))
Expect(err).ToNot(HaveOccurred())
originalValidatingWebhookConfiguration = validatingWebhookConfiguration.DeepCopy()
validatingWebhookConfiguration.Labels = nil
validatingWebhookConfiguration.Annotations = nil
Expect(
Expand Down Expand Up @@ -230,14 +228,12 @@ var _ = Describe("AdmissionPolicy controller", func() {
HaveField("Webhooks", Equal(originalMutatingWebhookConfiguration.Webhooks)),
),
)
})

It("should reconcile unitialized label and annotation maps (behavior of Kubewarden <= 1.9.0))", func() {
By("changing the MutatingWebhookConfiguration")
mutatingWebhookConfiguration, err := getTestMutatingWebhookConfiguration(fmt.Sprintf("namespaced-%s-%s", policyNamespace, policyName))
Expect(err).ToNot(HaveOccurred())
originalMutatingWebhookConfiguration := mutatingWebhookConfiguration.DeepCopy()
// simulate unitialized labels and annotation maps (behaviour of Kubewarden <= 1.9.0), or user change
By("by setting the MutatingWebhookConfiguration labels and annotation to nil")
mutatingWebhookConfiguration, err = getTestMutatingWebhookConfiguration(fmt.Sprintf("namespaced-%s-%s", policyNamespace, policyName))
Expect(err).ToNot(HaveOccurred())
originalMutatingWebhookConfiguration = mutatingWebhookConfiguration.DeepCopy()
mutatingWebhookConfiguration.Labels = nil
mutatingWebhookConfiguration.Annotations = nil
Expect(
Expand Down

0 comments on commit 73b58b8

Please sign in to comment.