Skip to content
Snippets Groups Projects
Unverified Commit 00cf2da8 authored by Noah Moss's avatar Noah Moss Committed by GitHub
Browse files

Include new site UUID in version check requests (#25783)


* Add UUID param to version info checks

* add test and minor tweaks

* Update test/metabase/task/upgrade_checks_test.clj

Co-authored-by: default avatarCal Herries <39073188+calherries@users.noreply.github.com>

* add is-prod check

Co-authored-by: default avatarCal Herries <39073188+calherries@users.noreply.github.com>
parent 1b863873
Branches
Tags
No related merge requests found
......@@ -101,6 +101,13 @@
:setter :none
:type ::uuid-nonce)
(defsetting site-uuid-for-version-info-fetching
"A *different* site-wide UUID that we use for the version info fetching API calls. Do not use this for any other
applications. (See [[site-uuid-for-premium-features-token-checks]] for more reasoning.)"
:visibility :internal
:setter :none
:type ::uuid-nonce)
(defn- normalize-site-url [^String s]
(let [ ;; remove trailing slashes
s (str/replace s #"/$" "")
......
......@@ -15,7 +15,10 @@
(defn- get-version-info []
(let [version-info-url-key (if config/ee-available? :mb-version-info-ee-url :mb-version-info-url)
version-info-url (config/config-str version-info-url-key)
{:keys [status body]} (http/get version-info-url {:content-type "application/json"})]
{: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)}})))]
(when (not= status 200)
(throw (Exception. (format "[%d]: %s" status body))))
(json/parse-string body keyword)))
......
(ns metabase.task.upgrade-checks-test
(:require [clj-http.fake :as http-fake]
[clojure.test :refer :all]
[metabase.config :as config]
[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"
(with-redefs [config/is-prod? true]
(http-fake/with-fake-routes-in-isolation
{{:address #"http://static.metabase.com/version-info(-ee)?.json.*"
:query-params {:instance (public-settings/site-uuid-for-version-info-fetching)}}
(constantly {:status 200 :body "{}"})}
(is (= {} (@#'upgrade-checks/get-version-info))))))
(testing "Instance UUID is not included when not running in prod"
(with-redefs [config/is-prod? false]
(http-fake/with-fake-routes-in-isolation
{{:address #"http://static.metabase.com/version-info(-ee)?.json.*"
:query-params {}}
(constantly {:status 200 :body "{}"})}
(is (= {} (@#'upgrade-checks/get-version-info)))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment