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
32e3955b
Commit
32e3955b
authored
May 25, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure only the admin could update shared_runners_minutes_limit
parent
0106d2f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
6 deletions
+25
-6
app/models/user.rb
app/models/user.rb
+2
-0
lib/api/groups.rb
lib/api/groups.rb
+3
-0
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+10
-3
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+10
-3
No files found.
app/models/user.rb
View file @
32e3955b
...
...
@@ -182,6 +182,8 @@ class User < ActiveRecord::Base
alias_attribute
:private_token
,
:authentication_token
delegate
:path
,
to: :namespace
,
allow_nil:
true
,
prefix:
true
# EE-only
delegate
:shared_runners_minutes_limit
,
:shared_runners_minutes_limit
=
,
to: :namespace
...
...
lib/api/groups.rb
View file @
32e3955b
...
...
@@ -124,6 +124,9 @@ module API
group
=
find_group!
(
params
[
:id
])
authorize!
:admin_group
,
group
# EE
authenticated_as_admin!
if
params
[
:shared_runners_minutes_limit
]
if
::
Groups
::
UpdateService
.
new
(
group
,
current_user
,
declared_params
(
include_missing:
false
)).
execute
present
group
,
with:
Entities
::
GroupDetail
,
current_user:
current_user
else
...
...
spec/requests/api/groups_spec.rb
View file @
32e3955b
...
...
@@ -274,11 +274,10 @@ describe API::Groups do
end
# EE
it
'
updates the group for
shared_runners_minutes_limit'
do
it
'
returns 403 for updating
shared_runners_minutes_limit'
do
put
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
),
shared_runners_minutes_limit:
133
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
133
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
...
...
@@ -289,6 +288,14 @@ describe API::Groups do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'name'
]).
to
eq
(
new_group_name
)
end
# EE
it
'updates the group for shared_runners_minutes_limit'
do
put
api
(
"/groups/
#{
group1
.
id
}
"
,
admin
),
shared_runners_minutes_limit:
133
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
133
)
end
end
context
'when authenticated as an user that can see the group'
do
...
...
spec/requests/api/users_spec.rb
View file @
32e3955b
...
...
@@ -447,9 +447,16 @@ describe API::Users do
expect
(
user
.
reload
.
email
).
not_to
eq
(
'invalid email'
)
end
it
"is not available for non admin users"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
user
),
attributes_for
(
:user
)
expect
(
response
).
to
have_http_status
(
403
)
context
'when the current user is not an admin'
do
it
"is not available"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
user
),
attributes_for
(
:user
)
expect
(
response
).
to
have_http_status
(
403
)
end
it
"cannot update their own shared_runners_minutes_limit"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
user
),
{
shared_runners_minutes_limit:
133
}
expect
(
response
).
to
have_http_status
(
403
)
end
end
it
"returns 404 for non-existing user"
do
...
...
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