python/samba: Another object.next() to next(object) py2/py3 converstion
[Samba.git] / source3 / lib / test_tldap.c
bloba6c2f2117cb5d0e04347f769d126b8629b8ad1c3
1 /*
2 * Unix SMB/CIFS implementation.
3 * Test suite for ldap client
5 * Copyright (C) 2018 Andreas Schneider <asn@samba.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <stdarg.h>
22 #include <stddef.h>
23 #include <setjmp.h>
24 #include <cmocka.h>
26 #include "source3/lib/tldap.c"
28 static void test_tldap_unescape_ldapv3(void **state)
30 const char *unescaped_dn = "(&(objectclass=group)(cn=Samba*))";
31 char dn[] = "\\28&\\28objectclass=group\\29\\28cn=Samba\\2a\\29\\29";
32 size_t dnlen = sizeof(dn);
33 bool ok;
35 ok = tldap_unescape_inplace(dn, &dnlen);
36 assert_true(ok);
38 assert_string_equal(dn, unescaped_dn);
41 static void test_tldap_unescape_ldapv2(void **state)
43 const char *unescaped_dn = "(&(objectclass=group)(cn=Samba*))";
44 char dn[] = "\\(&\\(objectclass=group\\)\\(cn=Samba\\*\\)\\)";
45 size_t dnlen = sizeof(dn);
46 bool ok;
48 ok = tldap_unescape_inplace(dn, &dnlen);
49 assert_true(ok);
51 assert_string_equal(dn, unescaped_dn);
54 int main(void) {
55 const struct CMUnitTest tests[] = {
56 cmocka_unit_test(test_tldap_unescape_ldapv3),
57 cmocka_unit_test(test_tldap_unescape_ldapv2)
60 cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
61 return cmocka_run_group_tests(tests, NULL, NULL);