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

Clear google auth client ID setting if empty string is saved (#20462)

parent e6087ad2
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@
(deferred-tru "Client ID for Google Sign-In. If this is set, Google Sign-In is considered to be enabled.")
:visibility :public
:setter (fn [client-id]
(if client-id
(if (seq client-id)
(let [trimmed-client-id (str/trim client-id)]
(when-not (str/ends-with? trimmed-client-id ".apps.googleusercontent.com")
(throw (ex-info (tru "Invalid Google Sign-In Client ID: must end with \".apps.googleusercontent.com\"")
......
......@@ -11,15 +11,20 @@
;;; --------------------------------------------- google-auth-client-id ----------------------------------------------
(deftest google-auth-client-id-test
(testing "Client ID must end with correct suffix"
(is (thrown-with-msg?
clojure.lang.ExceptionInfo
#"Invalid Google Sign-In Client ID: must end with \".apps.googleusercontent.com\""
(google/google-auth-client-id "invalid-client-id"))))
(testing "Trailing whitespace in client ID is stripped upon save"
(google/google-auth-client-id "test-client-id.apps.googleusercontent.com ")
(is (= "test-client-id.apps.googleusercontent.com" (google/google-auth-client-id)))))
(mt/with-temporary-setting-values [google-auth-client-id nil]
(testing "Client ID must end with correct suffix"
(is (thrown-with-msg?
clojure.lang.ExceptionInfo
#"Invalid Google Sign-In Client ID: must end with \".apps.googleusercontent.com\""
(google/google-auth-client-id "invalid-client-id"))))
(testing "Trailing whitespace in client ID is stripped upon save"
(google/google-auth-client-id "test-client-id.apps.googleusercontent.com ")
(is (= "test-client-id.apps.googleusercontent.com" (google/google-auth-client-id))))
(testing "Saving an empty string will clear the client ID setting"
(google/google-auth-client-id "")
(is (= nil (google/google-auth-client-id))))))
;;; --------------------------------------------- account autocreation -----------------------------------------------
......
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