Skip to content
Snippets Groups Projects
Commit 069537f7 authored by Cam Saül's avatar Cam Saül
Browse files

Remove expect-eval-actual-first from metabase.api.setup-test :new:

parent c6767621
No related branches found
No related tags found
No related merge requests found
......@@ -13,16 +13,12 @@
[metabase.util :as u]
[metabase.test.util :refer [random-name resolve-private-fns with-temporary-setting-values with-temp], :as tu]))
(defn- is-uuid-string? [s]
(boolean (when (string? s)
(re-matches #"^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$" s))))
;; ## POST /api/session
;; Test that we can login
(expect
;; delete all other sessions for the bird first, otherwise test doesn't seem to work (TODO - why?)
(do (db/delete! Session, :user_id (user->id :rasta))
(is-uuid-string? (:id (client :post 200 "session" (user->credentials :rasta))))))
(tu/is-uuid-string? (:id (client :post 200 "session" (user->credentials :rasta))))))
;; Test for required params
(expect {:errors {:email "field is a required param."}}
......@@ -126,7 +122,7 @@
(db/update! User id, :reset_token <>))]
(-> (client :post 200 "session/reset_password" {:token token
:password "whateverUP12!!"})
(update :session_id is-uuid-string?)))))
(update :session_id tu/is-uuid-string?)))))
;; Test that token and password are required
(expect {:errors {:token "field is a required param."}}
......@@ -230,7 +226,7 @@
(defn- is-session? [session]
(u/ignore-exceptions
(is-uuid-string? (:id session))))
(tu/is-uuid-string? (:id session))))
;; test that an existing user can log in with Google auth even if the auto-create accounts domain is different from their account
;; should return a Session
......
......@@ -8,26 +8,27 @@
[user :refer [User]])
[metabase.setup :as setup]
(metabase.test [data :refer :all]
[util :refer [match-$ random-name], :as tu])))
[util :refer [match-$ random-name], :as tu])
[metabase.util :as u]))
;; ## POST /api/setup/user
;; Check that we can create a new superuser via setup-token
(let [user-name (random-name)]
(tu/expect-eval-actual-first
[(match-$ (Session :user_id (db/select-one-id User, :email (str user-name "@metabase.com")))
{:id $id})
(str user-name "@metabase.com")]
(let [resp (http/client :post 200 "setup" {:token (setup/token-create)
:prefs {:site_name "Metabase Test"}
:user {:first_name user-name
:last_name user-name
:email (str user-name "@metabase.com")
:password "anythingUP12!!"}})]
;; reset our setup token
(setup/token-create)
;; return api response
[resp (setting/get :admin-email)])))
(let [user-name (random-name)
email (str user-name "@metbase.com")]
(expect
[true
email]
[(tu/is-uuid-string? (:id (http/client :post 200 "setup" {:token (setup/token-create)
:prefs {:site_name "Metabase Test"}
:user {:first_name user-name
:last_name user-name
:email email
:password "anythingUP12!!"}})))
(do
;; reset our setup token
(setup/token-create)
(setting/get :admin-email))]))
;; Test input validations
......
......@@ -347,3 +347,10 @@
(if (seq more)
`(with-temporary-setting-values ~more ~body)
body)))
(defn is-uuid-string?
"Is string S a valid UUID string?"
^Boolean [^String s]
(boolean (when (string? s)
(re-matches #"^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$" s))))
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