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/>.
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
);
35 ok
= tldap_unescape_inplace(dn
, &dnlen
);
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
);
48 ok
= tldap_unescape_inplace(dn
, &dnlen
);
51 assert_string_equal(dn
, unescaped_dn
);
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
);