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
a6cc25d1
Commit
a6cc25d1
authored
7 years ago
by
Ryan Senior
Browse files
Options
Downloads
Patches
Plain Diff
Add permissions checks for dimension updates
parent
ec43789b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/api/field.clj
+2
-2
2 additions, 2 deletions
src/metabase/api/field.clj
test/metabase/api/field_test.clj
+12
-0
12 additions, 0 deletions
test/metabase/api/field_test.clj
with
14 additions
and
2 deletions
src/metabase/api/field.clj
+
2
−
2
View file @
a6cc25d1
...
...
@@ -102,7 +102,7 @@
{
dimension-type
(
s/enum
"internal"
"external"
)
dimension-name
su/NonBlankString
human_readable_field_id
(
s/maybe
su/IntGreaterThanZero
)}
(
let
[
field
(
api/
read
-check
Field
id
)]
(
let
[
field
(
api/
write
-check
Field
id
)]
(
api/check
(
or
(
=
dimension-type
"internal"
)
(
and
(
=
dimension-type
"external"
)
human_readable_field_id
))
...
...
@@ -122,7 +122,7 @@
(
api/defendpoint
DELETE
"/:id/dimension"
"Remove the dimension associated to field at ID"
[
id
]
(
let
[
field
(
api/
read
-check
Field
id
)]
(
let
[
field
(
api/
write
-check
Field
id
)]
(
db/delete!
Dimension
:field_id
id
)
api/generic-204-no-content
))
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/field_test.clj
+
12
−
0
View file @
a6cc25d1
...
...
@@ -320,6 +320,12 @@
(
tt/with-temp*
[
Field
[{
field-id-1
:id
}
{
:name
"Field Test 1"
}]]
(
dimension-post
field-id-1
{
:name
"some dimension name"
,
:type
"external"
})))
;; Non-admin users can't update dimensions
(
expect
"You don't have permissions to do that."
(
tt/with-temp*
[
Field
[{
field-id
:id
}
{
:name
"Field Test 1"
}]]
((
user->client
:rasta
)
:post
403
(
format
"field/%d/dimension"
field-id
)
{
:name
"some dimension name"
,
:type
"external"
})))
;; Ensure we can delete a dimension
(
expect
[{
:id
true
...
...
@@ -339,6 +345,12 @@
[(
tu/boolean-ids-and-timestamps
new-dim
)
(
dimension-for-field
field-id
)])))
;; Non-admin users can't delete a dimension
(
expect
"You don't have permissions to do that."
(
tt/with-temp*
[
Field
[{
field-id
:id
}
{
:name
"Field Test 1"
}]]
((
user->client
:rasta
)
:delete
403
(
format
"field/%d/dimension"
field-id
))))
;; When an FK field gets it's special_type removed, we should clear the external dimension
(
expect
[{
:id
true
...
...
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