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
1bf48360
Commit
1bf48360
authored
Feb 12, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ldap_group_integration' into 'master'
Ldap group integration closes #237 See merge request !307
parents
f440c2e3
52800b50
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
1 deletion
+31
-1
app/models/user.rb
app/models/user.rb
+5
-0
lib/api/users.rb
lib/api/users.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+13
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+12
-0
No files found.
app/models/user.rb
View file @
1bf48360
...
...
@@ -246,6 +246,11 @@ class User < ActiveRecord::Base
def
build_user
(
attrs
=
{})
User
.
new
(
attrs
)
end
def
non_ldap
joins
(
'LEFT JOIN identities ON identities.user_id = users.id'
).
where
(
'identities.provider IS NULL OR identities.provider NOT LIKE ?'
,
'ldap%'
)
end
end
#
...
...
lib/api/users.rb
View file @
1bf48360
...
...
@@ -13,7 +13,7 @@ module API
@users
=
User
.
all
@users
=
@users
.
active
if
params
[
:active
].
present?
@users
=
@users
.
where
(
'provider != ? OR provider IS NULL'
,
'ldap'
)
if
skip_ldap
@users
=
@users
.
non_ldap
if
skip_ldap
@users
=
@users
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@users
=
paginate
@users
...
...
spec/models/user_spec.rb
View file @
1bf48360
...
...
@@ -108,6 +108,19 @@ describe User do
end
end
end
describe
"non_ldap"
do
it
"retuns non-ldap user"
do
User
.
delete_all
create
:user
ldap_user
=
create
:omniauth_user
,
provider:
"ldapmain"
create
:omniauth_user
,
provider:
"gitlub"
users
=
User
.
non_ldap
users
.
count
.
should
==
2
users
.
detect
{
|
user
|
user
.
username
==
ldap_user
.
username
}.
should
be_nil
end
end
describe
"Respond to"
do
it
{
should
respond_to
(
:is_admin?
)
}
...
...
spec/requests/api/users_spec.rb
View file @
1bf48360
...
...
@@ -37,6 +37,18 @@ describe API::API, api: true do
json_response
.
first
.
keys
.
should
include
'can_create_project'
end
end
context
"when authenticated and ldap is enabled"
do
it
"should return non-ldap user"
do
User
.
delete_all
create
:omniauth_user
,
provider:
"ldapserver1"
get
api
(
"/users"
,
user
),
skip_ldap:
"true"
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
username
=
user
.
username
json_response
.
first
[
"username"
].
should
==
username
end
end
end
describe
"GET /users/:id"
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