From 767726456f074cbfc9a7d4780b05fd9fc7583d8c Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Fri, 9 Dec 2022 21:09:09 +0100
Subject: [PATCH] OZG-3184 - fix cors header with minor helm cleanup

---
 src/main/helm/templates/_helpers.tpl        | 30 -----------------
 src/main/helm/test-values.yaml              | 31 ------------------
 src/main/helm/values.yaml                   | 15 +--------
 src/test/helm/api-password-secret_test.yaml |  9 ++++--
 src/test/helm/deployment-test.yaml          |  3 ++
 src/test/helm/ingress_nginx_cors_test.yaml  |  2 +-
 src/test/unit-values.yaml                   | 36 ---------------------
 7 files changed, 11 insertions(+), 115 deletions(-)
 delete mode 100644 src/main/helm/test-values.yaml

diff --git a/src/main/helm/templates/_helpers.tpl b/src/main/helm/templates/_helpers.tpl
index e9901580..3599981a 100644
--- a/src/main/helm/templates/_helpers.tpl
+++ b/src/main/helm/templates/_helpers.tpl
@@ -52,14 +52,6 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
 {{- printf "%d %d * * *" (div (randNumeric 2) 2) (div (randNumeric 1) 2) -}}
 {{- end -}}
 
-#{{- define "app.envSpringProfiles" }}
-#{{- if (.Values.env).overrideSpringProfiles -}}
-#{{ printf "%s" (.Values.env).overrideSpringProfiles }}
-#{{- else -}}
-#{{ printf "oc, %s" (include "app.kopEnvironment" . ) }}
-#{{- end -}}
-#{{- end -}}
-
 {{- define "app.kopEnvironment" -}}
 {{- required "Environment muss angegeben sein" (.Values.kop).environment -}}
 {{- end -}}
@@ -86,24 +78,6 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
 {{- end }}
 {{- end -}}
 
-{{- define "app.mongodb.resources" }}
-{{- if eq (include "app.kopEnvironment" . ) "prod" }}
-  limits:
-    cpu: 250m
-    memory: "2000Mi"
-  requests:
-    cpu: "50m"
-    memory: "800Mi"
-{{- else }}
-  limits:
-    cpu: 250m
-    memory: "2000Mi"
-  requests:
-    cpu: "50m"
-    memory: "500Mi"
-{{- end }}
-{{- end -}}
-
 {{- define "app.ssoServerUrl" -}}
 {{- if contains "https://" .Values.sso.serverUrl -}}
 {{- .Values.sso.serverUrl -}}
@@ -141,7 +115,3 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
 {{- define "app.goofyAddress" -}}
 {{ printf "https://%s.%s" (include "app.kopBezeichner" .) .Values.baseUrl }}
 {{- end -}}
-
-{{- define "app.accessControlHeaders" -}}
-{{ printf "Access-Control-Allow-Origin:%s||Access-Control-Allow-Methods:GET,POST,OPTIONS||Access-Control-Allow-Headers:DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range||Access-Control-Expose-Headers:Content-Length,Content-Range" (include "app.goofyAddress" .) }}
-{{- end -}}
\ No newline at end of file
diff --git a/src/main/helm/test-values.yaml b/src/main/helm/test-values.yaml
deleted file mode 100644
index f836f16e..00000000
--- a/src/main/helm/test-values.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2022 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.
-#
-
-database:
-  password: changeme
-
-kop:
-  bundesland: sh
-  bezeichner: helm
-  environment: test
\ No newline at end of file
diff --git a/src/main/helm/values.yaml b/src/main/helm/values.yaml
index 94c49968..3f8e1863 100644
--- a/src/main/helm/values.yaml
+++ b/src/main/helm/values.yaml
@@ -24,26 +24,13 @@
 
 cluster_env: ""
 
-baseUrl: test.sh.kop-cloud.de
-sso:
-  serverUrl: sso.test.by.kop-cloud.de
-
 replicaCount: 2
-replicaCountDatabase: 3
 
 image:
   repo: docker.ozg-sh.de
   name: user-manager
   tag: latest # [default: latest]
 
-resources:
-  limits:
-    cpu: 1
-    memory: 1200Mi
-  requests:
-    cpu: 50m
-    memory: 16Mi
-
 database: # username is always <release-name>-database-user
   backup:
     disabled: false
@@ -69,5 +56,5 @@ ingress:
   configuration_snippet:
     nginx.ingress.kubernetes.io/configuration-snippet: |
       more_set_headers "Access-Control-Allow-Methods: GET,PATCH,OPTIONS";
-      more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization";
+      more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-XSRF-TOKEN";
       more_set_headers "Access-Control-Expose-Headers: Content-Length,Content-Range";
diff --git a/src/test/helm/api-password-secret_test.yaml b/src/test/helm/api-password-secret_test.yaml
index 4493ea77..0dccd697 100644
--- a/src/test/helm/api-password-secret_test.yaml
+++ b/src/test/helm/api-password-secret_test.yaml
@@ -5,9 +5,12 @@ release:
 templates:
   - templates/api-password-secret.yaml
 tests:
-  - it: test api password
+  - it: test api secret kind
     asserts:
       - isKind:
           of: Secret
-      - isNotEmpty:
-          path: stringData.password
\ No newline at end of file
+  - it: test api password 
+    asserts:
+      - equal:
+          path: stringData.password
+          value: geheim
\ No newline at end of file
diff --git a/src/test/helm/deployment-test.yaml b/src/test/helm/deployment-test.yaml
index 5dbf3af6..85d43856 100644
--- a/src/test/helm/deployment-test.yaml
+++ b/src/test/helm/deployment-test.yaml
@@ -38,3 +38,6 @@ tests:
       - equal:
           path: spec.template.spec.containers[0].image
           value: docker.ozg-sh.de/user-manager:latest
+      - equal:
+          path: spec.replicas
+          value: 2
diff --git a/src/test/helm/ingress_nginx_cors_test.yaml b/src/test/helm/ingress_nginx_cors_test.yaml
index 52bd2527..82fab184 100644
--- a/src/test/helm/ingress_nginx_cors_test.yaml
+++ b/src/test/helm/ingress_nginx_cors_test.yaml
@@ -37,7 +37,7 @@ tests:
           path: metadata.annotations.[nginx.ingress.kubernetes.io/configuration-snippet]
           value: |
                    more_set_headers "Access-Control-Allow-Methods: GET,PATCH,OPTIONS";
-                   more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization";
+                   more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-XSRF-TOKEN";
                    more_set_headers "Access-Control-Expose-Headers: Content-Length,Content-Range";
 
                    more_set_headers "Access-Control-Allow-Origin: https://helm.test.sh.kop-cloud.de";
diff --git a/src/test/unit-values.yaml b/src/test/unit-values.yaml
index 932445da..858c3cae 100644
--- a/src/test/unit-values.yaml
+++ b/src/test/unit-values.yaml
@@ -37,39 +37,3 @@ kop:
 sso:
   serverUrl: sso.test.sh.kop-cloud.de
 
-image:
-  repo: docker.ozg-sh.de
-  name: user-manager
-  tag: latest # [default: latest]
-
-replicaCount: 2
-replicaCountDatabase: 3
-
-resources:
-  limits:
-    cpu: 1
-    memory: 1200Mi
-  requests:
-    cpu: 50m
-    memory: 16Mi
-
-database: # username is always <release-name>-database-user
-  password: hase
-  backup:
-    disabled: false
-    nfs:
-      server: "10.61.132.81"
-      mount_path: "/mnt/backups/mongodb/"
-
-imageCredentials:
-  registry: docker.ozg-sh.de
-  username: kop
-  password: Ymtbek3BWR8v
-  email: webmaster@ozg-sh.de
-
-ingress:
-  configuration_snippet:
-    nginx.ingress.kubernetes.io/configuration-snippet: |
-      more_set_headers "Access-Control-Allow-Methods: GET,PATCH,OPTIONS";
-      more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization";
-      more_set_headers "Access-Control-Expose-Headers: Content-Length,Content-Range";
-- 
GitLab