From 78bc44b944c9fc861229d991220681f3d3560d8e Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 14 Jan 2013 13:37:05 +0100 Subject: tests: adda a unit test for test_sysdb_search_groups --- src/tests/sysdb-tests.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/tests') diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index e6d14d098..f847359c7 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -992,6 +992,32 @@ done: } END_TEST +START_TEST (test_sysdb_search_groups) +{ + struct sysdb_test_ctx *test_ctx; + int ret; + const char *attrs[] = { SYSDB_NAME, NULL }; + char *filter; + size_t count; + struct ldb_message **msgs; + + /* Setup */ + ret = setup_sysdb_tests(&test_ctx); + fail_if(ret != EOK, "Could not set up the test"); + + filter = talloc_asprintf(test_ctx, "("SYSDB_GIDNUM"=%d)", _i); + fail_if(filter == NULL, "OOM"); + + ret = sysdb_search_groups(test_ctx, test_ctx->sysdb, test_ctx->domain, + filter, attrs, &count, &msgs); + talloc_free(filter); + fail_if(ret != EOK, "Search failed: %d", ret); + fail_if(count != 1, "Did not find the expected group\n"); + + talloc_free(test_ctx); +} +END_TEST + START_TEST (test_sysdb_getpwuid) { struct sysdb_test_ctx *test_ctx; @@ -4832,6 +4858,9 @@ Suite *create_sysdb_suite(void) /* Verify the groups can be queried by GID */ tcase_add_loop_test(tc_sysdb, test_sysdb_getgrgid, 28010, 28020); + /* Find the users by GID using a filter */ + tcase_add_loop_test(tc_sysdb, test_sysdb_search_groups, 28010, 28020); + /* Enumerate the groups */ tcase_add_test(tc_sysdb, test_sysdb_enumgrent); -- cgit