Add and test valid/invalid config/auth files
This commit is contained in:
parent
91d88d2a68
commit
19682eec36
8 changed files with 32 additions and 22 deletions
|
@ -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")))))
|
|
|
@ -2,8 +2,28 @@
|
||||||
(:require
|
(:require
|
||||||
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
||||||
:cljs [cljs.test :refer-macros [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]))
|
[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
|
(deftest should-generate-secret
|
||||||
(is (= {:apiVersion "v1"
|
(is (= {:apiVersion "v1"
|
||||||
:kind "Secret"
|
:kind "Secret"
|
||||||
|
|
7
src/test/resources/nextcloud-test/invalid-auth.yaml
Normal file
7
src/test/resources/nextcloud-test/invalid-auth.yaml
Normal file
|
@ -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"
|
5
src/test/resources/nextcloud-test/invalid-config.yaml
Normal file
5
src/test/resources/nextcloud-test/invalid-config.yaml
Normal file
|
@ -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"
|
Loading…
Reference in a new issue