Line data Source code
1 : /*
2 : SSSD
3 :
4 : Tests if IPA and LDAP backend options are in sync
5 :
6 : Authors:
7 : Jakub Hrozek <jhrozek@redhat.com>
8 :
9 : Copyright (C) 2010 Red Hat
10 :
11 : This program is free software; you can redistribute it and/or modify
12 : it under the terms of the GNU General Public License as published by
13 : the Free Software Foundation; either version 3 of the License, or
14 : (at your option) any later version.
15 :
16 : This program is distributed in the hope that it will be useful,
17 : but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : GNU General Public License for more details.
20 :
21 : You should have received a copy of the GNU General Public License
22 : along with this program. If not, see <http://www.gnu.org/licenses/>.
23 : */
24 :
25 : #include <check.h>
26 : #include <stdlib.h>
27 : #include <talloc.h>
28 :
29 : #include "providers/ipa/ipa_common.h"
30 : #include "providers/ipa/ipa_opts.h"
31 : #include "providers/ldap/sdap.h"
32 : #include "providers/ldap/ldap_opts.h"
33 : #include "providers/krb5/krb5_opts.h"
34 : #include "providers/krb5/krb5_common.h"
35 : #include "providers/ad/ad_opts.h"
36 : #include "providers/dp_dyndns.h"
37 : #include "tests/common.h"
38 :
39 : struct test_domain {
40 : const char *domain;
41 : const char *basedn;
42 : };
43 :
44 : struct test_domain test_domains[] = {
45 : { "abc", "dc=abc"},
46 : { "a.b.c", "dc=a,dc=b,dc=c"},
47 : { "A.B.C", "dc=a,dc=b,dc=c"},
48 : { NULL, NULL}
49 : };
50 :
51 : /* Mock parsing search base without overlinking the test */
52 0 : errno_t sdap_parse_search_base(TALLOC_CTX *mem_ctx,
53 : struct dp_option *opts, int class,
54 : struct sdap_search_base ***_search_bases)
55 : {
56 0 : return EOK;
57 : }
58 :
59 1 : START_TEST(test_domain_to_basedn)
60 : {
61 : int ret;
62 : int i;
63 : TALLOC_CTX *tmp_ctx;
64 : char *basedn;
65 :
66 1 : tmp_ctx = talloc_new(NULL);
67 1 : fail_unless(tmp_ctx != NULL, "talloc_new failed");
68 :
69 1 : ret = domain_to_basedn(tmp_ctx, NULL, &basedn);
70 1 : fail_unless(ret == EINVAL,
71 : "domain_to_basedn does not fail with EINVAL if domain is NULL");
72 :
73 1 : ret = domain_to_basedn(tmp_ctx, "abc", NULL);
74 1 : fail_unless(ret == EINVAL,
75 : "domain_to_basedn does not fail with EINVAL if basedn is NULL");
76 :
77 4 : for(i=0; test_domains[i].domain != NULL; i++) {
78 3 : ret = domain_to_basedn(tmp_ctx, test_domains[i].domain, &basedn);
79 3 : fail_unless(ret == EOK, "domain_to_basedn failed");
80 3 : fail_unless(strcmp(basedn, test_domains[i].basedn) == 0,
81 : "domain_to_basedn returned wrong basedn, "
82 : "get [%s], expected [%s]", basedn, test_domains[i].basedn);
83 3 : talloc_free(basedn);
84 : }
85 :
86 1 : talloc_free(tmp_ctx);
87 : }
88 1 : END_TEST
89 :
90 1 : START_TEST(test_compare_opts)
91 : {
92 : errno_t ret;
93 :
94 1 : ret = compare_dp_options(default_basic_opts, SDAP_OPTS_BASIC,
95 : ipa_def_ldap_opts);
96 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
97 :
98 1 : ret = compare_dp_options(default_krb5_opts, KRB5_OPTS,
99 : ipa_def_krb5_opts);
100 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
101 :
102 1 : ret = compare_dp_options(ipa_dyndns_opts, DP_OPT_DYNDNS,
103 : ad_dyndns_opts);
104 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
105 : }
106 1 : END_TEST
107 :
108 1 : START_TEST(test_compare_sdap_attrs)
109 : {
110 : errno_t ret;
111 :
112 : /* General Attributes */
113 1 : ret = compare_sdap_attr_maps(generic_attr_map, SDAP_AT_GENERAL,
114 : ipa_attr_map);
115 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
116 :
117 : /* User Attributes */
118 1 : ret = compare_sdap_attr_maps(rfc2307_user_map, SDAP_OPTS_USER,
119 : ipa_user_map);
120 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
121 :
122 : /* Group Attributes */
123 1 : ret = compare_sdap_attr_maps(rfc2307_group_map, SDAP_OPTS_GROUP,
124 : ipa_group_map);
125 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
126 :
127 : /* Service Attributes */
128 1 : ret = compare_sdap_attr_maps(service_map, SDAP_OPTS_SERVICES,
129 : ipa_service_map);
130 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
131 :
132 : /* AutoFS Attributes */
133 1 : ret = compare_sdap_attr_maps(rfc2307_autofs_mobject_map,
134 : SDAP_OPTS_AUTOFS_MAP,
135 : ipa_autofs_mobject_map);
136 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
137 :
138 1 : ret = compare_sdap_attr_maps(rfc2307_autofs_entry_map,
139 : SDAP_OPTS_AUTOFS_ENTRY,
140 : ipa_autofs_entry_map);
141 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
142 : }
143 1 : END_TEST
144 :
145 1 : START_TEST(test_compare_2307_with_2307bis)
146 : {
147 : errno_t ret;
148 :
149 : /* User Attributes */
150 1 : ret = compare_sdap_attr_maps(rfc2307_user_map, SDAP_OPTS_USER,
151 : rfc2307bis_user_map);
152 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
153 :
154 : /* Group Attributes */
155 1 : ret = compare_sdap_attr_maps(rfc2307_group_map, SDAP_OPTS_GROUP,
156 : rfc2307bis_group_map);
157 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
158 :
159 : /* AutoFS Attributes */
160 1 : ret = compare_sdap_attr_maps(rfc2307_autofs_mobject_map,
161 : SDAP_OPTS_AUTOFS_MAP,
162 : rfc2307bis_autofs_mobject_map);
163 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
164 :
165 1 : ret = compare_sdap_attr_maps(rfc2307_autofs_entry_map,
166 : SDAP_OPTS_AUTOFS_ENTRY,
167 : rfc2307bis_autofs_entry_map);
168 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
169 : }
170 1 : END_TEST
171 :
172 10 : static void fail_unless_dp_opt_is_terminator(struct dp_option *o)
173 : {
174 10 : fail_unless(o->opt_name == NULL);
175 10 : fail_unless(o->type == 0);
176 10 : fail_unless(o->def_val.string == NULL);
177 10 : fail_unless(o->val.string == NULL);
178 10 : }
179 :
180 35 : static void fail_unless_sdap_opt_is_terminator(struct sdap_attr_map *m)
181 : {
182 35 : fail_unless(m->name == NULL);
183 35 : fail_unless(m->def_name == NULL);
184 35 : fail_unless(m->sys_name == NULL);
185 35 : fail_unless(m->opt_name == NULL);
186 35 : }
187 :
188 1 : START_TEST(test_dp_opt_sentinel)
189 : {
190 1 : fail_unless_dp_opt_is_terminator(&default_basic_opts[SDAP_OPTS_BASIC]);
191 :
192 1 : fail_unless_dp_opt_is_terminator(&default_krb5_opts[KRB5_OPTS]);
193 :
194 1 : fail_unless_dp_opt_is_terminator(&ad_basic_opts[AD_OPTS_BASIC]);
195 1 : fail_unless_dp_opt_is_terminator(&ad_def_ldap_opts[SDAP_OPTS_BASIC]);
196 1 : fail_unless_dp_opt_is_terminator(&ad_def_krb5_opts[KRB5_OPTS]);
197 :
198 1 : fail_unless_dp_opt_is_terminator(&ipa_basic_opts[IPA_OPTS_BASIC]);
199 1 : fail_unless_dp_opt_is_terminator(&ipa_def_ldap_opts[SDAP_OPTS_BASIC]);
200 1 : fail_unless_dp_opt_is_terminator(&ipa_def_krb5_opts[KRB5_OPTS]);
201 :
202 1 : fail_unless_dp_opt_is_terminator(&ad_dyndns_opts[DP_OPT_DYNDNS]);
203 1 : fail_unless_dp_opt_is_terminator(&ipa_dyndns_opts[DP_OPT_DYNDNS]);
204 : }
205 1 : END_TEST
206 :
207 1 : START_TEST(test_sdap_opt_sentinel)
208 : {
209 1 : fail_unless_sdap_opt_is_terminator(&generic_attr_map[SDAP_AT_GENERAL]);
210 1 : fail_unless_sdap_opt_is_terminator(&gen_ipa_attr_map[SDAP_AT_GENERAL]);
211 1 : fail_unless_sdap_opt_is_terminator(&gen_ad_attr_map[SDAP_AT_GENERAL]);
212 1 : fail_unless_sdap_opt_is_terminator(&ad_2008r2_attr_map[SDAP_AT_GENERAL]);
213 1 : fail_unless_sdap_opt_is_terminator(&ipa_attr_map[SDAP_AT_GENERAL]);
214 :
215 1 : fail_unless_sdap_opt_is_terminator(&rfc2307_user_map[SDAP_OPTS_USER]);
216 1 : fail_unless_sdap_opt_is_terminator(&rfc2307bis_user_map[SDAP_OPTS_USER]);
217 1 : fail_unless_sdap_opt_is_terminator(&gen_ad2008r2_user_map[SDAP_OPTS_USER]);
218 1 : fail_unless_sdap_opt_is_terminator(&ad_2008r2_user_map[SDAP_OPTS_USER]);
219 1 : fail_unless_sdap_opt_is_terminator(&ipa_user_map[SDAP_OPTS_USER]);
220 :
221 1 : fail_unless_sdap_opt_is_terminator(&rfc2307_group_map[SDAP_OPTS_GROUP]);
222 1 : fail_unless_sdap_opt_is_terminator(&rfc2307bis_group_map[SDAP_OPTS_GROUP]);
223 1 : fail_unless_sdap_opt_is_terminator(&gen_ad2008r2_group_map[SDAP_OPTS_GROUP]);
224 1 : fail_unless_sdap_opt_is_terminator(&ad_2008r2_group_map[SDAP_OPTS_GROUP]);
225 1 : fail_unless_sdap_opt_is_terminator(&ipa_group_map[SDAP_OPTS_GROUP]);
226 :
227 1 : fail_unless_sdap_opt_is_terminator(&native_sudorule_map[SDAP_OPTS_SUDO]);
228 :
229 1 : fail_unless_sdap_opt_is_terminator(&netgroup_map[SDAP_OPTS_NETGROUP]);
230 1 : fail_unless_sdap_opt_is_terminator(&ad_netgroup_map[SDAP_OPTS_NETGROUP]);
231 1 : fail_unless_sdap_opt_is_terminator(&ipa_netgroup_map[IPA_OPTS_NETGROUP]);
232 :
233 1 : fail_unless_sdap_opt_is_terminator(&ipa_host_map[IPA_OPTS_HOST]);
234 1 : fail_unless_sdap_opt_is_terminator(&ipa_hostgroup_map[IPA_OPTS_HOSTGROUP]);
235 1 : fail_unless_sdap_opt_is_terminator(&ipa_selinux_user_map[IPA_OPTS_SELINUX_USERMAP]);
236 1 : fail_unless_sdap_opt_is_terminator(&ipa_view_map[IPA_OPTS_VIEW]);
237 1 : fail_unless_sdap_opt_is_terminator(&ipa_override_map[IPA_OPTS_OVERRIDE]);
238 :
239 1 : fail_unless_sdap_opt_is_terminator(&service_map[SDAP_OPTS_SERVICES]);
240 1 : fail_unless_sdap_opt_is_terminator(&ad_service_map[SDAP_OPTS_SERVICES]);
241 1 : fail_unless_sdap_opt_is_terminator(&ipa_service_map[SDAP_OPTS_SERVICES]);
242 :
243 1 : fail_unless_sdap_opt_is_terminator(&rfc2307_autofs_mobject_map[SDAP_OPTS_AUTOFS_MAP]);
244 1 : fail_unless_sdap_opt_is_terminator(&rfc2307bis_autofs_mobject_map[SDAP_OPTS_AUTOFS_MAP]);
245 1 : fail_unless_sdap_opt_is_terminator(&ad_autofs_mobject_map[SDAP_OPTS_AUTOFS_MAP]);
246 1 : fail_unless_sdap_opt_is_terminator(&ipa_autofs_mobject_map[SDAP_OPTS_AUTOFS_MAP]);
247 :
248 1 : fail_unless_sdap_opt_is_terminator(&rfc2307_autofs_entry_map[SDAP_OPTS_AUTOFS_ENTRY]);
249 1 : fail_unless_sdap_opt_is_terminator(&rfc2307bis_autofs_entry_map[SDAP_OPTS_AUTOFS_ENTRY]);
250 1 : fail_unless_sdap_opt_is_terminator(&ad_autofs_entry_map[SDAP_OPTS_AUTOFS_ENTRY]);
251 1 : fail_unless_sdap_opt_is_terminator(&ipa_autofs_entry_map[SDAP_OPTS_AUTOFS_ENTRY]);
252 : }
253 1 : END_TEST
254 :
255 1 : START_TEST(test_copy_opts)
256 : {
257 : errno_t ret;
258 : TALLOC_CTX *tmp_ctx;
259 : struct dp_option *opts;
260 :
261 1 : tmp_ctx = talloc_new(NULL);
262 1 : fail_unless(tmp_ctx != NULL, "talloc_new failed");
263 :
264 1 : ret = dp_copy_defaults(tmp_ctx, ad_def_ldap_opts, SDAP_OPTS_BASIC, &opts);
265 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
266 :
267 89 : for (int i=0; i < SDAP_OPTS_BASIC; i++) {
268 : char *s1, *s2;
269 : bool b1, b2;
270 : int i1, i2;
271 : struct dp_opt_blob bl1, bl2;
272 :
273 88 : switch (opts[i].type) {
274 : case DP_OPT_STRING:
275 45 : s1 = dp_opt_get_string(opts, i);
276 45 : s2 = opts[i].def_val.string;
277 :
278 45 : if (s1 != NULL || s2 != NULL) {
279 11 : fail_unless(strcmp(s1, s2) == 0,
280 : "Option %s does not have default value after copy\n",
281 : opts[i].opt_name);
282 : }
283 45 : break;
284 :
285 : case DP_OPT_NUMBER:
286 22 : i1 = dp_opt_get_int(opts, i);
287 22 : i2 = opts[i].def_val.number;
288 :
289 22 : fail_unless(i1 == i2,
290 : "Option %s does not have default value after copy\n",
291 : opts[i].opt_name);
292 22 : break;
293 :
294 : case DP_OPT_BOOL:
295 20 : b1 = dp_opt_get_bool(opts, i);
296 20 : b2 = opts[i].def_val.boolean;
297 :
298 20 : fail_unless(b1 == b2,
299 : "Option %s does not have default value after copy\n",
300 : opts[i].opt_name);
301 20 : break;
302 :
303 : case DP_OPT_BLOB:
304 1 : bl1 = dp_opt_get_blob(opts, i);
305 1 : bl2 = opts[i].def_val.blob;
306 :
307 1 : fail_unless(bl1.length == bl2.length,
308 : "Blobs differ in size for option %s\n",
309 : opts[i].opt_name);
310 1 : fail_unless(memcmp(bl1.data, bl2.data, bl1.length) == 0,
311 : "Blobs differ in value for option %s\n",
312 : opts[i].opt_name);
313 : }
314 : }
315 :
316 1 : talloc_free(tmp_ctx);
317 : }
318 1 : END_TEST
319 :
320 1 : START_TEST(test_copy_sdap_map)
321 : {
322 : errno_t ret;
323 : struct sdap_attr_map *out_map;
324 :
325 1 : ret = sdap_copy_map(global_talloc_context,
326 : rfc2307_user_map, SDAP_OPTS_USER, &out_map);
327 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
328 1 : fail_unless(out_map[SDAP_OPTS_USER].name == NULL);
329 1 : fail_unless(out_map[SDAP_OPTS_USER].def_name == NULL);
330 1 : fail_unless(out_map[SDAP_OPTS_USER].sys_name == NULL);
331 1 : fail_unless(out_map[SDAP_OPTS_USER].opt_name == NULL);
332 1 : talloc_free(out_map);
333 :
334 1 : ret = sdap_copy_map(global_talloc_context,
335 : rfc2307bis_user_map, SDAP_OPTS_USER, &out_map);
336 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
337 1 : fail_unless(out_map[SDAP_OPTS_USER].name == NULL);
338 1 : fail_unless(out_map[SDAP_OPTS_USER].def_name == NULL);
339 1 : fail_unless(out_map[SDAP_OPTS_USER].sys_name == NULL);
340 1 : fail_unless(out_map[SDAP_OPTS_USER].opt_name == NULL);
341 1 : talloc_free(out_map);
342 :
343 1 : ret = sdap_copy_map(global_talloc_context,
344 : ipa_user_map, SDAP_OPTS_USER, &out_map);
345 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
346 1 : fail_unless(out_map[SDAP_OPTS_USER].name == NULL);
347 1 : fail_unless(out_map[SDAP_OPTS_USER].def_name == NULL);
348 1 : fail_unless(out_map[SDAP_OPTS_USER].sys_name == NULL);
349 1 : fail_unless(out_map[SDAP_OPTS_USER].opt_name == NULL);
350 1 : talloc_free(out_map);
351 :
352 1 : ret = sdap_copy_map(global_talloc_context,
353 : gen_ad2008r2_user_map, SDAP_OPTS_USER, &out_map);
354 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
355 1 : fail_unless(out_map[SDAP_OPTS_USER].name == NULL);
356 1 : fail_unless(out_map[SDAP_OPTS_USER].def_name == NULL);
357 1 : fail_unless(out_map[SDAP_OPTS_USER].sys_name == NULL);
358 1 : fail_unless(out_map[SDAP_OPTS_USER].opt_name == NULL);
359 1 : talloc_free(out_map);
360 : }
361 1 : END_TEST
362 :
363 1 : START_TEST(test_extra_opts)
364 : {
365 : errno_t ret;
366 1 : char *extra_attrs[] = { discard_const("foo"),
367 : discard_const("baz:bar"),
368 : NULL };
369 : struct sdap_attr_map *in_map;
370 : struct sdap_attr_map *out_map;
371 : size_t new_size;
372 :
373 1 : ret = sdap_copy_map(global_talloc_context, rfc2307_user_map,
374 : SDAP_OPTS_USER, &in_map);
375 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
376 :
377 1 : ret = sdap_extend_map(global_talloc_context,
378 : in_map,
379 : SDAP_OPTS_USER,
380 : extra_attrs,
381 : &out_map, &new_size);
382 1 : fail_unless(ret == EOK, "[%s]", sss_strerror(ret));
383 :
384 : /* Two extra and sentinel */
385 1 : fail_unless(new_size != SDAP_OPTS_USER + 3);
386 : /* Foo would be saved to sysdb verbatim */
387 1 : ck_assert_str_eq(out_map[SDAP_OPTS_USER].name, "foo");
388 1 : ck_assert_str_eq(out_map[SDAP_OPTS_USER].sys_name, "foo");
389 : /* Bar would be saved to sysdb as baz */
390 1 : ck_assert_str_eq(out_map[SDAP_OPTS_USER+1].name, "bar");
391 1 : ck_assert_str_eq(out_map[SDAP_OPTS_USER+1].sys_name, "baz");
392 1 : fail_unless(out_map[SDAP_OPTS_USER+2].name == NULL);
393 :
394 1 : talloc_free(out_map);
395 : }
396 1 : END_TEST
397 :
398 1 : START_TEST(test_no_extra_opts)
399 : {
400 : errno_t ret;
401 : struct sdap_attr_map *in_map;
402 : struct sdap_attr_map *out_map;
403 : size_t new_size;
404 :
405 1 : ret = sdap_copy_map(global_talloc_context, rfc2307_user_map,
406 : SDAP_OPTS_USER, &in_map);
407 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
408 :
409 1 : ret = sdap_extend_map(global_talloc_context,
410 : in_map,
411 : SDAP_OPTS_USER,
412 : NULL,
413 : &out_map, &new_size);
414 1 : fail_unless(ret == EOK, "[%s]", sss_strerror(ret));
415 : /* Attributes and sentinel */
416 1 : fail_unless(new_size != SDAP_OPTS_USER + 1);
417 1 : fail_unless(out_map[SDAP_OPTS_USER].name == NULL);
418 :
419 1 : talloc_free(out_map);
420 : }
421 1 : END_TEST
422 :
423 1 : START_TEST(test_extra_opts_neg)
424 : {
425 : errno_t ret;
426 1 : char *extra_attrs[] = { discard_const(":foo"),
427 : discard_const("bar:"),
428 : NULL };
429 : struct sdap_attr_map *in_map;
430 : struct sdap_attr_map *out_map;
431 : size_t new_size;
432 :
433 1 : ret = sdap_copy_map(global_talloc_context, rfc2307_user_map,
434 : SDAP_OPTS_USER, &in_map);
435 1 : fail_unless(ret == EOK, "[%s]", sss_strerror(ret));
436 :
437 1 : ret = sdap_extend_map(global_talloc_context,
438 : in_map,
439 : SDAP_OPTS_USER,
440 : extra_attrs,
441 : &out_map, &new_size);
442 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
443 : /* The faulty attributes would be just skipped */
444 1 : fail_unless(new_size != SDAP_OPTS_USER + 1);
445 1 : fail_unless(out_map[SDAP_OPTS_USER].name == NULL);
446 :
447 1 : talloc_free(out_map);
448 : }
449 1 : END_TEST
450 :
451 1 : START_TEST(test_extra_opts_dup)
452 : {
453 : errno_t ret;
454 1 : char *extra_attrs[] = { discard_const("name:foo"),
455 : NULL };
456 : struct sdap_attr_map *in_map;
457 : struct sdap_attr_map *out_map;
458 : size_t new_size;
459 :
460 1 : ret = sdap_copy_map(global_talloc_context, rfc2307_user_map,
461 : SDAP_OPTS_USER, &in_map);
462 1 : fail_unless(ret == EOK, "[%s]", strerror(ret));
463 :
464 1 : ret = sdap_extend_map(global_talloc_context,
465 : in_map,
466 : SDAP_OPTS_USER,
467 : extra_attrs,
468 : &out_map, &new_size);
469 1 : fail_unless(ret == ERR_DUP_EXTRA_ATTR, "[%s]", sss_strerror(ret));
470 : }
471 1 : END_TEST
472 :
473 1 : Suite *ipa_ldap_opt_suite (void)
474 : {
475 1 : Suite *s = suite_create ("ipa_ldap_opt");
476 :
477 1 : TCase *tc_ipa_ldap_opt = tcase_create ("ipa_ldap_opt");
478 :
479 1 : tcase_add_test (tc_ipa_ldap_opt, test_compare_opts);
480 1 : tcase_add_test (tc_ipa_ldap_opt, test_compare_sdap_attrs);
481 1 : tcase_add_test (tc_ipa_ldap_opt, test_compare_2307_with_2307bis);
482 1 : tcase_add_test (tc_ipa_ldap_opt, test_dp_opt_sentinel);
483 1 : tcase_add_test (tc_ipa_ldap_opt, test_sdap_opt_sentinel);
484 1 : suite_add_tcase (s, tc_ipa_ldap_opt);
485 :
486 1 : TCase *tc_ipa_utils = tcase_create ("ipa_utils");
487 1 : tcase_add_test (tc_ipa_utils, test_domain_to_basedn);
488 1 : suite_add_tcase (s, tc_ipa_utils);
489 :
490 1 : TCase *tc_dp_opts = tcase_create ("dp_opts");
491 1 : tcase_add_test (tc_dp_opts, test_copy_opts);
492 1 : suite_add_tcase (s, tc_dp_opts);
493 :
494 1 : TCase *tc_sdap_opts = tcase_create ("sdap_opts");
495 1 : tcase_add_test (tc_sdap_opts, test_copy_sdap_map);
496 1 : suite_add_tcase (s, tc_sdap_opts);
497 :
498 1 : TCase *tc_extra_opts = tcase_create ("extra_opts");
499 1 : tcase_add_test (tc_extra_opts, test_extra_opts);
500 1 : tcase_add_test (tc_extra_opts, test_no_extra_opts);
501 1 : tcase_add_test (tc_extra_opts, test_extra_opts_neg);
502 1 : tcase_add_test (tc_extra_opts, test_extra_opts_dup);
503 1 : suite_add_tcase (s, tc_extra_opts);
504 :
505 1 : return s;
506 : }
507 :
508 1 : int main(void)
509 : {
510 : int number_failed;
511 :
512 1 : tests_set_cwd();
513 :
514 1 : Suite *s = ipa_ldap_opt_suite ();
515 1 : SRunner *sr = srunner_create (s);
516 : /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
517 1 : srunner_run_all(sr, CK_ENV);
518 1 : number_failed = srunner_ntests_failed (sr);
519 1 : srunner_free (sr);
520 1 : return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
521 : }
|