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
95a03f90
Commit
95a03f90
authored
Feb 24, 2021
by
Jonas Waelter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow parameter 'external' for normal users
parent
aa240c59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
lib/api/users.rb
lib/api/users.rb
+1
-1
spec/finders/users_finder_spec.rb
spec/finders/users_finder_spec.rb
+6
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+12
-0
No files found.
lib/api/users.rb
View file @
95a03f90
...
...
@@ -98,7 +98,7 @@ module API
end
# rubocop: disable CodeReuse/ActiveRecord
get
feature_category: :users
do
authenticated_as_admin!
if
params
[
:extern
al
].
present?
||
(
params
[
:extern_uid
].
present?
&&
params
[
:provider
].
present?
)
authenticated_as_admin!
if
params
[
:extern
_uid
].
present?
&&
params
[
:provider
].
present?
unless
current_user
&
.
admin?
params
.
except!
(
:created_after
,
:created_before
,
:order_by
,
:sort
,
:two_factor
,
:without_projects
)
...
...
spec/finders/users_finder_spec.rb
View file @
95a03f90
...
...
@@ -51,6 +51,12 @@ RSpec.describe UsersFinder do
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
external_user
,
omniauth_user
,
admin_user
)
end
it
'filters by external users'
do
users
=
described_class
.
new
(
user
,
external:
true
).
execute
expect
(
users
).
to
contain_exactly
(
external_user
)
end
it
'filters by non external users'
do
users
=
described_class
.
new
(
user
,
non_external:
true
).
execute
...
...
spec/requests/api/users_spec.rb
View file @
95a03f90
...
...
@@ -320,6 +320,18 @@ RSpec.describe API::Users do
expect
(
json_response
).
to
all
(
include
(
'state'
=>
/(blocked|ldap_blocked)/
))
end
it
"returns an array of external users"
do
create
(
:user
)
external_user
=
create
(
:user
,
external:
true
)
get
api
(
"/users?external=true"
,
user
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/user/basics'
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
[
0
][
'id'
]).
to
eq
(
external_user
.
id
)
end
it
"returns one user"
do
get
api
(
"/users?username=
#{
omniauth_user
.
username
}
"
,
user
)
...
...
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