Ejemplo n.º 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(common_ldap.dn_startswith(descendant, dn))

        descendant = 'uid=12345,ou=Users,dc=example,dc=com'
        dn = 'ou=Users,dc=example,dc=com'
        self.assertTrue(common_ldap.dn_startswith(descendant, dn))
Ejemplo n.º 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(common_ldap.dn_startswith(descendant, dn))

        descendant = 'uid=12345,ou=Users,dc=example,dc=com'
        dn = 'ou=Users,dc=example,dc=com'
        self.assertTrue(common_ldap.dn_startswith(descendant, dn))
Ejemplo n.º 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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def test_startswith_unicode(self):
     # dn_startswith accepts unicode.
     child = u'cn=fäké,ou=OpenStäck'
     parent = u'ou=OpenStäck'
     self.assertTrue(common_ldap.dn_startswith(child, parent))
Ejemplo n.º 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(common_ldap.dn_startswith(descendant, dn))
Ejemplo n.º 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(common_ldap.dn_startswith(child, parent))
Ejemplo n.º 8
0
 def test_startswith_same(self):
     # dn_startswith returns False if DNs are the same.
     dn = 'cn=Babs Jansen,ou=OpenStack'
     self.assertFalse(common_ldap.dn_startswith(dn, dn))
Ejemplo n.º 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(common_ldap.dn_startswith(parent, child))
Ejemplo n.º 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(common_ldap.dn_startswith(child, parent))
Ejemplo n.º 11
0
 def test_startswith_unicode(self):
     # dn_startswith accepts unicode.
     child = u'cn=fäké,ou=OpenStäck'
     parent = u'ou=OpenStäck'
     self.assertTrue(common_ldap.dn_startswith(child, parent))
Ejemplo n.º 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(common_ldap.dn_startswith(descendant, dn))
Ejemplo n.º 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(common_ldap.dn_startswith(child, parent))
Ejemplo n.º 14
0
 def test_startswith_same(self):
     # dn_startswith returns False if DNs are the same.
     dn = 'cn=Babs Jansen,ou=OpenStack'
     self.assertFalse(common_ldap.dn_startswith(dn, dn))
Ejemplo n.º 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(common_ldap.dn_startswith(parent, child))
Ejemplo n.º 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(common_ldap.dn_startswith(child, parent))