b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina Pavel Březina <pbrezina@redhat.com>
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina Copyright (C) 2015 Red Hat
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina This program is free software; you can redistribute it and/or modify
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina it under the terms of the GNU General Public License as published by
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina the Free Software Foundation; either version 3 of the License, or
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina (at your option) any later version.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina This program is distributed in the hope that it will be useful,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina GNU General Public License for more details.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina You should have received a copy of the GNU General Public License
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina test_ctx = talloc_zero(NULL, struct ipa_dn_test_ctx);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina /* initialize domain */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina test_ctx->tctx = create_dom_test_ctx(test_ctx, TESTS_PATH, TEST_CONF_DB,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina test_ctx = talloc_get_type_abort(*state, struct ipa_dn_test_ctx);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_check_rdn(test_ctx->sysdb, "cn=rdn,dc=example,dc=com", "cn");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_check_rdn(test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", "cn", "attr1", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_check_rdn(test_ctx->sysdb, "cn=rdn,attr1=value1,attr2=value2,dc=example,dc=com", "cn", "attr1", "value1", "attr2", "value2");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_check_rdn(test_ctx->sysdb, "cn=rdn,dc=example,dc=com", "nope");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_check_rdn(test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", "cn", "nope", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_check_rdn(test_ctx->sysdb, "cn=rdn,attr1=value1,attr2=value2,dc=example,dc=com", "cn", "attr1", "nope");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_check_rdn(test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", "cn", "attr1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_check_rdn(test_ctx->sysdb, "cn=rdn,attr1=value1", "cn", "attr1", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic void ipa_check_rdn_bool_test(void **state)
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina test_ctx = talloc_get_type_abort(*state, struct ipa_dn_test_ctx);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina bret = ipa_check_rdn_bool(test_ctx->sysdb, "cn=rdn,dc=example,dc=com", "cn");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina bret = ipa_check_rdn_bool(test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", "cn", "attr1", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina bret = ipa_check_rdn_bool(test_ctx->sysdb, "cn=rdn,attr1=value1,attr2=value2,dc=example,dc=com", "cn", "attr1", "value1", "attr2", "value2");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina bret = ipa_check_rdn_bool(test_ctx->sysdb, "cn=rdn,dc=example,dc=com", "nope");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina bret = ipa_check_rdn_bool(test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", "cn", "nope", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina bret = ipa_check_rdn_bool(test_ctx->sysdb, "cn=rdn,attr1=value1,attr2=value2,dc=example,dc=com", "cn", "attr1", "nope");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina bret = ipa_check_rdn_bool(test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", "cn", "attr1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina bret = ipa_check_rdn_bool(test_ctx->sysdb, "cn=rdn,attr1=value1", "cn", "attr1", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina test_ctx = talloc_get_type_abort(*state, struct ipa_dn_test_ctx);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_get_rdn(test_ctx, test_ctx->sysdb, "cn=rdn,dc=example,dc=com", &rdn, "cn");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_get_rdn(test_ctx, test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", &rdn, "cn", "attr1", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_get_rdn(test_ctx, test_ctx->sysdb, "cn=rdn,attr1=value1,attr2=value2,dc=example,dc=com", &rdn, "cn", "attr1", "value1", "attr2", "value2");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_get_rdn(test_ctx, test_ctx->sysdb, "cn=rdn,dc=example,dc=com", &rdn, "nope");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_get_rdn(test_ctx, test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", &rdn, "cn", "nope", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_get_rdn(test_ctx, test_ctx->sysdb, "cn=rdn,attr1=value1,attr2=value2,dc=example,dc=com", &rdn, "cn", "attr1", "nope");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_get_rdn(test_ctx, test_ctx->sysdb, "cn=rdn,attr1=value1,dc=example,dc=com", &rdn, "cn", "attr1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = ipa_get_rdn(test_ctx, test_ctx->sysdb, "cn=rdn,attr1=value1", &rdn, "cn", "attr1", "value1");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina {"no-cleanup", 'n', POPT_ARG_NONE, &no_cleanup, 0,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina _("Do not delete the test database after a test run"), NULL },
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina cmocka_unit_test_setup_teardown(ipa_check_rdn_test,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina cmocka_unit_test_setup_teardown(ipa_check_rdn_bool_test,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina cmocka_unit_test_setup_teardown(ipa_get_rdn_test,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina /* Set debug level to invalid value so we can deside if -d 0 was used. */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina pc = poptGetContext(argv[0], argc, argv, long_options, 0);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, "\nInvalid option %s: %s\n\n",
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina /* Even though normally the tests should clean up after themselves
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * they might not after a failed run. Remove the old db to be sure */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina rv = cmocka_run_group_tests(tests, NULL, NULL);