Beispiel #1
0
    def test_startswith_descendant(self):
        # dn_startswith returns True if descendant_dn is a descendant of dn.
        descendant = 'cn=Babs Jansen,ou=Keystone,ou=OpenStack,dc=example.com'
        dn = 'ou=OpenStack,dc=example.com'
        self.assertTrue(ks_ldap.dn_startswith(descendant, dn))

        descendant = 'uid=12345,ou=Users,dc=example,dc=com'
        dn = 'ou=Users,dc=example,dc=com'
        self.assertTrue(ks_ldap.dn_startswith(descendant, dn))
Beispiel #2
0
    def test_startswith_descendant(self):
        # dn_startswith returns True if descendant_dn is a descendant of dn.
        descendant = 'cn=Babs Jansen,ou=Keystone,ou=OpenStack,dc=example.com'
        dn = 'ou=OpenStack,dc=example.com'
        self.assertTrue(ks_ldap.dn_startswith(descendant, dn))

        descendant = 'uid=12345,ou=Users,dc=example,dc=com'
        dn = 'ou=Users,dc=example,dc=com'
        self.assertTrue(ks_ldap.dn_startswith(descendant, dn))
Beispiel #3
0
    def is_user(self, dn):
        """Return True if the entry is a user."""
        # NOTE(blk-u): It's easy to check if the DN is under the User tree,
        # but may not be accurate. A more accurate test would be to fetch the
        # entry to see if it's got the user objectclass, but this could be
        # really expensive considering how this is used.

        return common_ldap.dn_startswith(dn, self.tree_dn)
Beispiel #4
0
    def is_user(self, dn):
        """Returns True if the entry is a user."""
        # NOTE(blk-u): It's easy to check if the DN is under the User tree,
        # but may not be accurate. A more accurate test would be to fetch the
        # entry to see if it's got the user objectclass, but this could be
        # really expensive considering how this is used.

        return common_ldap.dn_startswith(dn, self.tree_dn)
Beispiel #5
0
 def test_startswith_unicode(self):
     # dn_startswith accepts unicode.
     child = u'cn=cn=fäké,ou=OpenStäck'
     parent = 'ou=OpenStäck'
     self.assertTrue(ks_ldap.dn_startswith(child, parent))
Beispiel #6
0
 def test_startswith_parsed_dns(self):
     # dn_startswith also accepts parsed DNs.
     descendant = ldap.dn.str2dn('cn=Babs Jansen,ou=OpenStack')
     dn = ldap.dn.str2dn('ou=OpenStack')
     self.assertTrue(ks_ldap.dn_startswith(descendant, dn))
Beispiel #7
0
 def test_startswith_not_parent(self):
     # dn_startswith returns False if descendant_dn is not under the dn
     child = 'cn=Babs Jansen,ou=OpenStack'
     parent = 'dc=example.com'
     self.assertFalse(ks_ldap.dn_startswith(child, parent))
Beispiel #8
0
 def test_startswith_same(self):
     # dn_startswith returns False if DNs are the same.
     dn = 'cn=Babs Jansen,ou=OpenStack'
     self.assertFalse(ks_ldap.dn_startswith(dn, dn))
Beispiel #9
0
 def test_startswith_parent(self):
     # dn_startswith returns False if descendant_dn is a parent of dn.
     child = 'cn=Babs Jansen,ou=OpenStack'
     parent = 'ou=OpenStack'
     self.assertFalse(ks_ldap.dn_startswith(parent, child))
Beispiel #10
0
 def test_startswith_under_child(self):
     # dn_startswith returns True if descendant_dn is a child of dn.
     child = 'cn=Babs Jansen,ou=OpenStack'
     parent = 'ou=OpenStack'
     self.assertTrue(ks_ldap.dn_startswith(child, parent))
Beispiel #11
0
 def test_startswith_unicode(self):
     # dn_startswith accepts unicode.
     child = u'cn=cn=fäké,ou=OpenStäck'
     parent = 'ou=OpenStäck'
     self.assertTrue(ks_ldap.dn_startswith(child, parent))
Beispiel #12
0
 def test_startswith_parsed_dns(self):
     # dn_startswith also accepts parsed DNs.
     descendant = ldap.dn.str2dn('cn=Babs Jansen,ou=OpenStack')
     dn = ldap.dn.str2dn('ou=OpenStack')
     self.assertTrue(ks_ldap.dn_startswith(descendant, dn))
Beispiel #13
0
 def test_startswith_not_parent(self):
     # dn_startswith returns False if descendant_dn is not under the dn
     child = 'cn=Babs Jansen,ou=OpenStack'
     parent = 'dc=example.com'
     self.assertFalse(ks_ldap.dn_startswith(child, parent))
Beispiel #14
0
 def test_startswith_same(self):
     # dn_startswith returns False if DNs are the same.
     dn = 'cn=Babs Jansen,ou=OpenStack'
     self.assertFalse(ks_ldap.dn_startswith(dn, dn))
Beispiel #15
0
 def test_startswith_parent(self):
     # dn_startswith returns False if descendant_dn is a parent of dn.
     child = 'cn=Babs Jansen,ou=OpenStack'
     parent = 'ou=OpenStack'
     self.assertFalse(ks_ldap.dn_startswith(parent, child))
Beispiel #16
0
 def test_startswith_under_child(self):
     # dn_startswith returns True if descendant_dn is a child of dn.
     child = 'cn=Babs Jansen,ou=OpenStack'
     parent = 'ou=OpenStack'
     self.assertTrue(ks_ldap.dn_startswith(child, parent))