@@ -1132,9 +1132,7 @@ var _ = Describe("With a running MachineSync Reconciler", func() {
11321132 Eventually (k .Object (sentinelMachine ), timeout ).Should (
11331133 HaveField ("Status.AuthoritativeAPI" , Equal (mapiv1beta1 .MachineAuthorityClusterAPI )))
11341134
1135- Eventually (k .Update (sentinelMachine , func () {
1136- sentinelMachine .ObjectMeta .Labels = map [string ]string {"test-sentinel" : "fubar" }
1137- }), timeout ).Should (MatchError (ContainSubstring ("policy in place" )))
1135+ admissiontestutils .VerifySentinelValidation (k , sentinelMachine , timeout )
11381136 })
11391137
11401138 Context ("with status.AuthoritativeAPI: Machine API" , func () {
@@ -1318,9 +1316,7 @@ var _ = Describe("With a running MachineSync Reconciler", func() {
13181316 Eventually (k8sClient .Create (ctx , sentinelMachine )).Should (Succeed ())
13191317
13201318 // Continually try to update the capiMachine to a forbidden field until the VAP blocks it
1321- Eventually (k .Update (sentinelMachine , func () {
1322- sentinelMachine .ObjectMeta .Labels = map [string ]string {"test-sentinel" : "fubar" }
1323- }), timeout ).Should (MatchError (ContainSubstring ("policy in place" )))
1319+ admissiontestutils .VerifySentinelValidation (k , sentinelMachine , timeout )
13241320 })
13251321
13261322 It ("updating the spec.Version should not be allowed" , func () {
@@ -1383,9 +1379,7 @@ var _ = Describe("With a running MachineSync Reconciler", func() {
13831379
13841380 Eventually (k .Get (capiSentinelMachine )).Should (Succeed ())
13851381
1386- Eventually (k .Update (sentinelMachine , func () {
1387- sentinelMachine .ObjectMeta .Labels = map [string ]string {"test-sentinel" : "fubar" }
1388- }), timeout ).Should (MatchError (ContainSubstring ("policy in place" )))
1382+ admissiontestutils .VerifySentinelValidation (k , sentinelMachine , timeout )
13891383 })
13901384
13911385 // The Authoritative API defaults to MachineAPI so we can't test if it's unset.
@@ -1451,9 +1445,7 @@ var _ = Describe("With a running MachineSync Reconciler", func() {
14511445
14521446 Eventually (k .Get (capiSentinelMachine )).Should (Succeed ())
14531447
1454- Eventually (k .Update (sentinelMachine , func () {
1455- sentinelMachine .ObjectMeta .Labels = map [string ]string {"test-sentinel" : "fubar" }
1456- }), timeout ).Should (MatchError (ContainSubstring ("policy in place" )))
1448+ admissiontestutils .VerifySentinelValidation (k , sentinelMachine , timeout )
14571449 })
14581450
14591451 It ("denies updating the AuthoritativeAPI when the machine is in Provisioning" , func () {
@@ -1566,7 +1558,7 @@ var _ = Describe("With a running MachineSync Reconciler", func() {
15661558 warnSink .Reset () // keep each probe self-contained
15671559
15681560 err := warnKomega .Update (sentinelMachine , func () {
1569- sentinelMachine . ObjectMeta . Labels = map [ string ] string { "test-sentinel" : "fubar" }
1561+ admissiontestutils . SetSentinelValidationLabel ( sentinelMachine )
15701562 })()
15711563 g .Expect (err ).NotTo (HaveOccurred ())
15721564
0 commit comments