diff --git a/project.clj b/project.clj index b04f419..8b5f76c 100644 --- a/project.clj +++ b/project.clj @@ -5,7 +5,7 @@ :url "https://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.10.3"] [org.clojure/tools.reader "1.3.6"] - [org.domaindrivenarchitecture/c4k-common-clj "6.0.0"]] + [org.domaindrivenarchitecture/c4k-common-clj "6.0.1"]] :target-path "target/%s/" :source-paths ["src/main/cljc" "src/main/clj"] diff --git a/src/main/cljc/dda/c4k_keycloak/core.cljc b/src/main/cljc/dda/c4k_keycloak/core.cljc index ce6cc8f..49d7e69 100644 --- a/src/main/cljc/dda/c4k_keycloak/core.cljc +++ b/src/main/cljc/dda/c4k_keycloak/core.cljc @@ -14,16 +14,16 @@ (def config-defaults {:issuer "staging"}) -(s/def ::config (s/keys :req-un [::kc/fqdn] - :opt-un [::kc/issuer - ::mon/config])) +(def config? (s/keys :req-un [::kc/fqdn] + :opt-un [::kc/issuer + ::mon/mon-cfg])) (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])) (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 fdc25c6..c40c1d2 100644 --- a/src/test/cljc/dda/c4k_keycloak/core_test.cljc +++ b/src/test/cljc/dda/c4k_keycloak/core_test.cljc @@ -16,5 +16,6 @@ ;; 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/auth? (yaml/load-as-edn "keycloak-test/valid-auth.yaml")))) \ No newline at end of file + (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"))) + (is (not (s/valid? cut/config? (yaml/load-as-edn "keycloak-test/invalid-config.yaml"))))) \ No newline at end of file diff --git a/src/test/resources/keycloak-test/invalid-config.yaml b/src/test/resources/keycloak-test/invalid-config.yaml new file mode 100644 index 0000000..2ff8447 --- /dev/null +++ b/src/test/resources/keycloak-test/invalid-config.yaml @@ -0,0 +1,6 @@ +fqdn: "keycloak.test.meissa-gmbh.de" +issuer: "staging" +mon-cfg: + grafana-clod-url: "url-for-your-prom-remote-write-endpoint" + cluster-nam: "keycloak" + cluster-stage: "none" \ 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 d995606..4aa1c76 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