From 53eca49d9d62cdd2813d1865bac5a950207f3ddb Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 27 Jul 2022 12:23:42 +0200 Subject: [PATCH] Update deps, fix tests --- project.clj | 2 +- src/main/cljc/dda/c4k_gitea/gitea.cljc | 21 ++------- src/test/cljc/dda/c4k_gitea/gitea_test.cljc | 50 ++++----------------- 3 files changed, 13 insertions(+), 60 deletions(-) diff --git a/project.clj b/project.clj index b93c9ba..43a0a96 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 "2.1.0"] + [org.domaindrivenarchitecture/c4k-common-clj "2.1.2"] [hickory "0.7.1"]] :target-path "target/%s/" :source-paths ["src/main/cljc" diff --git a/src/main/cljc/dda/c4k_gitea/gitea.cljc b/src/main/cljc/dda/c4k_gitea/gitea.cljc index b1827b1..daa9345 100644 --- a/src/main/cljc/dda/c4k_gitea/gitea.cljc +++ b/src/main/cljc/dda/c4k_gitea/gitea.cljc @@ -17,20 +17,8 @@ (s/def ::default-app-name string?) (s/def ::fqdn pred/fqdn-string?) (s/def ::mailer-from pred/bash-env-string?) -; TODO: Move to pred/host-port? -; TODO: Review jem - 2022/07/26 - move to common & add unittest -(s/def ::mailer-host-port #(let [split-string (str/split % #":")] - (and (= (count split-string) 2) - (pred/fqdn-string? (first split-string)) - ; TODO: Move this to pred/port-number? - ; TODO: Review jem - 2022/07/26 - move to common & add unittest - (let [snd (edn/read-string (second split-string))] - (and (integer? snd) - (> snd 0) - (<= snd 65535)))))) -;TODO: Maybe move to pred/comma-separated-fqdn-list? -; TODO: Review jem - 2022/07/26 - move to common & add unittest -(s/def ::service-domain-whitelist #(every? true? (map pred/fqdn-string? (str/split % #",")))) +(s/def ::mailer-host-port pred/host-and-port-string?) +(s/def ::service-domain-whitelist #(pred/string-of-separated-by? pred/fqdn-string? #"," %)) (s/def ::service-noreply-address string?) (s/def ::mailer-user pred/bash-env-string?) (s/def ::mailer-pw pred/bash-env-string?) @@ -60,9 +48,8 @@ (defmethod yaml/load-as-edn :gitea [resource-name] (yaml/from-string (yaml/load-resource resource-name)))) -(defn-spec generate-appini-env pred/map-or-seq? - ; TODO: Review jem - 2022/07/26 - as we do not need auth here just hand over config & spec it. - [config any?] +(defn-spec generate-appini-env pred/map-or-seq? + [config config?] (let [{:keys [default-app-name fqdn mailer-from diff --git a/src/test/cljc/dda/c4k_gitea/gitea_test.cljc b/src/test/cljc/dda/c4k_gitea/gitea_test.cljc index 0aa160a..fffdc22 100644 --- a/src/test/cljc/dda/c4k_gitea/gitea_test.cljc +++ b/src/test/cljc/dda/c4k_gitea/gitea_test.cljc @@ -16,23 +16,23 @@ :APP_NAME-c2 "test gitea", :GITEA__mailer__FROM-c1 "", :GITEA__mailer__FROM-c2 "test@test.com", - :GITEA__mailer__HOST-c1 "", + :GITEA__mailer__HOST-c1 "m.t.de:123", :GITEA__mailer__HOST-c2 "mail.test.com:123", - :GITEA__server__DOMAIN-c1 "", + :GITEA__server__DOMAIN-c1 "test.de", :GITEA__server__DOMAIN-c2 "test.com", - :GITEA__server__ROOT_URL-c1 "https://", + :GITEA__server__ROOT_URL-c1 "https://test.de", :GITEA__server__ROOT_URL-c2 "https://test.com", - :GITEA__server__SSH_DOMAIN-c1 "", + :GITEA__server__SSH_DOMAIN-c1 "test.de", :GITEA__server__SSH_DOMAIN-c2 "test.com", - :GITEA__service__EMAIL_DOMAIN_WHITELIST-c1 "", + :GITEA__service__EMAIL_DOMAIN_WHITELIST-c1 "adb.de", :GITEA__service__EMAIL_DOMAIN_WHITELIST-c2 "test.com,test.net", :GITEA__service__NO_REPLY_ADDRESS-c1 "", :GITEA__service__NO_REPLY_ADDRESS-c2 "noreply@test.com"} (ct/map-diff (cut/generate-appini-env {:default-app-name "" - :fqdn "" + :fqdn "test.de" :mailer-from "" - :mailer-host-port "" - :service-domain-whitelist "" + :mailer-host-port "m.t.de:123" + :service-domain-whitelist "adb.de" :service-noreply-address "" }) (cut/generate-appini-env {:default-app-name "test gitea" @@ -66,37 +66,3 @@ :mailer-user "maileruser" :mailer-pw "mailerpw"}))))) - -(not - (= - {:GITEA__server__DOMAIN-c2 "test.com", - :GITEA__mailer__FROM-c1 "", - :GITEA__service__EMAIL_DOMAIN_WHITELIST-c2 "test.com,test.net", - :GITEA__service__EMAIL_DOMAIN_WHITELIST-c1 "", - :GITEA__mailer__HOST-c1 "", - :GITEA__service__NO_REPLY_ADDRESS-c1 "", - :GITEA__mailer__FROM-c2 "test@test.com", - :GITEA__mailer__HOST-c2 "mail.test.com:123", - :GITEA__server__ROOT_URL-c2 "https://test.com", - :GITEA__server__ROOT_URL-c1 "https://", - :GITEA__DEFAULT__APP_NAME-c2 "test gitea", - :GITEA__server__DOMAIN-c1 "", - :GITEA__DEFAULT__APP_NAME-c1 "", - :GITEA__service__NO_REPLY_ADDRESS-c2 "noreply@test.com"} - - {:GITEA__server__DOMAIN-c2 "test.com", - :GITEA__mailer__FROM-c1 "", - :GITEA__service__EMAIL_DOMAIN_WHITELIST-c2 "test.com,test.net", - :GITEA__service__EMAIL_DOMAIN_WHITELIST-c1 "", - :GITEA__mailer__HOST-c1 "", - :GITEA__service__NO_REPLY_ADDRESS-c1 "", - :GITEA__mailer__FROM-c2 "test@test.com", - :GITEA__mailer__HOST-c2 "mail.test.com:123", - :GITEA__server__ROOT_URL-c2 "https://test.com", - :GITEA__server__SSH_DOMAIN-c1 "", - :GITEA__server__ROOT_URL-c1 "https://", - :GITEA__DEFAULT__APP_NAME-c2 "test gitea", - :GITEA__server__SSH_DOMAIN-c2 "test.com", - :GITEA__server__DOMAIN-c1 "", - :GITEA__DEFAULT__APP_NAME-c1 "", - :GITEA__service__NO_REPLY_ADDRESS-c2 "noreply@test.com"})) \ No newline at end of file