Skip to content
Snippets Groups Projects
Unverified Commit 57e94a79 authored by github-automation-metabase's avatar github-automation-metabase Committed by GitHub
Browse files

version and channel query params for version info (#48616) (#48668)

* version and channel query params for version info

https://github.com/metabase/metabase/issues/48615



* omit blanks from query params for version info

Co-authored-by: default avatarJohn Swanson <john.swanson@metabase.com>
parent fb7b17d1
No related branches found
No related tags found
No related merge requests found
......@@ -3,10 +3,12 @@
(:require
[cheshire.core :as json]
[clj-http.client :as http]
[clojure.string :as str]
[clojurewerkz.quartzite.jobs :as jobs]
[clojurewerkz.quartzite.schedule.cron :as cron]
[clojurewerkz.quartzite.triggers :as triggers]
[java-time.api :as t]
[medley.core :as m]
[metabase.config :as config]
[metabase.public-settings :as public-settings]
[metabase.task :as task]
......@@ -20,7 +22,11 @@
{:keys [status body]} (http/get version-info-url (merge
{:content-type "application/json"}
(when config/is-prod?
{:query-params {"instance" (public-settings/site-uuid-for-version-info-fetching)}})))]
{:query-params (m/remove-vals
str/blank?
{"instance" (public-settings/site-uuid-for-version-info-fetching)
"current-version" (:tag config/mb-version-info)
"channel" (public-settings/update-channel)})})))]
(when (not= status 200)
(throw (Exception. (format "[%d]: %s" status body))))
(json/parse-string body keyword)))
......
......@@ -6,16 +6,33 @@
[metabase.public-settings :as public-settings]
[metabase.task.upgrade-checks :as upgrade-checks]))
(deftest site-uuid-test
(testing "A unique and stable instance UUID is included in version info requests in prod"
(deftest query-params-test
(testing "The expected query params are provided"
(with-redefs [config/is-prod? true]
(http-fake/with-fake-routes-in-isolation
{{:address #"https://static.metabase.com/version-info(-ee)?.json.*"
:query-params {:instance (public-settings/site-uuid-for-version-info-fetching)}}
:query-params {;; 3 query parameters are sent in prod:
;; - A unique and stable instance UUID,
;; - The current version, and
;; - the update channel
:instance (public-settings/site-uuid-for-version-info-fetching)
:current-version (:tag config/mb-version-info)
:channel (public-settings/update-channel)}}
(constantly {:status 200 :body "{}"})}
(is (= {} (@#'upgrade-checks/get-version-info))))))
(testing "Instance UUID is not included when not running in prod"
(testing "Empty values are omitted from the query params"
(with-redefs [config/is-prod? true
public-settings/site-uuid-for-version-info-fetching (constantly "")
config/mb-version-info (constantly {:tag ""})
public-settings/update-channel (constantly "")]
(http-fake/with-fake-routes-in-isolation
{{:address #"https://static.metabase.com/version-info(-ee)?.json.*"
:query-params {}}
(constantly {:status 200 :body "{}"})}
(is (= {} (@#'upgrade-checks/get-version-info))))))
(testing "No query parameters are sent outside of prod"
(with-redefs [config/is-prod? false]
(http-fake/with-fake-routes-in-isolation
{{:address #"https://static.metabase.com/version-info(-ee)?.json.*"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment