@@ -200,8 +200,6 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
200200 Expect (runtimeConfig .APIVersion ).To (Equal ("ui.scality.com/v1alpha1" ))
201201 Expect (runtimeConfig .Metadata .Kind ).To (Equal ("" ))
202202 Expect (runtimeConfig .Metadata .Name ).To (Equal (componentName ))
203- Expect (runtimeConfig .Spec .ScalityUI ).To (Equal (uiName ))
204- Expect (runtimeConfig .Spec .ScalityUIComponent ).To (Equal (componentName ))
205203
206204 // Verify no auth configuration since ScalityUI doesn't have auth and exposer doesn't specify auth
207205 authConfig := runtimeConfig .Spec .Auth
@@ -217,22 +215,19 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
217215 Expect (configMapCondition .Reason ).To (Equal ("ReconcileSucceeded" ))
218216 })
219217
220- It ("should handle complete custom auth configuration" , func () {
221- By ("Creating the custom resource with complete auth configuration" )
218+ It ("should correctly add auth configuration from ScalityUI to runtime configuration" , func () {
219+ By ("Creating ScalityUI with auth configuration" )
222220 providerLogout := true
223- exposer := & uiv1alpha1.ScalityUIComponentExposer {
221+ uiWithAuth := & uiv1alpha1.ScalityUI {
224222 TypeMeta : metav1.TypeMeta {
225223 APIVersion : "ui.scality.com/v1alpha1" ,
226- Kind : "ScalityUIComponentExposer " ,
224+ Kind : "ScalityUI " ,
227225 },
228226 ObjectMeta : metav1.ObjectMeta {
229- Name : exposerName ,
227+ Name : "test-ui-with-auth" ,
230228 Namespace : testNamespace ,
231229 },
232- Spec : uiv1alpha1.ScalityUIComponentExposerSpec {
233- ScalityUI : uiName ,
234- ScalityUIComponent : componentName ,
235- AppHistoryBasePath : "/test-app" ,
230+ Spec : uiv1alpha1.ScalityUISpec {
236231 Auth : & uiv1alpha1.AuthConfig {
237232 Kind : "OIDC" ,
238233 ProviderURL : "https://auth.example.com" ,
@@ -242,38 +237,38 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
242237 Scopes : "openid profile email" ,
243238 ProviderLogout : & providerLogout ,
244239 },
245- SelfConfiguration : & runtime.RawExtension {
246- Raw : []byte (`{"url": "/test"}` ),
247- },
248240 },
249241 }
250- Expect (k8sClient .Create (ctx , exposer )).To (Succeed ())
242+ Expect (k8sClient .Create (ctx , uiWithAuth )).To (Succeed ())
251243
252- By ("Reconciling the created resource" )
253- controllerReconciler := NewScalityUIComponentExposerReconcilerForTest (k8sClient , k8sClient .Scheme ())
244+ By ("Creating component and exposer" )
245+ component := createComponent ("test-component-auth" , "/test-component" )
246+ exposer := createExposer ("test-exposer-auth" , "test-ui-with-auth" , "test-component-auth" , nil , nil )
254247
255- _ , err := controllerReconciler . Reconcile ( ctx , reconcile. Request {
256- NamespacedName : typeNamespacedName ,
257- } )
248+ By ( "Reconciling the exposer" )
249+ controllerReconciler := createReconciler ()
250+ _ , err := reconcileExposer ( controllerReconciler , "test-exposer-auth" )
258251 Expect (err ).NotTo (HaveOccurred ())
259252
260- By ("Verifying complete auth configuration in ConfigMap" )
253+ By ("Verifying auth configuration in ConfigMap" )
261254 configMap := & corev1.ConfigMap {}
262- configMapName := componentName + " -runtime-app-configuration"
255+ configMapName := "test-component-auth -runtime-app-configuration"
263256 Eventually (func () error {
264257 return k8sClient .Get (ctx , types.NamespacedName {
265258 Name : configMapName ,
266259 Namespace : testNamespace ,
267260 }, configMap )
268261 }, time .Second * 10 , time .Millisecond * 250 ).Should (Succeed ())
269262
263+ Expect (configMap .Data ).To (HaveKey ("test-exposer-auth" ))
264+
270265 var runtimeConfig MicroAppRuntimeConfiguration
271- err = json .Unmarshal ([]byte (configMap .Data [exposerName ]), & runtimeConfig )
266+ err = json .Unmarshal ([]byte (configMap .Data ["test-exposer-auth" ]), & runtimeConfig )
272267 Expect (err ).NotTo (HaveOccurred ())
273268
274- Expect (runtimeConfig .Metadata .Name ).To (Equal (componentName ))
275-
269+ By ("Checking that auth configuration is correctly populated from ScalityUI" )
276270 authConfig := runtimeConfig .Spec .Auth
271+ Expect (authConfig ).NotTo (BeEmpty ())
277272 Expect (authConfig ["kind" ]).To (Equal ("OIDC" ))
278273 Expect (authConfig ["providerUrl" ]).To (Equal ("https://auth.example.com" ))
279274 Expect (authConfig ["redirectUrl" ]).To (Equal ("/callback" ))
@@ -282,8 +277,10 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
282277 Expect (authConfig ["scopes" ]).To (Equal ("openid profile email" ))
283278 Expect (authConfig ["providerLogout" ]).To (Equal (true ))
284279
285- selfConfig := runtimeConfig .Spec .SelfConfiguration
286- Expect (selfConfig ["url" ]).To (Equal ("/test" ))
280+ By ("Cleaning up" )
281+ _ = k8sClient .Delete (ctx , exposer )
282+ _ = k8sClient .Delete (ctx , component )
283+ _ = k8sClient .Delete (ctx , uiWithAuth )
287284 })
288285
289286 It ("should handle resource not found gracefully" , func () {
@@ -387,7 +384,7 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
387384 ingress := & networkingv1.Ingress {}
388385 Eventually (func () error {
389386 return k8sClient .Get (ctx , types.NamespacedName {
390- Name : "test-exposer-ingress-test-exposer-ingress " , Namespace : testNamespace ,
387+ Name : "test-exposer-ingress" , Namespace : testNamespace ,
391388 }, ingress )
392389 }, time .Second * 10 , time .Millisecond * 250 ).Should (Succeed ())
393390
0 commit comments