@@ -396,4 +396,53 @@ var _ = Describe("ScalityUIComponentExposer Controller", func() {
396
396
_ = k8sClient .Delete (ctx , uiWithNetworks )
397
397
})
398
398
})
399
+
400
+ Context ("When testing path handling" , func () {
401
+ It ("should preserve original path format without forcing trailing slashes" , func () {
402
+ networks := & uiv1alpha1.UINetworks {
403
+ Host : "test.example.com" ,
404
+ }
405
+
406
+ By ("Testing path without trailing slash - should remain as-is" )
407
+ rules := getIngressRules (networks , "/test-component" )
408
+ Expect (rules ).To (HaveLen (1 ))
409
+ Expect (rules [0 ].Host ).To (Equal ("test.example.com" ))
410
+ Expect (rules [0 ].Path ).To (Equal ("/test-component" ))
411
+
412
+ By ("Testing path with trailing slash - should remain as-is" )
413
+ rules = getIngressRules (networks , "/test-component/" )
414
+ Expect (rules ).To (HaveLen (1 ))
415
+ Expect (rules [0 ].Path ).To (Equal ("/test-component/" ))
416
+
417
+ By ("Testing empty path - should default to root" )
418
+ rules = getIngressRules (networks , "" )
419
+ Expect (rules ).To (HaveLen (1 ))
420
+ Expect (rules [0 ].Path ).To (Equal ("/" ))
421
+
422
+ By ("Testing root path - should remain as-is" )
423
+ rules = getIngressRules (networks , "/" )
424
+ Expect (rules ).To (HaveLen (1 ))
425
+ Expect (rules [0 ].Path ).To (Equal ("/" ))
426
+ })
427
+
428
+ It ("should generate flexible nginx rewrite rules for runtime configuration" , func () {
429
+ networks := & uiv1alpha1.UINetworks {
430
+ Host : "test.example.com" ,
431
+ }
432
+
433
+ By ("Testing annotation generation for path without trailing slash" )
434
+ annotations := getIngressAnnotations (networks , "/test-app" , "test-exposer" )
435
+ Expect (annotations ).To (HaveKey ("nginx.ingress.kubernetes.io/configuration-snippet" ))
436
+
437
+ snippet := annotations ["nginx.ingress.kubernetes.io/configuration-snippet" ]
438
+ // Should match both /test-app/.well-known/... and /test-app//.well-known/...
439
+ Expect (snippet ).To (ContainSubstring ("^/test-app/?/?" ))
440
+
441
+ By ("Testing annotation generation for path with trailing slash" )
442
+ annotations = getIngressAnnotations (networks , "/test-app/" , "test-exposer" )
443
+ snippet = annotations ["nginx.ingress.kubernetes.io/configuration-snippet" ]
444
+ // Should normalize to /test-app and still be flexible
445
+ Expect (snippet ).To (ContainSubstring ("^/test-app/?/?" ))
446
+ })
447
+ })
399
448
})
0 commit comments