smbtorture: Use NT_STATUS_PENDING instead of STATUS_PENDING
[Samba.git] / source3 / lib / test_tldap.c
blob659c5a7371afd83c97762c7f4d178332a428ac3c
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 <stdint.h>
24 #include <setjmp.h>
25 #include <cmocka.h>
27 #include "source3/lib/tldap.c"
29 static void test_tldap_unescape_ldapv3(void **state)
31 const char *unescaped_dn = "(&(objectclass=group)(cn=Samba*))";
32 char dn[] = "\\28&\\28objectclass=group\\29\\28cn=Samba\\2a\\29\\29";
33 size_t dnlen = sizeof(dn);
34 bool ok;
36 ok = tldap_unescape_inplace(dn, &dnlen);
37 assert_true(ok);
39 assert_string_equal(dn, unescaped_dn);
42 static void test_tldap_unescape_ldapv2(void **state)
44 const char *unescaped_dn = "(&(objectclass=group)(cn=Samba*))";
45 char dn[] = "\\(&\\(objectclass=group\\)\\(cn=Samba\\*\\)\\)";
46 size_t dnlen = sizeof(dn);
47 bool ok;
49 ok = tldap_unescape_inplace(dn, &dnlen);
50 assert_true(ok);
52 assert_string_equal(dn, unescaped_dn);
55 int main(void) {
56 const struct CMUnitTest tests[] = {
57 cmocka_unit_test(test_tldap_unescape_ldapv3),
58 cmocka_unit_test(test_tldap_unescape_ldapv2)
61 cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
62 return cmocka_run_group_tests(tests, NULL, NULL);