[SSSD] [PATCH] cache_req: support UPN
Petr Cech
pcech at redhat.com
Thu Sep 17 08:32:34 UTC 2015
Hi Pavel!
There is some code between my last end and this continuation. I was read
it and did't find anything wrong.
On 09/16/2015 04:26 PM, Petr Cech wrote:
> 0003-cache_req-tests-reduce-code-duplication.patch
>
>
> From e41f96a47f2b0f8d3e07e34af83e9a516d29df34 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Pavel=20B=C5=99ezina?=<pbrezina at redhat.com>
> Date: Mon, 14 Sep 2015 11:06:45 +0200
> Subject: [PATCH 3/3] cache_req tests: reduce code duplication
>
> ---
> src/tests/cmocka/test_responder_cache_req.c | 1624
> +++++++--------------------
> 1 file changed, 394 insertions(+), 1230 deletions(-)
>
> diff --git a/src/tests/cmocka/test_responder_cache_req.c
> b/src/tests/cmocka/test_responder_cache_req.c
> index
> 7db87ccc816ea0e30e707ec8c2fa4666441892a8..2af481494319d0d01d29d0c243020c5adcb06d3a
> 100644
> --- a/src/tests/cmocka/test_responder_cache_req.c
> +++ b/src/tests/cmocka/test_responder_cache_req.c
> @@ -52,6 +52,27 @@
> test_multi_domain_setup, \
> test_multi_domain_teardown)
>
> +#define run_cache_req(ctx, send_fn, done_fn, dom, crp, lookup, expret)
> do { \
> + TALLOC_CTX
> *req_mem_ctx; \
> + struct tevent_req
> *req; \
> + errno_t
> ret; \
> +
> \
> + req_mem_ctx =
> talloc_new(global_talloc_context); \
> +
> check_leaks_push(req_mem_ctx); \
> +
> \
> + req = send_fn(req_mem_ctx, ctx->tctx->ev,
> ctx->rctx, \
> + ctx->ncache, 10,
> crp, \
> + (dom == NULL ? NULL : dom->name),
> lookup); \
> +
> assert_non_null(req); \
> + tevent_req_set_callback(req, done_fn,
> ctx); \
> +
> \
> + ret =
> test_ev_loop(ctx->tctx); \
> + assert_int_equal(ret,
> expret); \
> +
> assert_true(check_leaks_pop(req_mem_ctx)); \
> +
> \
> +
> talloc_free(req_mem_ctx); \
> +} while (0)
This definition should be a function. I found that you use it like
# return run_cache_req(...) but it doesn't provide value.
> +
> struct cache_req_test_ctx {
> struct sss_test_ctx *tctx;
> struct resp_ctx *rctx;
> @@ -80,46 +101,6 @@ struct cli_protocol_version
> *register_cli_protocol_version(void)
> return version;
> }
>
> -struct tevent_req *
> -__wrap_sss_dp_get_account_send(TALLOC_CTX *mem_ctx,
> - struct resp_ctx *rctx,
> - struct sss_domain_info *dom,
> - bool fast_reply,
> - enum sss_dp_acct_type type,
> - const char *opt_name,
> - uint32_t opt_id,
> - const char *extra)
> -{
> - struct sysdb_attrs *attrs = NULL;
> - struct cache_req_test_ctx *ctx = NULL;
> - errno_t ret;
> -
> - ctx = sss_mock_ptr_type(struct cache_req_test_ctx*);
> - ctx->dp_called = true;
> -
> - if (ctx->create_user) {
> - attrs = sysdb_new_attrs(ctx);
> - assert_non_null(attrs);
> -
> - ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, TEST_UPN);
> - assert_int_equal(ret, EOK);
> -
> - ret = sysdb_store_user(ctx->tctx->dom, TEST_USER_NAME, "pwd",
> - TEST_USER_ID, 1000, NULL, NULL, NULL,
> - "cn=test-user,dc=test", attrs, NULL,
> - 1000, time(NULL));
> - assert_int_equal(ret, EOK);
> - }
> -
> - if (ctx->create_group) {
> - ret = sysdb_store_group(ctx->tctx->dom, TEST_GROUP_NAME,
> - TEST_GROUP_ID, NULL, 1000, time(NULL));
> - assert_int_equal(ret, EOK);
> - }
> -
> - return test_req_succeed_send(mem_ctx, rctx->ev);
> -}
> -
> static void cache_req_user_by_name_test_done(struct tevent_req *req)
> {
> struct cache_req_test_ctx *ctx = NULL;
> @@ -176,6 +157,173 @@ static void cache_req_group_by_id_test_done(struct
> tevent_req *req)
> ctx->tctx->done = true;
> }
>
> +static void prepare_user(TALLOC_CTX *mem_ctx,
> + struct sss_domain_info *domain,
> + uint64_t timeout,
> + time_t time)
> +{
> + struct sysdb_attrs *attrs;
> + errno_t ret;
> +
> + attrs = sysdb_new_attrs(mem_ctx);
> + assert_non_null(attrs);
> +
> + ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, TEST_UPN);
> + assert_int_equal(ret, EOK);
> +
> + ret = sysdb_store_user(domain, TEST_USER_NAME, "pwd",
> + TEST_USER_ID, TEST_GROUP_ID, NULL, NULL, NULL,
> + "cn=test-user,dc=test", attrs, NULL,
> + timeout, time);
> + assert_int_equal(ret, EOK);
> +}
> +
> +static void run_user_by_name(struct cache_req_test_ctx *test_ctx,
> + struct sss_domain_info *domain,
> + int cache_refresh_percent,
> + errno_t exp_ret)
> +{
> + run_cache_req(test_ctx, cache_req_user_by_name_send,
> + cache_req_user_by_name_test_done, domain,
> + cache_refresh_percent, TEST_USER_NAME, exp_ret);
> +}
> +
> +static errno_t run_user_by_upn(struct cache_req_test_ctx *test_ctx,
> + struct sss_domain_info *domain,
> + int cache_refresh_percent,
> + errno_t exp_ret)
> +{
> + run_cache_req(test_ctx, cache_req_user_by_name_send,
> + cache_req_user_by_name_test_done, domain,
> + cache_refresh_percent, TEST_UPN, exp_ret);
> +}
This function returns errno_t but run_cache_req is
without return statement.
I tried with your patches
# make responder_cache_req-tests
and thre is a result:
src/tests/cmocka/test_responder_cache_req.c: In function ‘run_user_by_upn’:
src/tests/cmocka/test_responder_cache_req.c:199:1: warning: no return
statement in function returning non-void [-Wreturn-type]
}
^
src/tests/cmocka/test_responder_cache_req.c: In function ‘run_user_by_id’:
src/tests/cmocka/test_responder_cache_req.c:209:1: warning: no return
statement in function returning non-void [-Wreturn-type]
}
^
src/tests/cmocka/test_responder_cache_req.c: In function
‘run_group_by_name’:
src/tests/cmocka/test_responder_cache_req.c:261:1: warning: no return
statement in function returning non-void [-Wreturn-type]
}
^
src/tests/cmocka/test_responder_cache_req.c: In function ‘run_group_by_id’:
src/tests/cmocka/test_responder_cache_req.c:271:1: warning: no return
statement in function returning non-void [-Wreturn-type]
}
That's all for me. I didn't test the functionality. Please, ask someone
other who has skills with AD (and running instance of it) to test it.
Regards
Petr
More information about the sssd-devel
mailing list