-
Notifications
You must be signed in to change notification settings - Fork 26
Check memberships recursively #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
be83e88
fc34566
a9db2f7
68b2451
d29f991
055ac02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,9 +72,12 @@ def member_names | |||||||||||||
| # Internal - Check if an object class includes the member names | ||||||||||||||
| # Use `&` rathen than `include?` because both are arrays. | ||||||||||||||
| # | ||||||||||||||
| # NOTE: object classes are downcased by default in Net::LDAP, so this | ||||||||||||||
| # will fail to match correctly unless we also downcase our group classes. | ||||||||||||||
| # | ||||||||||||||
| # Returns true if the object class includes one of the group class names. | ||||||||||||||
| def group?(object_class) | ||||||||||||||
| !(GROUP_CLASS_NAMES & object_class).empty? | ||||||||||||||
| !(GROUP_CLASS_NAMES.map(&:downcase) & object_class.map(&:downcase)).empty? | ||||||||||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is necessary to properly partition groups from members here: github-ldap/lib/github/ldap/group.rb Lines 109 to 114 in 744b141
As documented,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| # Internal - Generate a hash with all the group DNs for caching purposes. | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,12 @@ def setup | |
| @group = @ldap.group("cn=enterprise,ou=groups,dc=github,dc=com") | ||
| end | ||
|
|
||
| def test_group? | ||
| object_classes = %w(groupOfNames) | ||
| assert @group.group?(object_classes) | ||
| assert @group.group?(object_classes.map(&:downcase)) | ||
| end | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second assertion fails without explicitly downcasing |
||
|
|
||
| def test_subgroups | ||
| assert_equal 3, @group.subgroups.size | ||
| end | ||
|
|
@@ -24,7 +30,7 @@ def test_members_from_subgroups | |
|
|
||
| def test_all_domain_groups | ||
| groups = groups_domain.all_groups | ||
| assert_equal 4, groups.size | ||
| assert_equal 8, groups.size | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to fixture changes. |
||
| end | ||
|
|
||
| def test_filter_domain_groups | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skips trying
PosixGroupunless it's enabled. It's on by default, so this doesn't result in changed behavior, just means we can disable this behavior at will.