@@ -60,6 +60,7 @@ import (
6060
6161	kstatus "github.com/fluxcd/cli-utils/pkg/kstatus/status" 
6262	"github.com/fluxcd/pkg/apis/meta" 
63+ 	"github.com/fluxcd/pkg/auth" 
6364	"github.com/fluxcd/pkg/git" 
6465	"github.com/fluxcd/pkg/oci" 
6566	"github.com/fluxcd/pkg/runtime/conditions" 
@@ -2971,10 +2972,10 @@ func TestOCIRepository_getArtifactRef(t *testing.T) {
29712972	}
29722973}
29732974
2974- func  TestOCIRepository_stalled (t  * testing.T ) {
2975+ func  TestOCIRepository_invalidURL (t  * testing.T ) {
29752976	g  :=  NewWithT (t )
29762977
2977- 	ns , err  :=  testEnv .CreateNamespace (ctx , "ocirepository-stalled -test" )
2978+ 	ns , err  :=  testEnv .CreateNamespace (ctx , "ocirepository-invalid-url -test" )
29782979	g .Expect (err ).ToNot (HaveOccurred ())
29792980	defer  func () { g .Expect (testEnv .Delete (ctx , ns )).To (Succeed ()) }()
29802981
@@ -3013,6 +3014,74 @@ func TestOCIRepository_stalled(t *testing.T) {
30133014	g .Expect (stalledCondition .Reason ).Should (Equal (sourcev1 .URLInvalidReason ))
30143015}
30153016
3017+ func  TestOCIRepository_objectLevelWorkloadIdentityFeatureGate (t  * testing.T ) {
3018+ 	g  :=  NewWithT (t )
3019+ 
3020+ 	ns , err  :=  testEnv .CreateNamespace (ctx , "ocirepository-olwifg-test" )
3021+ 	g .Expect (err ).ToNot (HaveOccurred ())
3022+ 	defer  func () { g .Expect (testEnv .Delete (ctx , ns )).To (Succeed ()) }()
3023+ 
3024+ 	err  =  testEnv .Create (ctx , & corev1.ServiceAccount {
3025+ 		ObjectMeta : metav1.ObjectMeta {
3026+ 			Namespace : ns .Name ,
3027+ 			Name :      "test" ,
3028+ 		},
3029+ 	})
3030+ 	g .Expect (err ).NotTo (HaveOccurred ())
3031+ 
3032+ 	obj  :=  & ociv1.OCIRepository {
3033+ 		ObjectMeta : metav1.ObjectMeta {
3034+ 			GenerateName : "ocirepository-reconcile" ,
3035+ 			Namespace :    ns .Name ,
3036+ 		},
3037+ 		Spec : ociv1.OCIRepositorySpec {
3038+ 			URL :                "oci://ghcr.io/stefanprodan/manifests/podinfo" ,
3039+ 			Interval :           metav1.Duration {Duration : 60  *  time .Minute },
3040+ 			Provider :           "aws" ,
3041+ 			ServiceAccountName : "test" ,
3042+ 		},
3043+ 	}
3044+ 
3045+ 	g .Expect (testEnv .Create (ctx , obj )).To (Succeed ())
3046+ 
3047+ 	key  :=  client.ObjectKey {Name : obj .Name , Namespace : obj .Namespace }
3048+ 	resultobj  :=  & ociv1.OCIRepository {}
3049+ 
3050+ 	g .Eventually (func () bool  {
3051+ 		if  err  :=  testEnv .Get (ctx , key , resultobj ); err  !=  nil  {
3052+ 			return  false 
3053+ 		}
3054+ 		return  conditions .IsStalled (resultobj )
3055+ 	}).Should (BeTrue ())
3056+ 
3057+ 	stalledCondition  :=  conditions .Get (resultobj , meta .StalledCondition )
3058+ 	g .Expect (stalledCondition ).ToNot (BeNil ())
3059+ 	g .Expect (stalledCondition .Reason ).Should (Equal (meta .FeatureGateDisabledReason ))
3060+ 	g .Expect (stalledCondition .Message ).Should (Equal ("to use spec.serviceAccountName for provider authentication please enable the ObjectLevelWorkloadIdentity feature gate in the controller" ))
3061+ 
3062+ 	t .Setenv (auth .EnvVarEnableObjectLevelWorkloadIdentity , "true" )
3063+ 
3064+ 	g .Eventually (func () bool  {
3065+ 		if  err  :=  testEnv .Get (ctx , key , resultobj ); err  !=  nil  {
3066+ 			return  false 
3067+ 		}
3068+ 		resultobj .Annotations  =  map [string ]string {
3069+ 			meta .ReconcileRequestAnnotation : time .Now ().Format (time .RFC3339 ),
3070+ 		}
3071+ 		return  testEnv .Update (ctx , resultobj ) ==  nil 
3072+ 	}).Should (BeTrue ())
3073+ 
3074+ 	g .Expect (testEnv .Update (ctx , resultobj )).To (Succeed ())
3075+ 	g .Eventually (func () bool  {
3076+ 		if  err  :=  testEnv .Get (ctx , key , resultobj ); err  !=  nil  {
3077+ 			return  false 
3078+ 		}
3079+ 		logOCIRepoStatus (t , resultobj )
3080+ 		return  ! conditions .IsReady (resultobj ) && 
3081+ 			conditions .GetReason (resultobj , meta .ReadyCondition ) ==  sourcev1 .AuthenticationFailedReason 
3082+ 	}).Should (BeTrue ())
3083+ }
3084+ 
30163085func  TestOCIRepository_reconcileStorage (t  * testing.T ) {
30173086	tests  :=  []struct  {
30183087		name              string 
0 commit comments