lib/ldb/tests: add test for ldb.Dn passed utf8 unicode
authorNoel Power <noel.power@suse.com>
Mon, 24 Sep 2018 13:37:50 +0000 (14:37 +0100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 5 Nov 2018 11:44:32 +0000 (12:44 +0100)
object dn format should be a utf8 encoded string
Note: Currently this fails in python2 as the c python binding for
      the dn string param uses PyArg_ParseTupleAndKeywords() with 's'
      format, this will accept str *or* unicode in the default encoding.
      The default encoding in python2 is... ascii.

Also adding here a knownfail to squash the error produced by the test.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit d1492ab919b19d1ca72f1d7c97ac0ca3bee13a2a)

lib/ldb/tests/python/api.py
selftest/knownfail

index e40109606975804d2ab31dcb0444489b03ca64a5..0a883961c00d303066548c58416a57ac27db0e0a 100755 (executable)
@@ -137,6 +137,10 @@ class SimpleLdb(LdbBaseTest):
         l = ldb.Ldb(self.url(), flags=self.flags())
         self.assertEqual(len(l.search(controls=["paged_results:0:5"])), 0)
 
+    def test_utf8_ldb_Dn(self):
+        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_search_attrs(self):
         l = ldb.Ldb(self.url(), flags=self.flags())
         self.assertEqual(len(l.search(ldb.Dn(l, ""), ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)
index baf3d57a31a0f58e565018ef8709adc3399b42ac..a122b27ad2196a7b8da43c25b72fbe437b15d63e 100644 (file)
 # Disabling NTLM means you can't use samr to change the password
 ^samba.tests.ntlmdisabled.python\(ktest\).ntlmdisabled.NtlmDisabledTests.test_samr_change_password\(ktest\)
 ^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\)
+# Ldb test api.SimpleLdb.test_utf8_ldb_Dn is expected to fail
+^ldb.python.api.SimpleLdb.test_utf8_ldb_Dn(none)