@@ -200,8 +200,6 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
200
200
Expect (runtimeConfig .APIVersion ).To (Equal ("ui.scality.com/v1alpha1" ))
201
201
Expect (runtimeConfig .Metadata .Kind ).To (Equal ("" ))
202
202
Expect (runtimeConfig .Metadata .Name ).To (Equal (componentName ))
203
- Expect (runtimeConfig .Spec .ScalityUI ).To (Equal (uiName ))
204
- Expect (runtimeConfig .Spec .ScalityUIComponent ).To (Equal (componentName ))
205
203
206
204
// Verify no auth configuration since ScalityUI doesn't have auth and exposer doesn't specify auth
207
205
authConfig := runtimeConfig .Spec .Auth
@@ -217,22 +215,19 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
217
215
Expect (configMapCondition .Reason ).To (Equal ("ReconcileSucceeded" ))
218
216
})
219
217
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" )
222
220
providerLogout := true
223
- exposer := & uiv1alpha1.ScalityUIComponentExposer {
221
+ uiWithAuth := & uiv1alpha1.ScalityUI {
224
222
TypeMeta : metav1.TypeMeta {
225
223
APIVersion : "ui.scality.com/v1alpha1" ,
226
- Kind : "ScalityUIComponentExposer " ,
224
+ Kind : "ScalityUI " ,
227
225
},
228
226
ObjectMeta : metav1.ObjectMeta {
229
- Name : exposerName ,
227
+ Name : "test-ui-with-auth" ,
230
228
Namespace : testNamespace ,
231
229
},
232
- Spec : uiv1alpha1.ScalityUIComponentExposerSpec {
233
- ScalityUI : uiName ,
234
- ScalityUIComponent : componentName ,
235
- AppHistoryBasePath : "/test-app" ,
230
+ Spec : uiv1alpha1.ScalityUISpec {
236
231
Auth : & uiv1alpha1.AuthConfig {
237
232
Kind : "OIDC" ,
238
233
ProviderURL : "https://auth.example.com" ,
@@ -242,38 +237,38 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
242
237
Scopes : "openid profile email" ,
243
238
ProviderLogout : & providerLogout ,
244
239
},
245
- SelfConfiguration : & runtime.RawExtension {
246
- Raw : []byte (`{"url": "/test"}` ),
247
- },
248
240
},
249
241
}
250
- Expect (k8sClient .Create (ctx , exposer )).To (Succeed ())
242
+ Expect (k8sClient .Create (ctx , uiWithAuth )).To (Succeed ())
251
243
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 )
254
247
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" )
258
251
Expect (err ).NotTo (HaveOccurred ())
259
252
260
- By ("Verifying complete auth configuration in ConfigMap" )
253
+ By ("Verifying auth configuration in ConfigMap" )
261
254
configMap := & corev1.ConfigMap {}
262
- configMapName := componentName + " -runtime-app-configuration"
255
+ configMapName := "test-component-auth -runtime-app-configuration"
263
256
Eventually (func () error {
264
257
return k8sClient .Get (ctx , types.NamespacedName {
265
258
Name : configMapName ,
266
259
Namespace : testNamespace ,
267
260
}, configMap )
268
261
}, time .Second * 10 , time .Millisecond * 250 ).Should (Succeed ())
269
262
263
+ Expect (configMap .Data ).To (HaveKey ("test-exposer-auth" ))
264
+
270
265
var runtimeConfig MicroAppRuntimeConfiguration
271
- err = json .Unmarshal ([]byte (configMap .Data [exposerName ]), & runtimeConfig )
266
+ err = json .Unmarshal ([]byte (configMap .Data ["test-exposer-auth" ]), & runtimeConfig )
272
267
Expect (err ).NotTo (HaveOccurred ())
273
268
274
- Expect (runtimeConfig .Metadata .Name ).To (Equal (componentName ))
275
-
269
+ By ("Checking that auth configuration is correctly populated from ScalityUI" )
276
270
authConfig := runtimeConfig .Spec .Auth
271
+ Expect (authConfig ).NotTo (BeEmpty ())
277
272
Expect (authConfig ["kind" ]).To (Equal ("OIDC" ))
278
273
Expect (authConfig ["providerUrl" ]).To (Equal ("https://auth.example.com" ))
279
274
Expect (authConfig ["redirectUrl" ]).To (Equal ("/callback" ))
@@ -282,8 +277,10 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
282
277
Expect (authConfig ["scopes" ]).To (Equal ("openid profile email" ))
283
278
Expect (authConfig ["providerLogout" ]).To (Equal (true ))
284
279
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 )
287
284
})
288
285
289
286
It ("should handle resource not found gracefully" , func () {
@@ -387,7 +384,7 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
387
384
ingress := & networkingv1.Ingress {}
388
385
Eventually (func () error {
389
386
return k8sClient .Get (ctx , types.NamespacedName {
390
- Name : "test-exposer-ingress-test-exposer-ingress " , Namespace : testNamespace ,
387
+ Name : "test-exposer-ingress" , Namespace : testNamespace ,
391
388
}, ingress )
392
389
}, time .Second * 10 , time .Millisecond * 250 ).Should (Succeed ())
393
390
0 commit comments