Remove old code

parent d8103cba
...@@ -85,21 +85,6 @@ module Gitlab ...@@ -85,21 +85,6 @@ module Gitlab
end end
end end
# Add user to GitLab group
# In case user already exists: update his access level
# only if existing permissions are lower than ldap one.
def add_user_to_groups(user_id, group_cn)
groups = ::Group.where(ldap_cn: group_cn)
groups.each do |group|
next unless group.ldap_access.present?
group_access = group.users_groups.find_by_user_id(user_id)
next if group_access && group_access.group_access >= group.ldap_access
group.add_users([user_id], group.ldap_access)
end
end
# Remove user from GitLab group # Remove user from GitLab group
def remove_user_from_groups(user_id, group_cn) def remove_user_from_groups(user_id, group_cn)
groups = ::Group.where(ldap_cn: group_cn) groups = ::Group.where(ldap_cn: group_cn)
...@@ -149,7 +134,7 @@ module Gitlab ...@@ -149,7 +134,7 @@ module Gitlab
if active_group_links.any? if active_group_links.any?
group.add_user(user, fetch_group_access(group, user, active_group_links)) group.add_user(user, fetch_group_access(group, user, active_group_links))
else else
group.users.delete(user) #ensure this is the nice way to do it group.users.delete(user)
end end
end end
end end
......
...@@ -9,29 +9,6 @@ describe Gitlab::LDAP::Access do ...@@ -9,29 +9,6 @@ describe Gitlab::LDAP::Access do
group group
end end
describe :add_user_to_groups do
it "should add user to group" do
access.add_user_to_groups(user.id, "oss")
member = group.members.first
member.user.should == user
member.group_access.should == Gitlab::Access::DEVELOPER
end
it "should respect higher permissions" do
group.add_owner(user)
access.add_user_to_groups(user.id, "oss")
group.owners.should include(user)
end
it "should update lower permissions" do
group.add_user(user, Gitlab::Access::REPORTER)
access.add_user_to_groups(user.id, "oss")
member = group.members.first
member.user.should == user
member.group_access.should == Gitlab::Access::DEVELOPER
end
end
describe :update_user_email do describe :update_user_email do
let(:user_ldap) { create(:user, provider: 'ldap', extern_uid: "66048")} let(:user_ldap) { create(:user, provider: 'ldap', extern_uid: "66048")}
...@@ -229,7 +206,7 @@ objectclass: posixGroup ...@@ -229,7 +206,7 @@ objectclass: posixGroup
end end
end end
describe "cns_with_access" do describe :cns_with_access do
let(:ldap_group_response_1) do let(:ldap_group_response_1) do
Net::LDAP::Entry.from_single_ldif_string( Net::LDAP::Entry.from_single_ldif_string(
%Q{dn: cn=group1,ou=groups,dc=bar,dc=com %Q{dn: cn=group1,ou=groups,dc=bar,dc=com
...@@ -269,5 +246,9 @@ objectclass: posixGroup ...@@ -269,5 +246,9 @@ objectclass: posixGroup
expect(access.cns_with_access(ldap_user)).to eql ['group1'] expect(access.cns_with_access(ldap_user)).to eql ['group1']
end end
end end
describe :update_ldap_group_links do
pending("I really need some test code!")
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment