>From 44c19d3ea3bfde05d054c7c5d024419b2ee8d511 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 14 Jan 2013 13:37:05 +0100 Subject: [PATCH 2/3] tests: adda a unit test for test_sysdb_search_groups --- src/tests/sysdb-tests.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index 8d3b98aeecd0b2b9173ef5f22017d1f8a9c0927b..779a6c930f8b01609ad1f30c779226c2112c7ba6 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; @@ -4896,6 +4922,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); -- 1.8.0.2