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
cc76d77b
Commit
cc76d77b
authored
May 28, 2019
by
Imre Farkas
Committed by
Yorick Peterse
May 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move EE specific lines in API::Users
parent
c4f94a99
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
32 deletions
+93
-32
ee/lib/ee/api/helpers/users_helpers.rb
ee/lib/ee/api/helpers/users_helpers.rb
+22
-0
ee/spec/requests/api/users_spec.rb
ee/spec/requests/api/users_spec.rb
+46
-0
lib/api/helpers/users_helpers.rb
lib/api/helpers/users_helpers.rb
+18
-0
lib/api/users.rb
lib/api/users.rb
+4
-8
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+3
-24
No files found.
ee/lib/ee/api/helpers/users_helpers.rb
0 → 100644
View file @
cc76d77b
# frozen_string_literal: true
module
EE
module
API
module
Helpers
module
UsersHelpers
extend
ActiveSupport
::
Concern
prepended
do
params
:optional_params_ee
do
optional
:shared_runners_minutes_limit
,
type:
Integer
,
desc:
'Pipeline minutes quota for this user'
optional
:extra_shared_runners_minutes_limit
,
type:
Integer
,
desc:
'(admin-only) Extra pipeline minutes quota for this user'
end
params
:optional_index_params_ee
do
optional
:skip_ldap
,
type:
Grape
::
API
::
Boolean
,
default:
false
,
desc:
'Skip LDAP users'
end
end
end
end
end
end
ee/spec/requests/api/users_spec.rb
0 → 100644
View file @
cc76d77b
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Users
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
context
'extended audit events'
do
describe
"PUT /users/:id"
do
it
"creates audit event when updating user with new password"
do
stub_licensed_features
(
extended_audit_events:
true
)
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{
password:
'12345678'
}
expect
(
AuditEvent
.
count
).
to
eq
(
1
)
end
end
end
context
'shared_runners_minutes_limit'
do
describe
"PUT /users/:id"
do
context
'when user is an admin'
do
it
"updates shared_runners_minutes_limit"
do
expect
do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{
shared_runners_minutes_limit:
133
}
end
.
to
change
{
user
.
reload
.
shared_runners_minutes_limit
}
.
from
(
nil
).
to
(
133
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
133
)
end
end
context
'when user is not an admin'
do
it
"cannot update their own shared_runners_minutes_limit"
do
expect
do
put
api
(
"/users/
#{
user
.
id
}
"
,
user
),
params:
{
shared_runners_minutes_limit:
133
}
end
.
not_to
change
{
user
.
reload
.
shared_runners_minutes_limit
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
end
end
end
lib/api/helpers/users_helpers.rb
0 → 100644
View file @
cc76d77b
# frozen_string_literal: true
module
API
module
Helpers
module
UsersHelpers
extend
ActiveSupport
::
Concern
extend
Grape
::
API
::
Helpers
params
:optional_params_ee
do
end
params
:optional_index_params_ee
do
end
end
end
end
API
::
Helpers
::
UsersHelpers
.
prepend
(
EE
::
API
::
Helpers
::
UsersHelpers
)
lib/api/users.rb
View file @
cc76d77b
...
...
@@ -15,6 +15,8 @@ module API
authenticate_non_get!
end
helpers
Helpers
::
UsersHelpers
helpers
do
# rubocop: disable CodeReuse/ActiveRecord
def
find_user_by_id
(
params
)
...
...
@@ -52,10 +54,7 @@ module API
optional
:private_profile
,
type:
Boolean
,
desc:
'Flag indicating the user has a private profile'
all_or_none_of
:extern_uid
,
:provider
if
Gitlab
.
ee?
optional
:shared_runners_minutes_limit
,
type:
Integer
,
desc:
'Pipeline minutes quota for this user'
optional
:extra_shared_runners_minutes_limit
,
type:
Integer
,
desc:
'(admin-only) Extra pipeline minutes quota for this user'
end
use
:optional_params_ee
end
params
:sort_params
do
...
...
@@ -85,10 +84,7 @@ module API
use
:sort_params
use
:pagination
use
:with_custom_attributes
if
Gitlab
.
ee?
optional
:skip_ldap
,
type:
Boolean
,
default:
false
,
desc:
'Skip LDAP users'
end
use
:optional_index_params_ee
end
# rubocop: disable CodeReuse/ActiveRecord
get
do
...
...
spec/requests/api/users_spec.rb
View file @
cc76d77b
...
...
@@ -280,11 +280,12 @@ describe API::Users do
context
"when authenticated and ldap is enabled"
do
it
"returns non-ldap user"
do
create
:omniauth_user
,
provider:
"ldapserver1"
get
api
(
"/users"
,
user
),
params:
{
skip_ldap:
"true"
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
username
=
user
.
username
expect
(
json_response
.
first
[
"username"
]).
to
eq
username
expect
(
json_response
.
first
[
"username"
]).
to
eq
user
.
username
end
end
end
...
...
@@ -644,13 +645,10 @@ describe API::Users do
end
it
"updates user with new password and forces reset on next login"
do
stub_licensed_features
(
extended_audit_events:
true
)
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{
password:
'12345678'
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
user
.
reload
.
password_expires_at
).
to
be
<=
Time
.
now
expect
(
AuditEvent
.
count
).
to
eq
(
1
)
end
it
"updates user with organization"
do
...
...
@@ -740,17 +738,6 @@ describe API::Users do
expect
(
user
.
reload
.
private_profile
).
to
eq
(
true
)
end
# EE
it
"updates shared_runners_minutes_limit"
do
expect
do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
params:
{
shared_runners_minutes_limit:
133
}
end
.
to
change
{
user
.
reload
.
shared_runners_minutes_limit
}
.
from
(
nil
).
to
(
133
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
133
)
end
it
"does not update admin status"
do
put
api
(
"/users/
#{
admin_user
.
id
}
"
,
admin
),
params:
{
can_create_group:
false
}
...
...
@@ -774,14 +761,6 @@ describe API::Users do
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
it
"cannot update their own shared_runners_minutes_limit"
do
expect
do
put
api
(
"/users/
#{
user
.
id
}
"
,
user
),
params:
{
shared_runners_minutes_limit:
133
}
end
.
not_to
change
{
user
.
reload
.
shared_runners_minutes_limit
}
expect
(
response
).
to
have_gitlab_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