From 19682eec36180da0cf335517b11f8de4534ec935 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 3 Feb 2023 10:22:54 +0100 Subject: [PATCH] Add and test valid/invalid config/auth files --- .../cljc/dda/c4k_nextcloud/core_test.cljc | 22 ------------------- .../dda/c4k_nextcloud/nextcloud_test.cljc | 20 +++++++++++++++++ .../nextcloud-test/invalid-auth.yaml | 7 ++++++ .../nextcloud-test/invalid-config.yaml | 5 +++++ .../resources/nextcloud-test/valid-auth.edn | 0 .../resources/nextcloud-test/valid-auth.yaml | 0 .../resources/nextcloud-test/valid-config.edn | 0 .../nextcloud-test/valid-config.yaml | 0 8 files changed, 32 insertions(+), 22 deletions(-) delete mode 100644 src/test/cljc/dda/c4k_nextcloud/core_test.cljc create mode 100644 src/test/resources/nextcloud-test/invalid-auth.yaml create mode 100644 src/test/resources/nextcloud-test/invalid-config.yaml rename valid-auth.edn => src/test/resources/nextcloud-test/valid-auth.edn (100%) rename valid-auth.yaml => src/test/resources/nextcloud-test/valid-auth.yaml (100%) rename valid-config.edn => src/test/resources/nextcloud-test/valid-config.edn (100%) rename valid-config.yaml => src/test/resources/nextcloud-test/valid-config.yaml (100%) diff --git a/src/test/cljc/dda/c4k_nextcloud/core_test.cljc b/src/test/cljc/dda/c4k_nextcloud/core_test.cljc deleted file mode 100644 index 0c88290..0000000 --- a/src/test/cljc/dda/c4k_nextcloud/core_test.cljc +++ /dev/null @@ -1,22 +0,0 @@ -(ns dda.c4k-nextcloud.core-test - (:require - #?(:clj [clojure.test :refer [deftest is are testing run-tests]] - :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) - #?(:cljs [shadow-resource :as rc]) - [clojure.spec.alpha :as s] - [dda.c4k-common.yaml :as yaml] - [dda.c4k-nextcloud.core :as cut])) - -#?(:cljs - (defmethod yaml/load-resource :nextcloud-test [resource-name] - (case resource-name - "nextcloud-test/valid-auth.yaml" (rc/inline "nextcloud-test/valid-auth.yaml") - "nextcloud-test/valid-config.yaml" (rc/inline "nextcloud-test/valid-config.yaml") - "nextcloud-test/invalid-auth.yaml" (rc/inline "nextcloud-test/invalid-auth.yaml") - "nextcloud-test/invalid-config.yaml" (rc/inline "nextcloud-test/invalid-config.yaml")))) - -(deftest validate-valid-resources - (is (s/valid? cut/config? (yaml/load-as-edn "nextcloud-test/valid-config.yaml"))) - (is (s/valid? cut/auth? (yaml/load-as-edn "nextcloud-test/valid-auth.yaml"))) - (is (not (s/valid? cut/config? (yaml/load-as-edn "nextcloud-test/invalid-config.yaml")))) - (is (not (s/valid? cut/auth? (yaml/load-as-edn "nextcloud-test/invalid-auth.yaml"))))) diff --git a/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc b/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc index 88e3376..26ee033 100644 --- a/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc +++ b/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc @@ -2,8 +2,28 @@ (:require #?(:clj [clojure.test :refer [deftest is are testing run-tests]] :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) + #?(:cljs [shadow-resource :as rc]) + [clojure.spec.alpha :as s] + [clojure.spec.test.alpha :as st] + [dda.c4k-common.yaml :as yaml] [dda.c4k-nextcloud.nextcloud :as cut])) +(st/instrument) + +#?(:cljs + (defmethod yaml/load-resource :nextcloud-test [resource-name] + (case resource-name + "nextcloud-test/valid-auth.yaml" (rc/inline "nextcloud-test/valid-auth.yaml") + "nextcloud-test/valid-config.yaml" (rc/inline "nextcloud-test/valid-config.yaml") + "nextcloud-test/invalid-auth.yaml" (rc/inline "nextcloud-test/invalid-auth.yaml") + "nextcloud-test/invalid-config.yaml" (rc/inline "nextcloud-test/invalid-config.yaml")))) + +(deftest validate-valid-resources + (is (s/valid? cut/config? (yaml/load-as-edn "nextcloud-test/valid-config.yaml"))) + (is (s/valid? cut/auth? (yaml/load-as-edn "nextcloud-test/valid-auth.yaml"))) + (is (not (s/valid? cut/config? (yaml/load-as-edn "nextcloud-test/invalid-config.yaml")))) + (is (not (s/valid? cut/auth? (yaml/load-as-edn "nextcloud-test/invalid-auth.yaml"))))) + (deftest should-generate-secret (is (= {:apiVersion "v1" :kind "Secret" diff --git a/src/test/resources/nextcloud-test/invalid-auth.yaml b/src/test/resources/nextcloud-test/invalid-auth.yaml new file mode 100644 index 0000000..11b9684 --- /dev/null +++ b/src/test/resources/nextcloud-test/invalid-auth.yaml @@ -0,0 +1,7 @@ +postgres-db-user: "nextcloud" +postgres-db-password: "nextcloud-db-password" +nextcloud-admin-user: "cloudadmin" +nextcloud-admin-password: "cloudpassword" +aws-accss-key-id: "aws-id" +aws-secret-access-key: "aws-secret" +restic-password: "restic-password" \ No newline at end of file diff --git a/src/test/resources/nextcloud-test/invalid-config.yaml b/src/test/resources/nextcloud-test/invalid-config.yaml new file mode 100644 index 0000000..86120a4 --- /dev/null +++ b/src/test/resources/nextcloud-test/invalid-config.yaml @@ -0,0 +1,5 @@ +fqdns: "cloud.test.meissa-gmbh.de" +issuer: "none" +nextcloud-data-volume-path: "/var/cloud" +postgres-data-volume-path: "/var/postgres" +restic-repository: "s3:s3.amazonaws.com/your-bucket/your-folder" \ No newline at end of file diff --git a/valid-auth.edn b/src/test/resources/nextcloud-test/valid-auth.edn similarity index 100% rename from valid-auth.edn rename to src/test/resources/nextcloud-test/valid-auth.edn diff --git a/valid-auth.yaml b/src/test/resources/nextcloud-test/valid-auth.yaml similarity index 100% rename from valid-auth.yaml rename to src/test/resources/nextcloud-test/valid-auth.yaml diff --git a/valid-config.edn b/src/test/resources/nextcloud-test/valid-config.edn similarity index 100% rename from valid-config.edn rename to src/test/resources/nextcloud-test/valid-config.edn diff --git a/valid-config.yaml b/src/test/resources/nextcloud-test/valid-config.yaml similarity index 100% rename from valid-config.yaml rename to src/test/resources/nextcloud-test/valid-config.yaml