summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPetr Cech <pcech@redhat.com>2015-11-01 07:45:56 -0500
committerJakub Hrozek <jhrozek@redhat.com>2015-11-14 13:08:18 +0100
commit16212bbb2aaa55d0587515e72c0018479ae51be9 (patch)
tree12cc932dfc088af4562278ed5cf07c985ffc3837 /src
parent5928fcbb57b92bfd18ad15aaaf4a5e1ab8dabe61 (diff)
downloadsssd-16212bbb2aaa55d0587515e72c0018479ae51be9.tar.gz
sssd-16212bbb2aaa55d0587515e72c0018479ae51be9.tar.xz
sssd-16212bbb2aaa55d0587515e72c0018479ae51be9.zip
TEST: Add test_groups_by_recent_filter_valid
Test groups_by_filter_valid() was removed in past. We will add two new tests instead of it. Logic of those tests is connected to RECENT filter. It returns only records which have been wrote or updated after filter was created (or another given time). groups_by_filter_valid() --> group_by_recent_filter_valid() grous_by_recent_filter_valid() The first of new tests, group_by_recent_filter_valid(), counts with two groups. One is stored before filter request creation and the second group is stored after filter request creation. So filter returns only one group. The second of new tests, groups_by_recent_filter_valid(), counts with three users. One is stored before filter request creation and two groups are stored after filter request creation. So filter returns two groups. This patch adds groups_by_recent_filter_valid(). Resolves: https://fedorahosted.org/sssd/ticket/2730 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/tests/cmocka/test_responder_cache_req.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/tests/cmocka/test_responder_cache_req.c b/src/tests/cmocka/test_responder_cache_req.c
index fa6c8fca3..842f94a72 100644
--- a/src/tests/cmocka/test_responder_cache_req.c
+++ b/src/tests/cmocka/test_responder_cache_req.c
@@ -1552,6 +1552,71 @@ void test_group_by_recent_filter_valid(void **state)
assert_string_equal(ldbname, TEST_GROUP_NAME);
}
+void test_groups_by_recent_filter_valid(void **state)
+{
+ struct cache_req_test_ctx *test_ctx = NULL;
+ TALLOC_CTX *req_mem_ctx = NULL;
+ TALLOC_CTX *tmp_ctx = NULL;
+ struct tevent_req *req = NULL;
+ const char **group_names = NULL;
+ const char **ldb_results = NULL;
+ const char *ldbname = NULL;
+ errno_t ret;
+
+ test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
+ test_ctx->create_group1 = true;
+ test_ctx->create_group2 = true;
+
+ ret = sysdb_store_group(test_ctx->tctx->dom, TEST_GROUP_NAME2,
+ 1001, NULL, 1001, time(NULL)-1);
+ assert_int_equal(ret, EOK);
+
+ req_mem_ctx = talloc_new(global_talloc_context);
+ check_leaks_push(req_mem_ctx);
+
+ /* Filters always go to DP */
+ will_return(__wrap_sss_dp_get_account_send, test_ctx);
+ mock_account_recv_simple();
+
+ /* Group TEST_GROUP1 and TEST_GROUP2 are created with a DP callback. */
+ req = cache_req_group_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
+ test_ctx->rctx,
+ test_ctx->tctx->dom->name,
+ TEST_USER_PREFIX);
+ assert_non_null(req);
+
+ tevent_req_set_callback(req, cache_req_group_by_filter_test_done, test_ctx);
+
+ ret = test_ev_loop(test_ctx->tctx);
+ assert_int_equal(ret, ERR_OK);
+ assert_true(check_leaks_pop(req_mem_ctx));
+
+ assert_non_null(test_ctx->result);
+ assert_int_equal(test_ctx->result->count, 2);
+
+ tmp_ctx = talloc_new(req_mem_ctx);
+
+ group_names = talloc_array(tmp_ctx, const char *, 2);
+ assert_non_null(group_names);
+ group_names[0] = TEST_GROUP_NAME;
+ group_names[1] = TEST_GROUP_NAME2;
+
+ ldb_results = talloc_array(tmp_ctx, const char *, 2);
+ assert_non_null(ldb_results);
+ for (int i = 0; i < 2; ++i) {
+ ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[i],
+ SYSDB_NAME, NULL);
+ assert_non_null(ldbname);
+ ldb_results[i] = ldbname;
+ }
+
+ assert_string_not_equal(ldb_results[0], ldb_results[1]);
+
+ assert_true(tc_are_values_in_array(group_names, ldb_results));
+
+ talloc_zfree(tmp_ctx);
+}
+
void test_groups_by_filter_notfound(void **state)
{
struct cache_req_test_ctx *test_ctx = NULL;
@@ -1673,6 +1738,7 @@ int main(int argc, const char *argv[])
new_single_domain_test(user_by_recent_filter_valid),
new_single_domain_test(users_by_recent_filter_valid),
new_single_domain_test(group_by_recent_filter_valid),
+ new_single_domain_test(groups_by_recent_filter_valid),
new_single_domain_test(users_by_filter_filter_old),
new_single_domain_test(users_by_filter_notfound),