Skip to content
Snippets Groups Projects
Commit 1bf48360 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge branch 'ldap_group_integration' into 'master'

Ldap group integration

closes #237

See merge request !307
parents f440c2e3 52800b50
No related branches found
No related tags found
3 merge requests!8889WIP: Port of 25624-anticipate-obstacles-to-removing-turbolinks to EE.,!7795Asciidoctor plantuml,!7793Add support for PlantUML diagrams in Asciidoc.
Loading
Loading
@@ -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
 
#
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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?) }
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment