Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
25566742
Commit
25566742
authored
Mar 13, 2020
by
Fabio Huser
Committed by
Mayra Cabrera
Mar 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent default overwrite for theme and color ID in user API
parent
257aae9f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
changelogs/unreleased/fix-prevent-user-theme-color-api-overwrite.yml
...unreleased/fix-prevent-user-theme-color-api-overwrite.yml
+5
-0
lib/api/users.rb
lib/api/users.rb
+2
-2
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+20
-0
No files found.
changelogs/unreleased/fix-prevent-user-theme-color-api-overwrite.yml
0 → 100644
View file @
25566742
---
title
:
Prevent default overwrite for theme and color ID in user API
merge_request
:
26792
author
:
Fabio Huser
type
:
fixed
lib/api/users.rb
View file @
25566742
...
@@ -52,8 +52,8 @@ module API
...
@@ -52,8 +52,8 @@ module API
optional
:external
,
type:
Boolean
,
desc:
'Flag indicating the user is an external user'
optional
:external
,
type:
Boolean
,
desc:
'Flag indicating the user is an external user'
# TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960
# TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960
optional
:avatar
,
type:
File
,
desc:
'Avatar image for user'
# rubocop:disable Scalability/FileUploads
optional
:avatar
,
type:
File
,
desc:
'Avatar image for user'
# rubocop:disable Scalability/FileUploads
optional
:theme_id
,
type:
Integer
,
de
fault:
1
,
de
sc:
'The GitLab theme for the user'
optional
:theme_id
,
type:
Integer
,
desc:
'The GitLab theme for the user'
optional
:color_scheme_id
,
type:
Integer
,
de
fault:
1
,
de
sc:
'The color scheme for the file viewer'
optional
:color_scheme_id
,
type:
Integer
,
desc:
'The color scheme for the file viewer'
optional
:private_profile
,
type:
Boolean
,
desc:
'Flag indicating the user has a private profile'
optional
:private_profile
,
type:
Boolean
,
desc:
'Flag indicating the user has a private profile'
all_or_none_of
:extern_uid
,
:provider
all_or_none_of
:extern_uid
,
:provider
...
...
spec/requests/api/users_spec.rb
View file @
25566742
...
@@ -832,6 +832,13 @@ describe API::Users, :do_not_mock_admin_mode do
...
@@ -832,6 +832,13 @@ describe API::Users, :do_not_mock_admin_mode do
expect
(
user
.
reload
.
private_profile
).
to
eq
(
false
)
expect
(
user
.
reload
.
private_profile
).
to
eq
(
false
)
end
end
it
"does have default values for theme and color-scheme ID"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{}
expect
(
user
.
reload
.
theme_id
).
to
eq
(
Gitlab
::
Themes
.
default
.
id
)
expect
(
user
.
reload
.
color_scheme_id
).
to
eq
(
Gitlab
::
ColorSchemes
.
default
.
id
)
end
it
"updates private profile"
do
it
"updates private profile"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{
private_profile:
true
}
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{
private_profile:
true
}
...
@@ -857,6 +864,19 @@ describe API::Users, :do_not_mock_admin_mode do
...
@@ -857,6 +864,19 @@ describe API::Users, :do_not_mock_admin_mode do
expect
(
user
.
reload
.
private_profile
).
to
eq
(
true
)
expect
(
user
.
reload
.
private_profile
).
to
eq
(
true
)
end
end
it
"does not modify theme or color-scheme ID when field is not provided"
do
theme
=
Gitlab
::
Themes
.
each
.
find
{
|
t
|
t
.
id
!=
Gitlab
::
Themes
.
default
.
id
}
scheme
=
Gitlab
::
ColorSchemes
.
each
.
find
{
|
t
|
t
.
id
!=
Gitlab
::
ColorSchemes
.
default
.
id
}
user
.
update
(
theme_id:
theme
.
id
,
color_scheme_id:
scheme
.
id
)
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
user
.
reload
.
theme_id
).
to
eq
(
theme
.
id
)
expect
(
user
.
reload
.
color_scheme_id
).
to
eq
(
scheme
.
id
)
end
it
"does not update admin status"
do
it
"does not update admin status"
do
put
api
(
"/users/
#{
admin_user
.
id
}
"
,
admin
),
params:
{
can_create_group:
false
}
put
api
(
"/users/
#{
admin_user
.
id
}
"
,
admin
),
params:
{
can_create_group:
false
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment