From 9dba615498a0fb2fda9d55df5258fb08f062adc7 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 11 Jan 2024 10:14:42 +0100 Subject: [PATCH] OZG-3328 new helm unittest framework --- src/test/helm/api-password-secret_test.yaml | 7 +++- .../helm/deployment-keycloak-values-test.yaml | 36 +++++++++---------- ...yment-mongodb-passwort-secretref-test.yaml | 7 ++++ src/test/helm/deployment-test.yaml | 7 ++++ src/test/helm/deployment-url-value-test.yaml | 9 ++++- ...yment_container_security_context_test.yaml | 7 ++++ .../helm/deployment_defaults_labels_test.yaml | 22 ++++++++---- src/test/helm/deployment_env_test.yaml | 3 ++ src/test/helm/network_policy_test.yaml | 4 +++ 9 files changed, 73 insertions(+), 29 deletions(-) diff --git a/src/test/helm/api-password-secret_test.yaml b/src/test/helm/api-password-secret_test.yaml index c39e185f..b3bafd39 100644 --- a/src/test/helm/api-password-secret_test.yaml +++ b/src/test/helm/api-password-secret_test.yaml @@ -4,6 +4,11 @@ release: namespace: sh-test-test templates: - templates/api-password-secret.yaml +set: + ozgcloud: + keycloak: + api: + password: testPassword tests: - it: test api secret kind asserts: @@ -13,7 +18,7 @@ tests: asserts: - equal: path: stringData.password - value: geheim + value: testPassword - it: should use Keycloak User Operator set: sso: diff --git a/src/test/helm/deployment-keycloak-values-test.yaml b/src/test/helm/deployment-keycloak-values-test.yaml index a59be04d..975dcd37 100644 --- a/src/test/helm/deployment-keycloak-values-test.yaml +++ b/src/test/helm/deployment-keycloak-values-test.yaml @@ -27,11 +27,16 @@ release: name: user-manager templates: - templates/deployment.yaml +set: + ozgcloud: + bundesland: by + bezeichner: helm + environment: dev + sso: + serverUrl: https://sso.test.by.ozg-cloud.local + baseUrl: test.company.local tests: - it: validate keycloak configuration values - template: deployment.yaml - release: - namespace: sh-helm-test asserts: - contains: path: spec.template.spec.containers[0].env @@ -51,17 +56,17 @@ tests: path: spec.template.spec.containers[0].env content: name: OZGCLOUD_KEYCLOAK_API_REALM - value: sh-helm-test + value: by-helm-dev - contains: path: spec.template.spec.containers[0].env content: name: QUARKUS_OIDC_AUTH_SERVER_URL - value: https://sso.test.sh.ozg-cloud.de/realms/sh-helm-test + value: https://sso.test.by.ozg-cloud.local/realms/by-helm-dev - contains: path: spec.template.spec.containers[0].env content: name: KEYCLOAK_URL - value: https://sso.test.sh.ozg-cloud.de + value: https://sso.test.by.ozg-cloud.local - contains: path: spec.template.spec.containers[0].env content: @@ -69,12 +74,10 @@ tests: value: alfa - it: should set keycloak client name - template: deployment.yaml - release: - namespace: sh-helm-test set: sso: client_name: alfa + serverUrl: https://sso.company.local asserts: - contains: path: spec.template.spec.containers[0].env @@ -83,9 +86,6 @@ tests: value: alfa - it: sso.serverurl with https - template: deployment.yaml - release: - namespace: sh-helm-test set: sso.serverUrl: https://sso.test.by.ozg-cloud.de asserts: @@ -93,16 +93,13 @@ tests: path: spec.template.spec.containers[0].env content: name: QUARKUS_OIDC_AUTH_SERVER_URL - value: https://sso.test.by.ozg-cloud.de/realms/sh-helm-test + value: https://sso.test.by.ozg-cloud.de/realms/by-helm-dev - contains: path: spec.template.spec.containers[0].env content: name: KEYCLOAK_URL value: https://sso.test.by.ozg-cloud.de - it: sso.serverurl without https - template: deployment.yaml - release: - namespace: sh-helm-test set: sso.serverUrl: sso.test.by.ozg-cloud.de asserts: @@ -110,20 +107,19 @@ tests: path: spec.template.spec.containers[0].env content: name: QUARKUS_OIDC_AUTH_SERVER_URL - value: https://sso.test.by.ozg-cloud.de/realms/sh-helm-test + value: https://sso.test.by.ozg-cloud.de/realms/by-helm-dev - contains: path: spec.template.spec.containers[0].env content: name: KEYCLOAK_URL value: https://sso.test.by.ozg-cloud.de + - it: should use Keycloak User Operator - template: deployment.yaml - release: - namespace: sh-helm-test set: sso: api_user: name: -userManager-ApiUser + serverUrl: https://sso.company.local asserts: - contains: path: spec.template.spec.containers[0].env diff --git a/src/test/helm/deployment-mongodb-passwort-secretref-test.yaml b/src/test/helm/deployment-mongodb-passwort-secretref-test.yaml index c5009855..e3d55eea 100644 --- a/src/test/helm/deployment-mongodb-passwort-secretref-test.yaml +++ b/src/test/helm/deployment-mongodb-passwort-secretref-test.yaml @@ -27,6 +27,13 @@ release: name: user-manager templates: - templates/deployment.yaml +set: + ozgcloud: + bundesland: by + bezeichner: helm + environment: dev + sso.serverUrl: https://sso.company.local + baseUrl: test.company.local tests: - it: should reference mongodb connectionString for user-manager set: diff --git a/src/test/helm/deployment-test.yaml b/src/test/helm/deployment-test.yaml index 63803158..cfcbe842 100644 --- a/src/test/helm/deployment-test.yaml +++ b/src/test/helm/deployment-test.yaml @@ -27,6 +27,13 @@ release: name: user-manager templates: - templates/deployment.yaml +set: + ozgcloud: + bundesland: by + bezeichner: helm + environment: dev + sso.serverUrl: https://sso.company.local + baseUrl: test.company.local tests: - it: test resources for prod environment release: diff --git a/src/test/helm/deployment-url-value-test.yaml b/src/test/helm/deployment-url-value-test.yaml index 02fd1681..f5b2b82f 100644 --- a/src/test/helm/deployment-url-value-test.yaml +++ b/src/test/helm/deployment-url-value-test.yaml @@ -27,6 +27,13 @@ release: name: user-manager templates: - templates/deployment.yaml +set: + ozgcloud: + bundesland: by + bezeichner: helm + environment: dev + sso.serverUrl: https://sso.company.local + baseUrl: test.company.local tests: - it: validate keycloak configuration values template: deployment.yaml @@ -37,4 +44,4 @@ tests: path: spec.template.spec.containers[0].env content: name: OZGCLOUD_USER_MANAGER_URL - value: https://helm-user-manager.test.sh.ozg-cloud.de \ No newline at end of file + value: https://helm-user-manager.test.company.local \ No newline at end of file diff --git a/src/test/helm/deployment_container_security_context_test.yaml b/src/test/helm/deployment_container_security_context_test.yaml index d95c4d15..92090bb6 100644 --- a/src/test/helm/deployment_container_security_context_test.yaml +++ b/src/test/helm/deployment_container_security_context_test.yaml @@ -28,6 +28,13 @@ release: namespace: sh-helm-test templates: - templates/deployment.yaml +set: + ozgcloud: + bundesland: by + bezeichner: helm + environment: dev + sso.serverUrl: https://sso.company.local + baseUrl: test.company.local tests: - it: check default values asserts: diff --git a/src/test/helm/deployment_defaults_labels_test.yaml b/src/test/helm/deployment_defaults_labels_test.yaml index 5510fba2..4edca498 100644 --- a/src/test/helm/deployment_defaults_labels_test.yaml +++ b/src/test/helm/deployment_defaults_labels_test.yaml @@ -30,39 +30,47 @@ templates: - templates/deployment.yaml - templates/service.yaml - templates/service_monitor.yaml +set: + ozgcloud: + bundesland: by + bezeichner: helm + environment: dev + sso: + serverUrl: https://sso.company.local + baseUrl: test.sh.ozg-cloud.local tests: - it: check default labels asserts: - equal: - path: metadata.labels.[app.kubernetes.io/instance] + path: metadata.labels["app.kubernetes.io/instance"] value: user-manager - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: user-manager - equal: - path: metadata.labels.[app.kubernetes.io/part-of] + path: metadata.labels["app.kubernetes.io/part-of"] value: ozgcloud - equal: - path: metadata.labels.[app.kubernetes.io/namespace] + path: metadata.labels["app.kubernetes.io/namespace"] value: sh-helm-test - it: check component label for deployment templates: - templates/deployment.yaml asserts: - equal: - path: spec.template.metadata.labels.[component] + path: spec.template.metadata.labels["component"] value: user-manager - it: check component label for service templates: - templates/service.yaml asserts: - equal: - path: metadata.labels.[component] + path: metadata.labels["component"] value: user-manager-service - it: check component label for service monitor templates: - templates/service_monitor.yaml asserts: - equal: - path: metadata.labels.[component] + path: metadata.labels["component"] value: user-manager-service-monitor diff --git a/src/test/helm/deployment_env_test.yaml b/src/test/helm/deployment_env_test.yaml index 6f9e04b4..e2ede3f3 100644 --- a/src/test/helm/deployment_env_test.yaml +++ b/src/test/helm/deployment_env_test.yaml @@ -80,6 +80,9 @@ tests: - it: check user sync period set set: ozgcloud: + bundesland: by + bezeichner: helm + environment: dev usersync: period: "6h" asserts: diff --git a/src/test/helm/network_policy_test.yaml b/src/test/helm/network_policy_test.yaml index 28458788..c67feb72 100644 --- a/src/test/helm/network_policy_test.yaml +++ b/src/test/helm/network_policy_test.yaml @@ -85,6 +85,8 @@ tests: - it: add ingress rule by values set: networkPolicy: + ssoPublicIp: 51.89.117.53/32 + dnsServerNamespace: test-namespace-dns additionalIngressConfig: - podSelector: matchLabels: @@ -112,6 +114,8 @@ tests: set: networkPolicy: disabled: false + ssoPublicIp: 51.89.117.53/32 + dnsServerNamespace: test-namespace-dns asserts: - hasDocuments: count: 1 \ No newline at end of file -- GitLab