@@ -30,6 +30,7 @@ import (
3030
3131 "github.com/ProtonMail/go-crypto/openpgp"
3232 "github.com/ProtonMail/go-crypto/openpgp/armor"
33+ "github.com/fluxcd/pkg/apis/acl"
3334 "github.com/go-git/go-billy/v5/memfs"
3435 "github.com/go-git/go-git/v5"
3536 "github.com/go-git/go-git/v5/config"
@@ -268,6 +269,7 @@ Images:
268269 })
269270
270271 AfterEach (func () {
272+ imageAutoReconciler .NoCrossNamespaceRef = false
271273 Expect (k8sClient .Delete (context .Background (), namespace )).To (Succeed ())
272274 })
273275
@@ -290,8 +292,9 @@ Images:
290292
291293 Context ("ref cross-ns GitRepository" , func () {
292294 var (
293- localRepo * git.Repository
294- commitMessage string
295+ localRepo * git.Repository
296+ commitMessage string
297+ updateBySetters * imagev1.ImageUpdateAutomation
295298 )
296299
297300 const (
@@ -410,7 +413,7 @@ Images:
410413 Namespace : namespace .Name ,
411414 Name : "update-test" ,
412415 }
413- updateBySetters : = & imagev1.ImageUpdateAutomation {
416+ updateBySetters = & imagev1.ImageUpdateAutomation {
414417 ObjectMeta : metav1.ObjectMeta {
415418 Name : updateKey .Name ,
416419 Namespace : updateKey .Namespace ,
@@ -465,6 +468,28 @@ Images:
465468 Expect (commit .Author .Name ).To (Equal (authorName ))
466469 Expect (commit .Author .Email ).To (Equal (authorEmail ))
467470 })
471+
472+ It ("fails to reconcile if cross-namespace flag is set" , func () {
473+ imageAutoReconciler .NoCrossNamespaceRef = true
474+
475+ // trigger reconcile
476+ var updatePatch imagev1.ImageUpdateAutomation
477+ Expect (k8sClient .Get (context .TODO (), client .ObjectKeyFromObject (updateBySetters ), & updatePatch )).To (Succeed ())
478+ updatePatch .Spec .Interval = metav1.Duration {Duration : 5 * time .Minute }
479+ Expect (k8sClient .Patch (context .Background (), & updatePatch , client .Merge )).To (Succeed ())
480+
481+ resultAuto := & imagev1.ImageUpdateAutomation {}
482+ var readyCondition * metav1.Condition
483+
484+ Eventually (func () bool {
485+ _ = k8sClient .Get (context .Background (), client .ObjectKeyFromObject (updateBySetters ), resultAuto )
486+ readyCondition = apimeta .FindStatusCondition (resultAuto .Status .Conditions , meta .ReadyCondition )
487+ return apimeta .IsStatusConditionFalse (resultAuto .Status .Conditions , meta .ReadyCondition )
488+ }, timeout , time .Second ).Should (BeTrue ())
489+
490+ Expect (readyCondition ).ToNot (BeNil ())
491+ Expect (readyCondition .Reason ).To (Equal (acl .AccessDeniedReason ))
492+ })
468493 })
469494
470495 Context ("update path" , func () {
0 commit comments