Skip to content

Commit

Permalink
Fix not to add nil as username and password #109
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Nov 16, 2021
1 parent f81fe82 commit 4adc268
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/antq/util/maven.clj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
;; In Leiningen, authentication information is defined in project.clj instead of ~/.m2/settings.xml,
;; so if there is authentication information in `:repositories`, apply to `settings`
(doseq [[id {:keys [username password]}] (:repositories opts)]
(when-not (contains? server-ids id)
(when (and username
password
(not (contains? server-ids id)))
(.addServer settings
(new-repository-server {:id id :username username :password password}))))
settings))
Expand Down
10 changes: 8 additions & 2 deletions test/antq/util/maven_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@
(.setPassword "two-pass")))))

(def ^:private dummy-repos
{"serv1" {:url "https://one.example.com"}
{;; duplicated with dummy-settings
"serv1" {:url "https://one.example.com"}
;; duplicated with dummy-settings
"serv2" {:url "https://two.example.com"}
;; new to appear
"serv3" {:url "https://three.example.com"
:username "three-user"
:password "three-pass"}
;; new to appear
"serv4" {:url "https://three.example.com"
:username :env
:password :env/four}})
:password :env/four}
;; should not be added because of missing username and password
"dummy" {:url "https://dummy.example.com"}})

(def ^:private dummy-env
{"LEIN_PASSWORD" "lein-pass"
Expand Down

0 comments on commit 4adc268

Please sign in to comment.