From c167c95e815fb475756374b29a107d938e5c4e48 Mon Sep 17 00:00:00 2001
From: Maarten de Waard <maarten@greenhost.nl>
Date: Thu, 20 Oct 2022 11:12:09 +0200
Subject: [PATCH] fix helmhelm test

---
 CHANGELOG.md                                      |  8 ++++++++
 Chart.yaml                                        |  2 +-
 templates/tests/cypress-test-nc-oo.yaml           |  5 ++---
 templates/tests/nextcoud-sso-password-secret.yaml | 12 ++++++++++++
 values.yaml                                       |  6 ++----
 5 files changed, 25 insertions(+), 8 deletions(-)
 create mode 100644 templates/tests/nextcoud-sso-password-secret.yaml

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 75981c39..710ed44c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
 # Changelog
 
+## [0.14.0] - 2022-10-18
+
+* Fix helm test when you try to use ssoLogin
+
+  To use this fix, you need to change your values.yaml, set
+  `tests.ssoLogin.password` to the password of the SSO user and remove the
+  `tests.ssoLogin.passwordSecret` section.
+
 ## [0.13.3] - 2022-10-06
 
 * Do not accidentally send onlyoffice traffic to cypress pod.
diff --git a/Chart.yaml b/Chart.yaml
index 643aa0e8..56f69b28 100644
--- a/Chart.yaml
+++ b/Chart.yaml
@@ -4,7 +4,7 @@ description: |
   A helm chart for installing NextCloud and setting up ONLYOFFICE integration
 name: nextcloud-onlyoffice
 appVersion: NC-24.0.5-OO-7.2.0.204
-version: 0.13.6
+version: 0.14.0
 icon: https://cdn.rawgit.com/docker-library/docs/defa5ffc7123177acd60ddef6e16bddf694cc35f/nextcloud/logo.svg
 dependencies:
   # https://artifacthub.io/packages/helm/nextcloud/nextcloud
diff --git a/templates/tests/cypress-test-nc-oo.yaml b/templates/tests/cypress-test-nc-oo.yaml
index fd641a29..b74d25ab 100644
--- a/templates/tests/cypress-test-nc-oo.yaml
+++ b/templates/tests/cypress-test-nc-oo.yaml
@@ -34,9 +34,8 @@ spec:
         - name: CYPRESS_SSO_PW
           valueFrom:
             secretKeyRef:
-              name: {{ .Values.tests.ssoLogin.passwordSecret.name }}
-              key: {{ .Values.tests.ssoLogin.passwordSecret.key }}
-              namespace: {{ .Values.tests.ssoLogin.passwordSecret.namespace }}
+              name: "{{ .Release.Name }}-sso-password"
+              key: password
         {{- else }}
         - name: CYPRESS_NEXTCLOUD_ADMIN_USER
           value: admin
diff --git a/templates/tests/nextcoud-sso-password-secret.yaml b/templates/tests/nextcoud-sso-password-secret.yaml
new file mode 100644
index 00000000..cdd233b1
--- /dev/null
+++ b/templates/tests/nextcoud-sso-password-secret.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.tests.ssoLogin.enabled }}
+apiVersion: v1
+kind: Secret
+metadata:
+  name: "{{ .Release.Name }}-sso-password"
+  labels:
+    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
+    app.kubernetes.io/instance: {{ .Release.Name | quote }}
+    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+stringData:
+  password: "{{ .Values.tests.ssoLogin.password }}"
+{{- end }}
diff --git a/values.yaml b/values.yaml
index 8b02348d..e73770c3 100644
--- a/values.yaml
+++ b/values.yaml
@@ -230,10 +230,8 @@ tests:
     # Otherwise, username "admin" and nextcloud.nextcloud.password are used
     enabled: false
     username: admin
-    passwordSecret:
-      name: stackspin-single-sign-on-variables
-      key: userbackend_admin_password
-      namespace: flux-system
+    # # Uncomment and set to the password of the SSO user
+    # password: SET_PASSWORD_HERE
   cypress:
     # Set project ID and record key if cypress screenshots and videos should be uploaded
     # to the cypress dashboard
-- 
GitLab