From bdf422fde0fd6b40b3412bad3b200f8fd7ea8693 Mon Sep 17 00:00:00 2001 From: Petr Cech Date: Fri, 21 Aug 2015 16:44:37 +0200 Subject: TESTS: Removing part of responder_cache_req-tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you call cache_req_[user|group]_by_filter_send() it than later calls updated_[users|groups]_by_filter(), which adds filter that is called "recent". This filter causes that only [users|groups] added after the request started are returned. This patch removes tests which use cache_req_[user|group]_by_filter_send(), because the logic of those tests is corrupted. The tests create [users|groups] and after it, they call cache_req_[user|group]_by_filter_send(). So it is obvious that it is not in the right manner. Possible fix is rewrite the tests to create the entries in the callback. Works around: https://fedorahosted.org/sssd/ticket/2730 Reviewed-by: Michal Židek --- src/tests/cmocka/test_responder_cache_req.c | 211 ---------------------------- 1 file changed, 211 deletions(-) diff --git a/src/tests/cmocka/test_responder_cache_req.c b/src/tests/cmocka/test_responder_cache_req.c index 032fe429a..bc6e2dc8f 100644 --- a/src/tests/cmocka/test_responder_cache_req.c +++ b/src/tests/cmocka/test_responder_cache_req.c @@ -1710,54 +1710,6 @@ static void cache_req_user_by_filter_test_done(struct tevent_req *req) ctx->tctx->done = true; } -void test_users_by_filter_valid(void **state) -{ - struct cache_req_test_ctx *test_ctx = NULL; - TALLOC_CTX *req_mem_ctx = NULL; - struct tevent_req *req = NULL; - const char *ldbname = NULL; - errno_t ret; - - test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx); - test_ctx->create_user = true; - - ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME2, "pwd", 1001, 1001, - NULL, NULL, NULL, "cn="TEST_USER_NAME2",dc=test", NULL, - NULL, 1000, time(NULL)); - 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(); - - req = cache_req_user_by_filter_send(req_mem_ctx, test_ctx->tctx->ev, - test_ctx->rctx, - test_ctx->tctx->dom->name, - "test*"); - assert_non_null(req); - tevent_req_set_callback(req, cache_req_user_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); - - ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0], - SYSDB_NAME, NULL); - assert_non_null(ldbname); - assert_string_equal(ldbname, TEST_USER_NAME2); - - ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[1], - SYSDB_NAME, NULL); - assert_non_null(ldbname); - assert_string_equal(ldbname, TEST_USER_NAME); -} - void test_users_by_filter_filter_old(void **state) { struct cache_req_test_ctx *test_ctx = NULL; @@ -1831,63 +1783,6 @@ void test_users_by_filter_notfound(void **state) assert_true(check_leaks_pop(req_mem_ctx)); } -static void test_users_by_filter_multiple_domains_valid(void **state) -{ - struct cache_req_test_ctx *test_ctx = NULL; - struct sss_domain_info *domain = NULL; - TALLOC_CTX *req_mem_ctx = NULL; - struct tevent_req *req = NULL; - const char *ldbname = NULL; - errno_t ret; - - test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx); - - domain = find_domain_by_name(test_ctx->tctx->dom, - "responder_cache_req_test_d", true); - assert_non_null(domain); - - ret = sysdb_store_user(domain, TEST_USER_NAME, "pwd", 1000, 1000, - NULL, NULL, NULL, "cn="TEST_USER_NAME",dc=test", NULL, - NULL, 1000, time(NULL)); - assert_int_equal(ret, EOK); - - ret = sysdb_store_user(domain, TEST_USER_NAME2, "pwd", 1001, 1001, - NULL, NULL, NULL, "cn="TEST_USER_NAME2",dc=test", NULL, - NULL, 1000, time(NULL)); - 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(); - - req = cache_req_user_by_filter_send(req_mem_ctx, test_ctx->tctx->ev, - test_ctx->rctx, - domain->name, - "test*"); - assert_non_null(req); - tevent_req_set_callback(req, cache_req_user_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); - - ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0], - SYSDB_NAME, NULL); - assert_non_null(ldbname); - assert_string_equal(ldbname, TEST_USER_NAME2); - - ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[1], - SYSDB_NAME, NULL); - assert_non_null(ldbname); - assert_string_equal(ldbname, TEST_USER_NAME); -} - static void test_users_by_filter_multiple_domains_notfound(void **state) { struct cache_req_test_ctx *test_ctx = NULL; @@ -1934,53 +1829,6 @@ static void cache_req_group_by_filter_test_done(struct tevent_req *req) ctx->tctx->done = true; } -void test_groups_by_filter_valid(void **state) -{ - struct cache_req_test_ctx *test_ctx = NULL; - TALLOC_CTX *req_mem_ctx = NULL; - struct tevent_req *req = NULL; - const char *ldbname = NULL; - errno_t ret; - - test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx); - test_ctx->create_group = true; - - ret = sysdb_store_group(test_ctx->tctx->dom, TEST_GROUP_NAME2, - 1001, NULL, 1001, time(NULL)); - 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(); - - req = cache_req_group_by_filter_send(req_mem_ctx, test_ctx->tctx->ev, - test_ctx->rctx, - test_ctx->tctx->dom->name, - "test*"); - 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); - - ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0], - SYSDB_NAME, NULL); - assert_non_null(ldbname); - assert_string_equal(ldbname, TEST_GROUP_NAME2); - - ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[1], - SYSDB_NAME, NULL); - assert_non_null(ldbname); - assert_string_equal(ldbname, TEST_GROUP_NAME); -} - void test_groups_by_filter_notfound(void **state) { struct cache_req_test_ctx *test_ctx = NULL; @@ -2009,61 +1857,6 @@ void test_groups_by_filter_notfound(void **state) assert_true(check_leaks_pop(req_mem_ctx)); } -void test_groups_by_filter_multiple_domains_valid(void **state) -{ - struct cache_req_test_ctx *test_ctx = NULL; - struct sss_domain_info *domain = NULL; - TALLOC_CTX *req_mem_ctx = NULL; - struct tevent_req *req = NULL; - const char *ldbname = NULL; - errno_t ret; - - test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx); - - domain = find_domain_by_name(test_ctx->tctx->dom, - "responder_cache_req_test_d", true); - assert_non_null(domain); - - ret = sysdb_store_group(domain, TEST_GROUP_NAME, - 1000, NULL, 1000, time(NULL)); - assert_int_equal(ret, EOK); - - ret = sysdb_store_group(domain, TEST_GROUP_NAME2, - 1001, NULL, 1001, time(NULL)); - 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(); - - req = cache_req_group_by_filter_send(req_mem_ctx, test_ctx->tctx->ev, - test_ctx->rctx, - domain->name, - "test*"); - 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); - - ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0], - SYSDB_NAME, NULL); - assert_non_null(ldbname); - assert_string_equal(ldbname, TEST_GROUP_NAME2); - - ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[1], - SYSDB_NAME, NULL); - assert_non_null(ldbname); - assert_string_equal(ldbname, TEST_GROUP_NAME); -} - void test_groups_by_filter_multiple_domains_notfound(void **state) { struct cache_req_test_ctx *test_ctx = NULL; @@ -2145,14 +1938,10 @@ int main(int argc, const char *argv[]) new_multi_domain_test(group_by_id_multiple_domains_found), new_multi_domain_test(group_by_id_multiple_domains_notfound), - new_single_domain_test(users_by_filter_valid), new_single_domain_test(users_by_filter_filter_old), new_single_domain_test(users_by_filter_notfound), - new_multi_domain_test(users_by_filter_multiple_domains_valid), new_multi_domain_test(users_by_filter_multiple_domains_notfound), - new_single_domain_test(groups_by_filter_valid), new_single_domain_test(groups_by_filter_notfound), - new_multi_domain_test(groups_by_filter_multiple_domains_valid), new_multi_domain_test(groups_by_filter_multiple_domains_notfound), }; -- cgit