Skip to content
Snippets Groups Projects
Unverified Commit a5eb647e authored by lbrdnk's avatar lbrdnk Committed by GitHub
Browse files

Add basic auth params to `dbms-version` call on Druid (#45729)

* Add basic auth to dbms-version

* Add test
parent 5bb2a152
Branches
Tags
No related merge requests found
......@@ -66,5 +66,10 @@
[database]
{:pre [(map? (:details database))]}
(ssh/with-ssh-tunnel [details-with-tunnel (:details database)]
(-> (druid.client/GET (druid.client/details->url details-with-tunnel "/status"))
(-> (druid.client/GET (druid.client/details->url details-with-tunnel "/status")
:auth-enabled (-> database :details :auth-enabled)
:auth-username (-> database :details :auth-username)
:auth-token-value (-> (:details database)
(secret/db-details-prop->secret-map "auth-token")
secret/value->string))
(select-keys [:version]))))
......@@ -4,7 +4,10 @@
[malli.core :as mc]
[malli.error :as me]
[metabase.driver :as driver]
[metabase.driver.druid.client :as druid.client]
[metabase.driver.druid.sync :as druid.sync]
[metabase.models.database :refer [Database]]
[metabase.models.secret :as secret]
[metabase.sync.sync-metadata.dbms-version :as sync-dbms-ver]
[metabase.test :as mt]
[metabase.timeseries-query-processor-test.util :as tqpt]
......@@ -60,3 +63,22 @@
(is (nil? version-after-update)))
(testing "Check that the value was set again after sync"
(is (nil? (check-dbms-version (db-dbms-version db))))))))))
(deftest ^:synchronized auth-dbms-version-test
(mt/test-driver
:druid
(testing "`dbms-version` uses auth parameters (#41579)"
(tqpt/with-flattened-dbdef
(let [get-args (volatile! nil)
db-with-auth-details (update (mt/db) :details assoc
:auth-enabled true
:auth-username "admin"
:auth-token-value "password1")]
;; Following ensures that auth parameters are passed to GET during version sync if present.
(with-redefs [secret/value->string (constantly "password1")
druid.client/GET (fn [_url & params] (vreset! get-args (apply hash-map params)) nil)]
;; Just fill in the params with internally modified `dbms-version`.
(druid.sync/dbms-version db-with-auth-details)
(is (= true (:auth-enabled @get-args)))
(is (= "admin" (:auth-username @get-args)))
(is (= "password1" (:auth-token-value @get-args)))))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment