Skip to content

Commit e04554e

Browse files
committed
fix: use ScalityUI auth instead of exposer-specific auth
ci: update Docker workflow feat: add auth configuration handling in ScalityUIComponentExposer tests refactor: update exposer naming and ingress handling for improved clarity and consistency
1 parent a20f158 commit e04554e

File tree

4 files changed

+30
-35
lines changed

4 files changed

+30
-35
lines changed

internal/controller/scalityuicomponentexposer/configmap.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (r *ScalityUIComponentExposerReconciler) buildRuntimeConfiguration(
109109
ui *uiv1alpha1.ScalityUI,
110110
component *uiv1alpha1.ScalityUIComponent,
111111
) (MicroAppRuntimeConfiguration, error) {
112-
authConfig, err := utils.BuildAuthConfig(exposer.Spec.Auth)
112+
authConfig, err := utils.BuildAuthConfig(ui.Spec.Auth)
113113
if err != nil {
114114
return MicroAppRuntimeConfiguration{}, fmt.Errorf("failed to build auth config: %w", err)
115115
}
@@ -130,11 +130,9 @@ func (r *ScalityUIComponentExposerReconciler) buildRuntimeConfiguration(
130130
Name: component.Name,
131131
},
132132
Spec: MicroAppRuntimeConfigurationSpec{
133-
ScalityUI: ui.Name,
134-
ScalityUIComponent: component.Name,
135-
AppHistoryBasePath: exposer.Spec.AppHistoryBasePath,
136133
Auth: authConfig,
137134
SelfConfiguration: selfConfig,
135+
AppHistoryBasePath: exposer.Spec.AppHistoryBasePath,
138136
},
139137
}, nil
140138
}

internal/controller/scalityuicomponentexposer/controller_test.go

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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

internal/controller/scalityuicomponentexposer/ingress.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func newScalityUIComponentExposerIngressReconciler(cr ScalityUIComponentExposer,
6565
AutoGenerateTLS: false, // We'll handle TLS manually if needed
6666
SkipTLS: shouldSkipTLS(networksConfig),
6767
ComputeName: func(subresourceType string, componentClass string) string {
68-
return cr.Name // Use exposer name as ingress name
68+
return subresourceType // Return subresourceType to avoid duplication
6969
},
7070
Annotations: getIngressAnnotations(networksConfig, path, cr.Name),
7171
},
@@ -155,6 +155,8 @@ func (r *scalityUIComponentExposerIngressReconciler) NewReferenceResource() (*ne
155155
return nil, nil
156156
}
157157

158+
ingress.Name = r.CR.Name
159+
158160
// Get dependencies to configure TLS
159161
ctx := r.CurrentState.GetContext()
160162
_, ui, err := validateAndFetchDependencies(ctx, r.CR, r.CurrentState, r.CurrentState.GetLog())

internal/controller/scalityuicomponentexposer/types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ type MicroAppRuntimeConfigurationMetadata struct {
1616

1717
// MicroAppRuntimeConfigurationSpec represents the spec section
1818
type MicroAppRuntimeConfigurationSpec struct {
19-
ScalityUI string `json:"scalityUI"`
20-
ScalityUIComponent string `json:"scalityUIComponent"`
2119
AppHistoryBasePath string `json:"appHistoryBasePath,omitempty"`
2220
Auth map[string]interface{} `json:"auth,omitempty"`
2321
SelfConfiguration map[string]interface{} `json:"selfConfiguration,omitempty"`

0 commit comments

Comments
 (0)