summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-01-14 13:37:05 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-01-15 14:47:40 +0100
commit78bc44b944c9fc861229d991220681f3d3560d8e (patch)
treef1d8cda9be3b80a824914904cd0ec96304df2f5d /src/tests
parent25d978f2c4eea0c869da8d844996601281f0a7d4 (diff)
downloadsssd-78bc44b944c9fc861229d991220681f3d3560d8e.tar.gz
sssd-78bc44b944c9fc861229d991220681f3d3560d8e.tar.xz
sssd-78bc44b944c9fc861229d991220681f3d3560d8e.zip
tests: adda a unit test for test_sysdb_search_groups
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/sysdb-tests.c29
1 files changed, 29 insertions, 0 deletions
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);