f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose Sumit Bose <sbose@redhat.com>
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose Copyright (C) 2017 Red Hat
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose SSSD tests - sdap certmap
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose This program is free software; you can redistribute it and/or modify
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose it under the terms of the GNU General Public License as published by
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose the Free Software Foundation; either version 3 of the License, or
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose (at your option) any later version.
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose This program is distributed in the hope that it will be useful,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose GNU General Public License for more details.
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose You should have received a copy of the GNU General Public License
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bosestruct certmap_info map_a = { discard_const("map_a"), 11,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bosestruct certmap_info map_b = { discard_const("map_b"), UINT_MAX,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bosestruct certmap_info *certmap[] = { &map_a, &map_b, NULL };
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose test_ctx->tctx = create_dom_test_ctx(test_ctx, TESTS_PATH,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose ret = sysdb_update_certmap(test_ctx->tctx->sysdb, certmap, false);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose test_ctx->id_ctx = talloc_zero(test_ctx->tctx, struct sdap_id_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose test_ctx->id_ctx->opts = talloc_zero(test_ctx->tctx, struct sdap_options);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose test_ctx->id_ctx->be = talloc_zero(test_ctx->tctx, struct be_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose test_ctx->id_ctx->be->domain = test_ctx->tctx->dom;
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose talloc_get_type(*state, struct certmap_test_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose struct certmap_test_ctx *test_ctx = talloc_get_type(*state,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose ret = sdap_init_certmap(test_ctx, test_ctx->id_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose talloc_free(test_ctx->id_ctx->opts->sdap_certmap_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bosestatic void test_sdap_get_sss_certmap(void **state)
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose struct certmap_test_ctx *test_ctx = talloc_get_type(*state,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose ret = sdap_init_certmap(test_ctx, test_ctx->id_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose talloc_free(test_ctx->id_ctx->opts->sdap_certmap_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bosestatic void test_sdap_certmap_init_twice(void **state)
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose struct certmap_test_ctx *test_ctx = talloc_get_type(*state,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose ret = sdap_init_certmap(test_ctx, test_ctx->id_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose sdap_certmap_ref = test_ctx->id_ctx->opts->sdap_certmap_ctx;
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose sss_certmap_ref = sdap_get_sss_certmap(sdap_certmap_ref);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose ret = sdap_init_certmap(test_ctx, test_ctx->id_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose talloc_free(test_ctx->id_ctx->opts->sdap_certmap_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose struct certmap_test_ctx *test_ctx = talloc_get_type(*state,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose ret = sdap_init_certmap(test_ctx, test_ctx->id_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose sdap_certmap_ref = test_ctx->id_ctx->opts->sdap_certmap_ctx;
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose sss_certmap_ref = sdap_get_sss_certmap(sdap_certmap_ref);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose assert_ptr_equal(sss_certmap_ref, sdap_get_sss_certmap(sdap_certmap_ref));
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose assert_ptr_equal(sss_certmap_ref, sdap_get_sss_certmap(sdap_certmap_ref));
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose ret = sdap_setup_certmap(sdap_certmap_ref, certmap);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose talloc_free(test_ctx->id_ctx->opts->sdap_certmap_ctx);
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose cmocka_unit_test_setup_teardown(test_sdap_certmap_init,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose cmocka_unit_test_setup_teardown(test_sdap_get_sss_certmap,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose cmocka_unit_test_setup_teardown(test_sdap_certmap_init_twice,
f2e70ec742cd7aab82b74d7e4b424ba3258da7aaSumit Bose cmocka_unit_test_setup_teardown(test_sdap_setup_certmap,
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */