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/>.
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
);
36 ok
= tldap_unescape_inplace(dn
, &dnlen
);
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
);
49 ok
= tldap_unescape_inplace(dn
, &dnlen
);
52 assert_string_equal(dn
, unescaped_dn
);
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
);