summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-01-14 13:27:14 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-01-15 14:47:37 +0100
commit25d978f2c4eea0c869da8d844996601281f0a7d4 (patch)
tree89a6b450e2985be5f6a41a95db6503b13b78ab7e /src/tests
parenta294438ef32b2a453f8cc8933056f8969a7ca510 (diff)
downloadsssd-25d978f2c4eea0c869da8d844996601281f0a7d4.tar.gz
sssd-25d978f2c4eea0c869da8d844996601281f0a7d4.tar.bz2
sssd-25d978f2c4eea0c869da8d844996601281f0a7d4.zip
tests: unit test for test_sysdb_search_users
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/sysdb-tests.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 958018fd..e6d14d09 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -1132,6 +1132,34 @@ START_TEST (test_sysdb_set_user_attr)
}
END_TEST
+START_TEST (test_sysdb_search_users)
+{
+ 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_UIDNUM"=%d)("SYSDB_SHELL"=/bin/ksh))",
+ _i);
+ fail_if(filter == NULL, "OOM");
+
+ ret = sysdb_search_users(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 user\n");
+
+ talloc_free(test_ctx);
+}
+END_TEST
+
START_TEST (test_sysdb_get_user_attr)
{
struct sysdb_test_ctx *test_ctx;
@@ -4790,6 +4818,9 @@ Suite *create_sysdb_suite(void)
/* Change their attribute */
tcase_add_loop_test(tc_sysdb, test_sysdb_set_user_attr, 27010, 27020);
+ /* Find the users by their new attribute */
+ tcase_add_loop_test(tc_sysdb, test_sysdb_search_users, 27010, 27020);
+
/* Verify the change */
tcase_add_loop_test(tc_sysdb, test_sysdb_get_user_attr, 27010, 27020);