test/domain_test.rb in github-ldap-1.2.1 vs test/domain_test.rb in github-ldap-1.3.0

- old
+ new

@@ -1,6 +1,6 @@ -require 'test_helper' +require_relative 'test_helper' module GitHubLdapDomainTestCases def setup @ldap = GitHub::Ldap.new(options) @domain = @ldap.domain("dc=github,dc=com") @@ -155,7 +155,67 @@ def test_membership_in_subgroups user = @ldap.domain('uid=rubiojr,ou=users,dc=github,dc=com').bind assert @domain.is_member?(user, %w(enterprise-ops)), "Expected `enterprise-ops` to include the member `#{user.dn}`" + end +end + +class GitHubLdapPosixGroupsWithRecursionFallbackTest < GitHub::Ldap::Test + def self.test_server_options + { + custom_schemas: FIXTURES.join('posixGroup.schema.ldif'), + user_fixtures: FIXTURES.join('github-with-posixGroups.ldif').to_s, + # so we exercise the recursive group search fallback + recursive_group_search_fallback: true + } + end + + def setup + @ldap = GitHub::Ldap.new(options) + @domain = @ldap.domain("dc=github,dc=com") + + @group = Net::LDAP::Entry._load(""" +dn: cn=enterprise-posix-devs,ou=groups,dc=github,dc=com +cn: enterprise-posix-devs +objectClass: posixGroup +memberUid: benburkert +memberUid: mtodd""") + end + + def test_membership_for_posixGroups + assert user = @ldap.domain('uid=mtodd,ou=users,dc=github,dc=com').bind + + assert @domain.is_member?(user, @group.cn), + "Expected `#{@group.cn.first}` to include the member `#{user.dn}`" + end +end + +class GitHubLdapPosixGroupsTest < GitHub::Ldap::Test + def self.test_server_options + { + custom_schemas: FIXTURES.join('posixGroup.schema.ldif'), + user_fixtures: FIXTURES.join('github-with-posixGroups.ldif').to_s, + # so we test the test the non-recursive group membership search + recursive_group_search_fallback: false + } + end + + def setup + @ldap = GitHub::Ldap.new(options) + @domain = @ldap.domain("dc=github,dc=com") + + @group = Net::LDAP::Entry._load(""" +dn: cn=enterprise-posix-devs,ou=groups,dc=github,dc=com +cn: enterprise-posix-devs +objectClass: posixGroup +memberUid: benburkert +memberUid: mtodd""") + end + + def test_membership_for_posixGroups + assert user = @ldap.domain('uid=mtodd,ou=users,dc=github,dc=com').bind + + assert @domain.is_member?(user, @group.cn), + "Expected `#{@group.cn.first}` to include the member `#{user.dn}`" end end