From 27236eef16d532bd7979bf56289724ef236ebef3 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Tue, 3 Dec 2024 10:49:47 +0100
Subject: [PATCH] OZG-7000 OZG-7219 Set properties for feature toggles

---
 src/main/helm/templates/deployment.yaml     | 12 ++++
 src/main/resources/application-dev.yaml     |  6 +-
 src/main/resources/application-e2e.yaml     |  8 ++-
 src/main/resources/application-local.yaml   |  4 ++
 src/test/helm/deployment_features_test.yaml | 78 +++++++++++++++++++++
 5 files changed, 106 insertions(+), 2 deletions(-)
 create mode 100644 src/test/helm/deployment_features_test.yaml

diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml
index b554d57c..54775001 100644
--- a/src/main/helm/templates/deployment.yaml
+++ b/src/main/helm/templates/deployment.yaml
@@ -111,6 +111,18 @@ spec:
             value: {{ .Values.zufiManager.address }}
           - name: grpc_client_zufi-manager_negotiationType
             value: {{ (.Values.zufiManager).grpcClientNegotiationType | default "TLS" }}
+          {{- if ((.Values.ozgcloud).feature).postfach }}
+          - name: ozgcloud_feature_postfach
+            value: {{ .Values.ozgcloud.feature.postfach | quote }}
+          {{- end }}
+          {{- if ((.Values.ozgcloud).feature).benutzerRollen }}
+          - name: ozgcloud_feature_benutzerRollen
+            value: {{ .Values.ozgcloud.feature.benutzerRollen | quote }}
+          {{- end }}
+          {{- if ((.Values.ozgcloud).feature).organisationsEinheiten }}
+          - name: ozgcloud_feature_organisationsEinheiten
+            value: {{ .Values.ozgcloud.feature.organisationsEinheiten | quote }}
+          {{- end }}
         envFrom:
           {{- if (.Values.database).useExternal }}
           - secretRef:
diff --git a/src/main/resources/application-dev.yaml b/src/main/resources/application-dev.yaml
index 691b5933..43f58936 100644
--- a/src/main/resources/application-dev.yaml
+++ b/src/main/resources/application-dev.yaml
@@ -3,4 +3,8 @@ ozgcloud:
   administration:
     sync:
       organisationseinheiten:
-        cron: "* */5 * * * *"
\ No newline at end of file
+        cron: "* */5 * * * *"
+  feature:
+    postfach: true
+    benutzerRollen: true
+    organisationsEinheiten: true
\ No newline at end of file
diff --git a/src/main/resources/application-e2e.yaml b/src/main/resources/application-e2e.yaml
index 864d289e..1ca78e90 100644
--- a/src/main/resources/application-e2e.yaml
+++ b/src/main/resources/application-e2e.yaml
@@ -8,4 +8,10 @@ server:
 
 management:
   server:
-    port: 8081
\ No newline at end of file
+    port: 8081
+
+ozgcloud:
+  feature:
+    postfach: true
+    benutzer-rollen: true
+    organisations-einheiten: true
\ No newline at end of file
diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml
index b39daf33..99608d21 100644
--- a/src/main/resources/application-local.yaml
+++ b/src/main/resources/application-local.yaml
@@ -17,6 +17,10 @@ ozgcloud:
     api:
       user: administrationApiUser
       password: administrationApiUser
+  feature:
+    postfach: true
+    benutzer-rollen: true
+    organisations-einheiten: true
 
 grpc:
   client:
diff --git a/src/test/helm/deployment_features_test.yaml b/src/test/helm/deployment_features_test.yaml
new file mode 100644
index 00000000..b0f29d2d
--- /dev/null
+++ b/src/test/helm/deployment_features_test.yaml
@@ -0,0 +1,78 @@
+#
+# 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 feature properties
+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 feature properties if values are missing
+    asserts:
+      - notContains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: ozgcloud_feature_postfach
+          any: true
+      - notContains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: ozgcloud_feature_benutzerRollen
+          any: true
+      - notContains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: ozgcloud_feature_organisationsEinheiten
+          any: true
+  - it: should set (optional) feature properties
+    set:
+      ozgcloud:
+        feature:
+          postfach: true
+          benutzerRollen: true
+          organisationsEinheiten: true
+    asserts:
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: ozgcloud_feature_postfach
+            value: "true"
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name:  ozgcloud_feature_benutzerRollen
+            value: "true"
+      - contains:
+          path: spec.template.spec.containers[0].env
+          content:
+            name: ozgcloud_feature_organisationsEinheiten
+            value: "true"
\ No newline at end of file
-- 
GitLab