From 938ba8027588b804ab147c31a1f7261c256c1734 Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 27 Jan 2023 13:03:09 +0100 Subject: [PATCH] [Skip-CI] [WIP] Update tests for config and auth Currently specs opt-un seems to validate invalid specs. This results in invalid configs not failing our tests. --- src/main/cljc/dda/c4k_keycloak/core.cljc | 13 +++++-------- src/test/cljc/dda/c4k_keycloak/core_test.cljc | 2 +- src/test/resources/keycloak-test/valid-config.yaml | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/cljc/dda/c4k_keycloak/core.cljc b/src/main/cljc/dda/c4k_keycloak/core.cljc index 06c7566..ce6cc8f 100644 --- a/src/main/cljc/dda/c4k_keycloak/core.cljc +++ b/src/main/cljc/dda/c4k_keycloak/core.cljc @@ -14,19 +14,16 @@ (def config-defaults {:issuer "staging"}) -(s/def ::mon-cfg mon/config?) -(s/def ::mon-auth mon/auth?) - -(def config? (s/keys :req-un [::kc/fqdn] - :opt-un [::kc/issuer - ::mon-cfg])) +(s/def ::config (s/keys :req-un [::kc/fqdn] + :opt-un [::kc/issuer + ::mon/config])) (def auth? (s/keys :req-un [::kc/keycloak-admin-user ::kc/keycloak-admin-password ::postgres/postgres-db-user ::postgres/postgres-db-password] - :opt-un [::mon-auth])) + :opt-un [::mon/auth])) (defn-spec k8s-objects cp/map-or-seq? - [config config? + [config ::config auth auth?] (map yaml/to-string (filter diff --git a/src/test/cljc/dda/c4k_keycloak/core_test.cljc b/src/test/cljc/dda/c4k_keycloak/core_test.cljc index 9110e5f..fdc25c6 100644 --- a/src/test/cljc/dda/c4k_keycloak/core_test.cljc +++ b/src/test/cljc/dda/c4k_keycloak/core_test.cljc @@ -16,5 +16,5 @@ ;; TODO: 2023.01.27 - jem: may not validate k3s-cluster-name entries ... find out what's wrong. (deftest validate-valid-resources - (is (s/valid? cut/config? (yaml/load-as-edn "keycloak-test/valid-config.yaml"))) + (is (s/valid? ::cut/config (yaml/load-as-edn "keycloak-test/valid-config.yaml"))) (is (s/valid? cut/auth? (yaml/load-as-edn "keycloak-test/valid-auth.yaml")))) \ No newline at end of file diff --git a/src/test/resources/keycloak-test/valid-config.yaml b/src/test/resources/keycloak-test/valid-config.yaml index 4aa1c76..d995606 100644 --- a/src/test/resources/keycloak-test/valid-config.yaml +++ b/src/test/resources/keycloak-test/valid-config.yaml @@ -3,4 +3,4 @@ issuer: "staging" mon-cfg: grafana-cloud-url: "url-for-your-prom-remote-write-endpoint" cluster-name: "keycloak" - cluster-stage: "test" \ No newline at end of file + cluster-stage: :test \ No newline at end of file