Commit 869ae9a1 authored by Noel Power's avatar Noel Power Committed by Karolin Seeger

lib/ldb/tests/python: Add test to pass utf8 encoded bytes to ldb.Dn

This test should demonstrate an error with the 'es' format in python
where a 'str' byte-string is passed (containing utf8 encoded bytes)
with some characters that cannot be decoded as ascii. The same
code if run in python3 should generate an error (needs string not

Also Add knownfail for ldb.Dn passed utf8 encoded byte string

BUG: default avatarNoel Power <>
Reviewed-by: default avatarDouglas Bagnall <>
(cherry picked from commit f8758b3b)
parent 043e6e8b
......@@ -141,6 +141,21 @@ class SimpleLdb(LdbBaseTest):
l = ldb.Ldb(self.url(), flags=self.flags())
dn = ldb.Dn(l, (b'a=' + b'\xc4\x85\xc4\x87\xc4\x99\xc5\x82\xc5\x84\xc3\xb3\xc5\x9b\xc5\xba\xc5\xbc').decode('utf8'))
def test_utf8_encoded_ldb_Dn(self):
l = ldb.Ldb(self.url(), flags=self.flags())
dn_encoded_utf8 = b'a=' + b'\xc4\x85\xc4\x87\xc4\x99\xc5\x82\xc5\x84\xc3\xb3\xc5\x9b\xc5\xba\xc5\xbc'
dn = ldb.Dn(l, dn_encoded_utf8)
except UnicodeDecodeError as e:
except TypeError as te:
if PY3:
p3errors = ["argument 2 must be str, not bytes",
"Can't convert 'bytes' object to str implicitly"]
self.assertIn(str(te), p3errors)
def test_search_attrs(self):
l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(len(, ""), ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)
......@@ -349,3 +349,5 @@
# Disabling NTLM means you can't use samr to change the password
# Ldb test api.SimpleLdb.test_utf8_ldb_Dn is expected to fail
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment