test/domain_test.rb in github-ldap-1.3.1 vs test/domain_test.rb in github-ldap-1.3.2

- old
+ new

@@ -171,28 +171,22 @@ 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""") + @cn = "enterprise-posix-devs" 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}`" + assert @domain.is_member?(user, [@cn]), + "Expected `#{@cn}` to include the member `#{user.dn}`" end end -class GitHubLdapPosixGroupsTest < GitHub::Ldap::Test +class GitHubLdapPosixGroupsWithoutRecursionTest < 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 @@ -201,21 +195,43 @@ end def setup @ldap = GitHub::Ldap.new(options) @domain = @ldap.domain("dc=github,dc=com") + @cn = "enterprise-posix-devs" + end - @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""") + def test_membership_for_posixGroups + assert user = @ldap.domain('uid=mtodd,ou=users,dc=github,dc=com').bind + + assert @domain.is_member?(user, [@cn]), + "Expected `#{@cn}` to include the member `#{user.dn}`" end +end +# Specifically testing that this doesn't break when posixGroups are not +# supported. +class GitHubLdapWithoutPosixGroupsTest < 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, + # explicitly disable posixGroup support (even if the schema supports it) + posix_support: false + } + end + + def setup + @ldap = GitHub::Ldap.new(options) + @domain = @ldap.domain("dc=github,dc=com") + @cn = "enterprise-posix-devs" + 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}`" + refute @domain.is_member?(user, [@cn]), + "Expected `#{@cn}` to not include the member `#{user.dn}`" end end