From 9a203123891023ed187b2fcd39cffa1e55fe5956 Mon Sep 17 00:00:00 2001
From: Felix Reichenbach <felix.reichenbach@mgm-tp.com>
Date: Wed, 8 Jan 2025 17:27:51 +0100
Subject: [PATCH] OZG-6741 configure zufi searchUri via helm

---
 src/main/helm/templates/deployment.yaml     |  4 +
 src/test/helm/deployment_features_test.yaml |  6 +-
 src/test/helm/deployment_zufi_test.yaml     | 83 +++++++++++++++++++++
 3 files changed, 91 insertions(+), 2 deletions(-)
 create mode 100644 src/test/helm/deployment_zufi_test.yaml

diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml
index 54775001..79e17f06 100644
--- a/src/main/helm/templates/deployment.yaml
+++ b/src/main/helm/templates/deployment.yaml
@@ -123,6 +123,10 @@ spec:
           - name: ozgcloud_feature_organisationsEinheiten
             value: {{ .Values.ozgcloud.feature.organisationsEinheiten | quote }}
           {{- end }}
+          {{- if eq ((.Values.ozgcloud).feature).organisationsEinheiten "true" }}
+          - name: ozgcloud_organisationseinheit_zufisucheuri
+            value: {{ required "ozgcloud.organisationsEinheit.zufiSearchUri must be set if feature organisationsEinheiten is activated" ((.Values.ozgcloud).organisationsEinheit).zufiSearchUri}}
+          {{- end }}
         envFrom:
           {{- if (.Values.database).useExternal }}
           - secretRef:
diff --git a/src/test/helm/deployment_features_test.yaml b/src/test/helm/deployment_features_test.yaml
index 9e02c58d..9d32ac54 100644
--- a/src/test/helm/deployment_features_test.yaml
+++ b/src/test/helm/deployment_features_test.yaml
@@ -60,6 +60,8 @@ tests:
           postfach: "true"
           benutzerRollen: "true"
           organisationsEinheiten: "true"
+        organisationsEinheit:
+          zufiSearchUri: alfa/zufi/search/endpoint?searchBy={searchBy}
     asserts:
       - contains:
           path: spec.template.spec.containers[0].env
@@ -69,7 +71,7 @@ tests:
       - contains:
           path: spec.template.spec.containers[0].env
           content:
-            name:  ozgcloud_feature_benutzerRollen
+            name: ozgcloud_feature_benutzerRollen
             value: "true"
       - contains:
           path: spec.template.spec.containers[0].env
@@ -98,4 +100,4 @@ tests:
           path: spec.template.spec.containers[0].env
           content:
             name: ozgcloud_feature_organisationsEinheiten
-            value: "false"
\ No newline at end of file
+            value: "false"
diff --git a/src/test/helm/deployment_zufi_test.yaml b/src/test/helm/deployment_zufi_test.yaml
new file mode 100644
index 00000000..ea877367
--- /dev/null
+++ b/src/test/helm/deployment_zufi_test.yaml
@@ -0,0 +1,83 @@
+#
+# Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den
+# Ministerpräsidenten des Landes Schleswig-Holstein
+# Staatskanzlei
+# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
+#
+# Lizenziert unter der EUPL, Version 1.2 oder - sobald
+# diese von der Europäischen Kommission genehmigt wurden -
+# Folgeversionen der EUPL ("Lizenz");
+# Sie dürfen dieses Werk ausschließlich gemäß
+# dieser Lizenz nutzen.
+# Eine Kopie der Lizenz finden Sie hier:
+#
+# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
+#
+# Sofern nicht durch anwendbare Rechtsvorschriften
+# gefordert oder in schriftlicher Form vereinbart, wird
+# die unter der Lizenz verbreitete Software "so wie sie
+# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
+# ausdrücklich oder stillschweigend - verbreitet.
+# Die sprachspezifischen Genehmigungen und Beschränkungen
+# unter der Lizenz sind dem Lizenztext zu entnehmen.
+#
+
+suite: test zufi search property
+release:
+  name: administration
+  namespace: sh-helm-test
+templates:
+  - templates/deployment.yaml
+set:
+  ozgcloud:
+    bundesland: sh
+    bezeichner: helm
+  sso:
+    serverUrl: https://sso.company.local
+  imagePullSecret: image-pull-secret
+tests:
+  - it: should not contain zufi search uri if organisationseinheit feature toggle not set
+    set:
+      ozgcloud:
+        feature:
+          organisationsEinheiten: "false"
+        organisationsEinheit:
+          zufiSearchUri: alfa/zufi/search/endpoint?searchBy={searchBy}
+    asserts:
+      - notContains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: ozgcloud_organisationseinheit_zufisucheuri
+          any: true
+  - it: should not contain zufi search uri if organisationseinheit feature toggle is disabled
+    set:
+      ozgcloud:
+        organisationsEinheit:
+          zufiSearchUri: alfa/zufi/search/endpoint?searchBy={searchBy}
+    asserts:
+      - notContains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: ozgcloud_organisationseinheit_zufisucheuri
+          any: true
+  - it: should set zufi search uri
+    set:
+      ozgcloud:
+        feature:
+          organisationsEinheiten: "true"
+        organisationsEinheit:
+          zufiSearchUri: alfa/zufi/search/endpoint?searchBy={searchBy}
+    asserts:
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: ozgcloud_organisationseinheit_zufisucheuri
+            value: alfa/zufi/search/endpoint?searchBy={searchBy}
+  - it: should fail if zufi search uri is not set
+    set:
+      ozgcloud:
+        feature:
+          organisationsEinheiten: "true"
+    asserts:
+      - failedTemplate:
+          errorMessage: "ozgcloud.organisationsEinheit.zufiSearchUri must be set if feature organisationsEinheiten is activated"
-- 
GitLab