Skip to content

Commit c8db2e3

Browse files
committed
Fix BMCSecret webhook unit test
1 parent c890911 commit c8db2e3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/webhook/v1alpha1/bmcsecret_webhook_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"k8s.io/utils/ptr"
1111

1212
metalv1alpha1 "github.com/ironcore-dev/metal-operator/api/v1alpha1"
13+
. "sigs.k8s.io/controller-runtime/pkg/envtest/komega"
1314
)
1415

1516
var _ = Describe("BMCSecret Webhook", func() {
@@ -31,7 +32,6 @@ var _ = Describe("BMCSecret Webhook", func() {
3132
"username": []byte("admin"),
3233
"password": []byte("adminpass"),
3334
},
34-
Immutable: ptr.To(true),
3535
}
3636
By("Creating an BMCSecret")
3737
Expect(k8sClient.Create(ctx, BMCSecret)).To(Succeed())
@@ -40,6 +40,11 @@ var _ = Describe("BMCSecret Webhook", func() {
4040

4141
Context("When creating or updating BMCSecret under Validating Webhook", func() {
4242
It("Should deny Update BMCSecret if Immutable is set to True", func(ctx SpecContext) {
43+
By("Setting Immutable to True")
44+
Eventually(Update(BMCSecret, func() {
45+
BMCSecret.Immutable = ptr.To(true)
46+
})).Should(Succeed())
47+
4348
By("Updating an BMCSecret with Immutable set to True")
4449
BMCSecretUpdated := BMCSecret.DeepCopy()
4550
BMCSecretUpdated.Data["username"] = []byte("newadmin")

0 commit comments

Comments
 (0)