mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-15 07:36:41 +10:00
Add unit test for update_ldap_group_links
This is the first stage, need to add some other to test revoking and upgrading of the permissions
This commit is contained in:
@@ -129,7 +129,7 @@ module Gitlab
|
||||
# Loop throug all ldap conneted groups, and update the users link with it
|
||||
def update_ldap_group_links(user)
|
||||
gitlab_groups_with_ldap_link.each do |group|
|
||||
active_group_links = group.ldap_group_links.where(cn: cns_with_access(ldap_user))
|
||||
active_group_links = group.ldap_group_links.where(cn: cns_with_access(get_ldap_user(user)))
|
||||
|
||||
if active_group_links.any?
|
||||
group.add_user(user, fetch_group_access(group, user, active_group_links))
|
||||
@@ -141,7 +141,7 @@ module Gitlab
|
||||
|
||||
# Get the group_access for a give user.
|
||||
# Always respect the current level, never downgrade it.
|
||||
def fetch_group_acess(group, user, active_group_links)
|
||||
def fetch_group_access(group, user, active_group_links)
|
||||
current_access_level = group.users_groups.where(user_id: user).maximum(:group_access)
|
||||
max_group_access_level = active_group_links.maximum(:group_access)
|
||||
|
||||
|
||||
@@ -244,7 +244,26 @@ objectclass: posixGroup
|
||||
end
|
||||
|
||||
describe :update_ldap_group_links do
|
||||
pending("I really need some test code!")
|
||||
let(:cns_with_access) { %w(ldap-group1 ldap-group2) }
|
||||
let(:gitlab_group_1) { create :group }
|
||||
let(:gitlab_group_2) { create :group }
|
||||
|
||||
before do
|
||||
access.stub(:get_ldap_user)
|
||||
access.stub(cns_with_access: cns_with_access)
|
||||
end
|
||||
|
||||
context "non existing access for group-1, allowed via ldap-group1 as DEVELOPER" do
|
||||
before do
|
||||
gitlab_group_1.ldap_group_links.create cn: 'ldap-group1', group_access: Gitlab::Access::MASTER
|
||||
end
|
||||
|
||||
it "gives the user master access for group 1" do
|
||||
access.update_ldap_group_links(user)
|
||||
|
||||
expect( gitlab_group_1.has_master?(user) ).to be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user