summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cwrap/Makefile.am33
-rwxr-xr-xsrc/tests/cwrap/cwrap_test_setup.sh2
-rw-r--r--src/tests/cwrap/group1
-rw-r--r--src/tests/cwrap/test_negcache.c675
4 files changed, 711 insertions, 0 deletions
diff --git a/src/tests/cwrap/Makefile.am b/src/tests/cwrap/Makefile.am
index 8f4d9f7ea..84d8df4b7 100644
--- a/src/tests/cwrap/Makefile.am
+++ b/src/tests/cwrap/Makefile.am
@@ -14,6 +14,7 @@ AM_CPPFLAGS = \
TESTS_ENVIRONMENT = \
CWRAP_TEST_SRCDIR=$(abs_srcdir) \
+ ABS_TOP_BUILDDIR=$(abs_top_builddir) \
. $(srcdir)/cwrap_test_setup.sh; \
$(AUX_TESTS_ENVIRONMENT) \
$(NULL)
@@ -35,6 +36,20 @@ SSSD_LIBS = \
$(OPENLDAP_LIBS) \
$(TDB_LIBS)
+SSSD_RESPONDER_OBJ = \
+ ../../../src/responder/common/negcache_files.c \
+ ../../../src/responder/common/negcache.c \
+ ../../../src/responder/common/responder_cmd.c \
+ ../../../src/responder/common/responder_common.c \
+ ../../../src/responder/common/responder_dp.c \
+ ../../../src/responder/common/responder_packet.c \
+ ../../../src/responder/common/responder_get_domains.c \
+ ../../../src/responder/common/responder_utils.c \
+ ../../../src/responder/common/responder_cache_req.c \
+ ../../../src/monitor/monitor_iface_generated.c \
+ ../../../src/providers/data_provider_iface_generated.c \
+ ../../../src/providers/data_provider_req.c
+
dist_noinst_DATA = \
group \
passwd \
@@ -49,6 +64,7 @@ check_PROGRAMS += \
server-tests \
usertools-tests \
responder_common-tests \
+ negcache-tests \
$(NULL)
endif # HAVE_UID_WRAPPER
endif # HAVE_NSS_WRAPPER
@@ -130,4 +146,21 @@ responder_common_tests_LDADD = \
$(abs_top_builddir)/libsss_test_common.la \
$(NULL)
+negcache_tests_SOURCES =\
+ $(SSSD_RESPONDER_OBJ) \
+ test_negcache.c \
+ $(NULL)
+negcache_tests_CFLAGS = \
+ $(AM_CFLAGS) \
+ -DBASE_FILE_STEM=\"$(*F)\" \
+ $(NULL)
+negcache_tests_LDADD = \
+ $(CMOCKA_LIBS) \
+ $(SSSD_LIBS) \
+ $(SELINUX_LIBS) \
+ $(abs_top_builddir)/libsss_util.la \
+ $(abs_top_builddir)/libsss_debug.la \
+ $(abs_top_builddir)/libsss_test_common.la \
+ $(NULL)
+
tests: $(check_PROGRAMS)
diff --git a/src/tests/cwrap/cwrap_test_setup.sh b/src/tests/cwrap/cwrap_test_setup.sh
index 0d35cb7e5..68d731d2d 100755
--- a/src/tests/cwrap/cwrap_test_setup.sh
+++ b/src/tests/cwrap/cwrap_test_setup.sh
@@ -15,3 +15,5 @@ export NSS_WRAPPER_PASSWD=$CWRAP_TEST_SRCDIR/passwd
export NSS_WRAPPER_GROUP=$CWRAP_TEST_SRCDIR/group
export UID_WRAPPER=1
export UID_WRAPPER_ROOT=1
+
+export LDB_MODULES_PATH=$ABS_TOP_BUILDDIR/ldb_mod_test_dir \ No newline at end of file
diff --git a/src/tests/cwrap/group b/src/tests/cwrap/group
index 61e428c41..d0cea659e 100644
--- a/src/tests/cwrap/group
+++ b/src/tests/cwrap/group
@@ -1 +1,2 @@
sssd:x:123:
+foogroup:x:10001:
diff --git a/src/tests/cwrap/test_negcache.c b/src/tests/cwrap/test_negcache.c
new file mode 100644
index 000000000..32a78ba7f
--- /dev/null
+++ b/src/tests/cwrap/test_negcache.c
@@ -0,0 +1,675 @@
+/*
+ Authors:
+ Petr Čech <pcech@redhat.com>
+
+ Copyright (C) 2016 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+#include <popt.h>
+
+#include "tests/common.h"
+#include "responder/common/negcache.h"
+#include "responder/common/negcache_files.h"
+#include "responder/common/responder.h"
+
+#define TIMEOUT 10000
+
+#define TESTS_PATH "tp_" BASE_FILE_STEM
+#define TEST_CONF_DB "test_sysdb_sudorules.ldb"
+#define TEST_DOM_NAME "test_domain.test"
+
+#define TEST_LOCAL_USER_NAME_1 "foobar"
+#define TEST_LOCAL_USER_NAME_2 "sssd"
+
+#define TEST_LOCAL_USER_UID_1 10001
+#define TEST_LOCAL_USER_UID_2 123
+
+#define TEST_LOCAL_GROUP_NAME_1 "foogroup"
+#define TEST_LOCAL_GROUP_NAME_2 "sssd"
+
+#define TEST_LOCAL_GID_1 10001
+#define TEST_LOCAL_GID_2 123
+
+struct test_user {
+ const char *name;
+ uid_t uid;
+ gid_t gid;
+} users[] = { { "test_user1", 1001, 50001 },
+ { "test_user2", 1002, 50002 } };
+
+static void create_users(struct sss_domain_info *domain)
+{
+ errno_t ret;
+
+ for (int i = 0; i < 2; i++) {
+ ret = sysdb_add_user(domain, users[i].name, users[i].uid, users[i].gid,
+ users[i].name, NULL, "/bin/bash", domain->name,
+ NULL, 30, time(NULL));
+ assert_int_equal(ret, EOK);
+ }
+}
+
+struct test_group {
+ const char *name;
+ gid_t gid;
+} groups[] = { { "test_group1", 50001 },
+ { "test_group2", 50002 } };
+
+struct ncache_test_ctx {
+ struct sss_test_ctx *tctx;
+ struct sss_nc_ctx *ncache;
+};
+
+static void create_groups(struct sss_domain_info *domain)
+{
+ errno_t ret;
+
+ for (int i = 0; i < 2; i++) {
+ ret = sysdb_add_group(domain, groups[i].name, groups[i].gid,
+ NULL, 30, time(NULL));
+ assert_int_equal(ret, EOK);
+ }
+}
+
+/* register_cli_protocol_version is required in test since it links with
+ * responder_common.c module
+ */
+struct cli_protocol_version *register_cli_protocol_version(void)
+{
+ static struct cli_protocol_version responder_test_cli_protocol_version[] = {
+ { 0, NULL, NULL }
+ };
+
+ return responder_test_cli_protocol_version;
+}
+
+static int test_ncache_setup(void **state)
+{
+ struct ncache_test_ctx *test_ctx;
+
+ assert_true(leak_check_setup());
+
+ test_ctx = talloc_zero(global_talloc_context, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ test_dom_suite_setup(TESTS_PATH);
+
+ test_ctx->tctx = create_dom_test_ctx(test_ctx, TESTS_PATH, TEST_CONF_DB,
+ TEST_DOM_NAME, "ipa", NULL);
+ assert_non_null(test_ctx->tctx);
+
+ create_groups(test_ctx->tctx->dom);
+ create_users(test_ctx->tctx->dom);
+
+ check_leaks_push(test_ctx);
+
+ *state = (void *)test_ctx;
+
+ return 0;
+}
+
+static int test_ncache_teardown(void **state)
+{
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+
+ test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
+
+ assert_true(check_leaks_pop(test_ctx));
+ talloc_zfree(test_ctx);
+ assert_true(leak_check_teardown());
+
+ return 0;
+}
+
+/* user utils */
+
+static void set_users(struct ncache_test_ctx *test_ctx)
+{
+ int ret;
+
+ ret = sss_ncache_set_user(test_ctx->ncache, false, test_ctx->tctx->dom,
+ users[0].name);
+ assert_int_equal(ret, EOK);
+
+ ret = sss_ncache_set_user(test_ctx->ncache, false, test_ctx->tctx->dom,
+ TEST_LOCAL_USER_NAME_1);
+ assert_int_equal(ret, EOK);
+}
+
+static void check_users(struct ncache_test_ctx *test_ctx,
+ int case_a, int case_b, int case_c, int case_d)
+{
+ int ret;
+
+ ret = sss_ncache_check_user(test_ctx->ncache, test_ctx->tctx->dom,
+ users[0].name);
+ assert_int_equal(ret, case_a);
+
+ ret = sss_ncache_check_user(test_ctx->ncache, test_ctx->tctx->dom,
+ users[1].name);
+ assert_int_equal(ret, case_b);
+
+ ret = sss_ncache_check_user(test_ctx->ncache, test_ctx->tctx->dom,
+ TEST_LOCAL_USER_NAME_1);
+ assert_int_equal(ret, case_c);
+
+ ret = sss_ncache_check_user(test_ctx->ncache, test_ctx->tctx->dom,
+ TEST_LOCAL_USER_NAME_2);
+ assert_int_equal(ret, case_d);
+}
+
+/* user tests */
+
+void test_ncache_nocache_user(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, 0, 0, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_users(test_ctx);
+
+ check_users(test_ctx, ENOENT, ENOENT, ENOENT, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_local_user(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, 0, TIMEOUT, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_users(test_ctx);
+
+ check_users(test_ctx, ENOENT, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_domain_user(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, TIMEOUT, 0, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_users(test_ctx);
+
+ check_users(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_both_user(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, TIMEOUT, TIMEOUT, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_users(test_ctx);
+
+ check_users(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+/* uid utils */
+
+static void set_uids(struct ncache_test_ctx *test_ctx)
+{
+ int ret;
+
+ ret = sss_ncache_set_uid(test_ctx->ncache, false, test_ctx->tctx->dom,
+ users[0].uid);
+ assert_int_equal(ret, EOK);
+
+ ret = sss_ncache_set_uid(test_ctx->ncache, false, test_ctx->tctx->dom,
+ TEST_LOCAL_USER_UID_1);
+ assert_int_equal(ret, EOK);
+}
+
+static void check_uids(struct ncache_test_ctx *test_ctx,
+ int case_a, int case_b, int case_c, int case_d)
+{
+ int ret;
+
+ ret = sss_ncache_check_uid(test_ctx->ncache, test_ctx->tctx->dom,
+ users[0].uid);
+ assert_int_equal(ret, case_a);
+
+ ret = sss_ncache_check_uid(test_ctx->ncache, test_ctx->tctx->dom,
+ users[1].uid);
+ assert_int_equal(ret, case_b);
+
+ ret = sss_ncache_check_uid(test_ctx->ncache, test_ctx->tctx->dom,
+ TEST_LOCAL_USER_UID_1);
+ assert_int_equal(ret, case_c);
+
+ ret = sss_ncache_check_uid(test_ctx->ncache, test_ctx->tctx->dom,
+ TEST_LOCAL_USER_UID_2);
+ assert_int_equal(ret, case_d);
+}
+
+/* uid tests */
+
+void test_ncache_nocache_uid(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, 0, 0, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_uids(test_ctx);
+
+ check_uids(test_ctx, ENOENT, ENOENT, ENOENT, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_local_uid(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, 0, TIMEOUT, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_uids(test_ctx);
+
+ check_uids(test_ctx, ENOENT, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_domain_uid(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, TIMEOUT, 0, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_uids(test_ctx);
+
+ check_uids(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_both_uid(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, TIMEOUT, TIMEOUT, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_uids(test_ctx);
+
+ check_uids(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+/* group utils */
+
+static void set_groups(struct ncache_test_ctx *test_ctx)
+{
+ int ret;
+
+ ret = sss_ncache_set_group(test_ctx->ncache, false, test_ctx->tctx->dom,
+ groups[0].name);
+ assert_int_equal(ret, EOK);
+
+ ret = sss_ncache_set_group(test_ctx->ncache, false, test_ctx->tctx->dom,
+ TEST_LOCAL_GROUP_NAME_1);
+ assert_int_equal(ret, EOK);
+}
+
+static void check_groups(struct ncache_test_ctx *test_ctx,
+ int case_a, int case_b, int case_c, int case_d)
+{
+ int ret;
+
+ ret = sss_ncache_check_group(test_ctx->ncache, test_ctx->tctx->dom,
+ groups[0].name);
+ assert_int_equal(ret, case_a);
+
+ ret = sss_ncache_check_group(test_ctx->ncache, test_ctx->tctx->dom,
+ groups[1].name);
+ assert_int_equal(ret, case_b);
+
+ ret = sss_ncache_check_group(test_ctx->ncache, test_ctx->tctx->dom,
+ TEST_LOCAL_GROUP_NAME_1);
+ assert_int_equal(ret, case_c);
+
+ ret = sss_ncache_check_group(test_ctx->ncache, test_ctx->tctx->dom,
+ TEST_LOCAL_GROUP_NAME_2);
+ assert_int_equal(ret, case_d);
+}
+
+/* group tests */
+
+void test_ncache_nocache_group(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, 0, 0, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_groups(test_ctx);
+
+ check_groups(test_ctx, ENOENT, ENOENT, ENOENT, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_local_group(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, 0, TIMEOUT, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_groups(test_ctx);
+
+ check_groups(test_ctx, ENOENT, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_domain_group(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, TIMEOUT, 0, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_groups(test_ctx);
+
+ check_groups(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_both_group(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, TIMEOUT, TIMEOUT, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_groups(test_ctx);
+
+ check_groups(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+/* gid utils */
+
+static void set_gids(struct ncache_test_ctx *test_ctx)
+{
+ int ret;
+
+ ret = sss_ncache_set_gid(test_ctx->ncache, false, test_ctx->tctx->dom,
+ users[0].gid);
+ assert_int_equal(ret, EOK);
+
+ ret = sss_ncache_set_gid(test_ctx->ncache, false, test_ctx->tctx->dom,
+ TEST_LOCAL_GID_1);
+ assert_int_equal(ret, EOK);
+}
+
+static void check_gids(struct ncache_test_ctx *test_ctx,
+ int case_a, int case_b, int case_c, int case_d)
+{
+ int ret;
+
+ ret = sss_ncache_check_gid(test_ctx->ncache, test_ctx->tctx->dom,
+ users[0].gid);
+ assert_int_equal(ret, case_a);
+
+ ret = sss_ncache_check_gid(test_ctx->ncache, test_ctx->tctx->dom,
+ users[1].gid);
+ assert_int_equal(ret, case_b);
+
+ ret = sss_ncache_check_gid(test_ctx->ncache, test_ctx->tctx->dom,
+ TEST_LOCAL_GID_1);
+ assert_int_equal(ret, case_c);
+
+ ret = sss_ncache_check_gid(test_ctx->ncache, test_ctx->tctx->dom,
+ TEST_LOCAL_GID_2);
+ assert_int_equal(ret, case_d);
+}
+
+/* uid tests */
+
+void test_ncache_nocache_gid(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, 0, 0, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_gids(test_ctx);
+
+ check_gids(test_ctx, ENOENT, ENOENT, ENOENT, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_local_gid(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, 0, TIMEOUT, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_gids(test_ctx);
+
+ check_gids(test_ctx, ENOENT, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_domain_gid(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, TIMEOUT, 0, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_gids(test_ctx);
+
+ check_gids(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+void test_ncache_both_gid(void **state)
+{
+ errno_t ret;
+ struct ncache_test_ctx *test_ctx;
+
+ test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx);
+ assert_non_null(test_ctx);
+
+ ret = sss_ncache_init(test_ctx, TIMEOUT, TIMEOUT, &test_ctx->ncache);
+ assert_int_equal(ret, EOK);
+
+ set_gids(test_ctx);
+
+ check_gids(test_ctx, EEXIST, ENOENT, EEXIST, ENOENT);
+
+ talloc_zfree(test_ctx->ncache);
+}
+
+int main(int argc, const char *argv[])
+{
+ int rv;
+ poptContext pc;
+ int opt;
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ SSSD_DEBUG_OPTS
+ POPT_TABLEEND
+ };
+
+ const struct CMUnitTest tests[] = {
+ /* user */
+ cmocka_unit_test_setup_teardown(test_ncache_nocache_user,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_local_user,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_domain_user,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_both_user,
+ test_ncache_setup,
+ test_ncache_teardown),
+ /* uid */
+ cmocka_unit_test_setup_teardown(test_ncache_nocache_uid,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_local_uid,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_domain_uid,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_both_uid,
+ test_ncache_setup,
+ test_ncache_teardown),
+ /* group */
+ cmocka_unit_test_setup_teardown(test_ncache_nocache_group,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_local_group,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_domain_group,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_both_group,
+ test_ncache_setup,
+ test_ncache_teardown),
+ /* gid */
+ cmocka_unit_test_setup_teardown(test_ncache_nocache_gid,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_local_gid,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_domain_gid,
+ test_ncache_setup,
+ test_ncache_teardown),
+ cmocka_unit_test_setup_teardown(test_ncache_both_gid,
+ test_ncache_setup,
+ test_ncache_teardown),
+ };
+
+ /* Set debug level to invalid value so we can deside if -d 0 was used. */
+ debug_level = SSSDBG_INVALID;
+
+ pc = poptGetContext(argv[0], argc, argv, long_options, 0);
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+ default:
+ fprintf(stderr, "\nInvalid option %s: %s\n\n",
+ poptBadOption(pc, 0), poptStrerror(opt));
+ poptPrintUsage(pc, stderr, 0);
+ return 1;
+ }
+ }
+ poptFreeContext(pc);
+
+ DEBUG_CLI_INIT(debug_level);
+
+ tests_set_cwd();
+ test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
+ rv = cmocka_run_group_tests(tests, NULL, NULL);
+
+ return rv;
+} \ No newline at end of file