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
3dd64ffe
Commit
3dd64ffe
authored
Sep 11, 2019
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SCIM Users Entity
parent
68818f67
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
5 deletions
+98
-5
ee/lib/api/scim.rb
ee/lib/api/scim.rb
+2
-5
ee/lib/ee/gitlab/scim/users.rb
ee/lib/ee/gitlab/scim/users.rb
+40
-0
ee/spec/lib/ee/gitlab/scim/users_spec.rb
ee/spec/lib/ee/gitlab/scim/users_spec.rb
+56
-0
No files found.
ee/lib/api/scim.rb
View file @
3dd64ffe
...
@@ -105,11 +105,8 @@ module API
...
@@ -105,11 +105,8 @@ module API
status
200
status
200
present
:totalResults
,
results
.
count
result_set
=
{
resources:
response_page
,
total_results:
results
.
count
,
items_per_page:
per_page
(
params
[
:count
]),
start_index:
params
[
:startIndex
]
}
present
:startIndex
,
params
[
:startIndex
].
presence
||
1
present
result_set
,
with:
::
EE
::
Gitlab
::
Scim
::
Users
present
:itemsPerPage
,
per_page
(
params
[
:count
])
present
:schemas
,
[
'urn:ietf:params:scim:api:messages:2.0:ListResponse'
]
present
:Resources
,
response_page
,
with:
::
EE
::
Gitlab
::
Scim
::
User
end
end
desc
'Get a SAML user'
do
desc
'Get a SAML user'
do
...
...
ee/lib/ee/gitlab/scim/users.rb
0 → 100644
View file @
3dd64ffe
# frozen_string_literal: true
module
EE
module
Gitlab
module
Scim
class
Users
<
Grape
::
Entity
expose
:schemas
expose
:total_results
,
as: :totalResults
expose
:items_per_page
,
as: :itemsPerPage
expose
:start_index
,
as: :startIndex
expose
:resources
,
as: :Resources
,
using:
::
EE
::
Gitlab
::
Scim
::
User
private
DEFAULT_SCHEMA
=
'urn:ietf:params:scim:api:messages:2.0:ListResponse'
def
schemas
[
DEFAULT_SCHEMA
]
end
def
total_results
object
[
:total_results
]
||
resources
.
count
end
def
items_per_page
object
[
:items_per_page
]
||
Kaminari
.
config
.
default_per_page
end
def
start_index
object
[
:start_index
].
presence
||
1
end
def
resources
object
[
:resources
]
||
[]
end
end
end
end
end
ee/spec/lib/ee/gitlab/scim/users_spec.rb
0 → 100644
View file @
3dd64ffe
# frozen_string_literal: true
require
'spec_helper'
describe
::
EE
::
Gitlab
::
Scim
::
Users
do
let
(
:user
)
{
build
(
:user
)
}
let
(
:identity
)
{
build
(
:group_saml_identity
,
user:
user
)
}
let
(
:entity
)
do
described_class
.
new
(
resources:
[
identity
])
end
subject
{
entity
.
as_json
}
it
'contains the schemas'
do
expect
(
subject
[
:schemas
]).
to
eq
([
'urn:ietf:params:scim:api:messages:2.0:ListResponse'
])
end
it
'calculates the totalResults'
do
expect
(
subject
[
:totalResults
]).
to
eq
(
1
)
end
it
'contains the default itemsPerPage'
do
expect
(
subject
[
:itemsPerPage
]).
to
eq
(
20
)
end
it
'contains the default startIndex'
do
expect
(
subject
[
:startIndex
]).
to
eq
(
1
)
end
it
'contains the user'
do
expect
(
subject
[
:Resources
]).
not_to
be_empty
end
it
'contains the user ID'
do
expect
(
subject
[
:Resources
].
first
[
:id
]).
to
eq
(
identity
.
extern_uid
)
end
context
'with configured values'
do
let
(
:entity
)
do
described_class
.
new
(
resources:
[
identity
],
total_results:
31
,
items_per_page:
10
,
start_index:
30
)
end
it
'contains the configured totalResults'
do
expect
(
subject
[
:totalResults
]).
to
eq
(
31
)
end
it
'contains the configured itemsPerPage'
do
expect
(
subject
[
:itemsPerPage
]).
to
eq
(
10
)
end
it
'contains the configured startIndex'
do
expect
(
subject
[
:startIndex
]).
to
eq
(
30
)
end
end
end
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