Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
069537f7
Commit
069537f7
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Remove expect-eval-actual-first from metabase.api.setup-test
parent
c6767621
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/metabase/api/session_test.clj
+3
-7
3 additions, 7 deletions
test/metabase/api/session_test.clj
test/metabase/api/setup_test.clj
+17
-16
17 additions, 16 deletions
test/metabase/api/setup_test.clj
test/metabase/test/util.clj
+7
-0
7 additions, 0 deletions
test/metabase/test/util.clj
with
27 additions
and
23 deletions
test/metabase/api/session_test.clj
+
3
−
7
View file @
069537f7
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/setup_test.clj
+
17
−
16
View file @
069537f7
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
test/metabase/test/util.clj
+
7
−
0
View file @
069537f7
...
...
@@ -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
))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment