e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech Petr Čech <pcech@redhat.com>
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech Copyright (C) 2016 Red Hat
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech SSSD tests: AD subdomain tests
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech This program is free software; you can redistribute it and/or modify
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech it under the terms of the GNU General Public License as published by
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech the Free Software Foundation; either version 3 of the License, or
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech (at your option) any later version.
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech This program is distributed in the hope that it will be useful,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech but WITHOUT ANY WARRANTY; without even the implied warranty of
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech GNU General Public License for more details.
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech You should have received a copy of the GNU General Public License
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech along with this program. If not, see <http://www.gnu.org/licenses/>.
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cechstatic struct ad_id_ctx *
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ad_id_ctx = talloc_zero(mem_ctx, struct ad_id_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ad_options = talloc_zero(ad_id_ctx, struct ad_options);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx = talloc_zero(global_talloc_context, struct test_ad_subdom_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx = talloc_get_type(*state, struct test_ad_subdom_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx = talloc_get_type(*state, struct test_ad_subdom_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx->ad_id_ctx = test_ad_subdom_init_ad_id_ctx(test_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = ad_get_enabled_domains(test_ctx, test_ctx->ad_id_ctx,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx = talloc_get_type(*state, struct test_ad_subdom_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx->ad_id_ctx = test_ad_subdom_init_ad_id_ctx(test_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = dp_opt_set_string(test_ctx->ad_id_ctx->ad_options->basic,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = ad_get_enabled_domains(test_ctx, test_ctx->ad_id_ctx,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ad_enabled_domains[enabled_domains_count] != NULL;
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech assert_int_equal(domain_count, enabled_domains_count);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech assert_true(are_values_in_array(domains, domain_count,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx = talloc_get_type(*state, struct test_ad_subdom_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx->ad_id_ctx = test_ad_subdom_init_ad_id_ctx(test_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = dp_opt_set_string(test_ctx->ad_id_ctx->ad_options->basic,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = ad_get_enabled_domains(test_ctx, test_ctx->ad_id_ctx,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ad_enabled_domains[enabled_domains_count] != NULL;
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech assert_int_equal(domain_count, enabled_domains_count);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech assert_true(are_values_in_array(domains, domain_count,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cechstatic void test_ad_subdom_add_master(void **state)
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx = talloc_get_type(*state, struct test_ad_subdom_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx->ad_id_ctx = test_ad_subdom_init_ad_id_ctx(test_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = dp_opt_set_string(test_ctx->ad_id_ctx->ad_options->basic,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = ad_get_enabled_domains(test_ctx, test_ctx->ad_id_ctx,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ad_enabled_domains[enabled_domains_count] != NULL;
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech assert_int_equal(domain_count, enabled_domains_count);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech assert_true(are_values_in_array(domains, domain_count,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cechstatic void test_ad_subdom_add_two_with_master(void **state)
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx = talloc_get_type(*state, struct test_ad_subdom_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech test_ctx->ad_id_ctx = test_ad_subdom_init_ad_id_ctx(test_ctx);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = dp_opt_set_string(test_ctx->ad_id_ctx->ad_options->basic,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ret = ad_get_enabled_domains(test_ctx, test_ctx->ad_id_ctx,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech ad_enabled_domains[enabled_domains_count] != NULL;
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech assert_int_equal(domain_count, enabled_domains_count);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech assert_true(are_values_in_array(domains, domain_count,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech cmocka_unit_test_setup_teardown(test_ad_subdom_default,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech cmocka_unit_test_setup_teardown(test_ad_subdom_add_one,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech cmocka_unit_test_setup_teardown(test_ad_subdom_add_two,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech cmocka_unit_test_setup_teardown(test_ad_subdom_add_master,
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech cmocka_unit_test_setup_teardown(test_ad_subdom_add_two_with_master,
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech pc = poptGetContext(argv[0], argc, argv, long_options, 0);
e4d18b748fd8298b5cc6b6687ca05ffffa20c574Petr Cech /* Even though normally the tests should clean up after themselves
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz * they might not after a failed run. Remove the old DB to be sure */