Skip to content

Commit 592a24a

Browse files
committed
Second fix to netrc
1 parent 5eaa5cc commit 592a24a

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix `${netrc:...} ` to consider `:netrcFile` config properly.
6+
57
## 0.84.1
68

79
- Fix `${netrc:...} ` to consider `:netrcFile` config.

src/eca/config.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
(string/replace #"\$\{netrc:([^}]+)\}"
176176
(fn [[_match key-rc]]
177177
(try
178-
(or (secrets/get-credential key-rc (:netrcFile config)) "")
178+
(or (secrets/get-credential key-rc (get config "netrcFile")) "")
179179
(catch Exception e
180180
(logger/warn logger-tag "Error reading netrc credential:" (.getMessage e))
181181
""))))))

test/eca/config_test.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@
342342
(when (= key-rc "api.openai.com")
343343
"secret-password-123"))]
344344
(is (= "secret-password-123" (#'config/parse-dynamic-string "${netrc:api.openai.com}" "/tmp" {})))))
345+
(testing "replaces netrc pattern with credential password with a custom netrcFile"
346+
(with-redefs [secrets/get-credential (fn [key-rc netrc-file]
347+
(when (and (= key-rc "api.openai.com")
348+
(= netrc-file "/tmp/my-file"))
349+
"secret-password-123"))]
350+
(is (= "secret-password-123" (#'config/parse-dynamic-string "${netrc:api.openai.com}" "/tmp" {"netrcFile" "/tmp/my-file"})))))
345351

346352
(testing "replaces netrc pattern with empty string when credential not found"
347353
(with-redefs [secrets/get-credential (constantly nil)]

0 commit comments

Comments
 (0)