test_responder_cache_req.c revision da79bee1472a06b89be2df903fb0bd8ce600c610
af84459fbf938e508fd10b01cb8d699c79083813takashi Pavel Březina <pbrezina@redhat.com>
af84459fbf938e508fd10b01cb8d699c79083813takashi Copyright (C) 2014 Red Hat
af84459fbf938e508fd10b01cb8d699c79083813takashi This program is free software; you can redistribute it and/or modify
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen it under the terms of the GNU General Public License as published by
af84459fbf938e508fd10b01cb8d699c79083813takashi the Free Software Foundation; either version 3 of the License, or
af84459fbf938e508fd10b01cb8d699c79083813takashi (at your option) any later version.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen This program is distributed in the hope that it will be useful,
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen but WITHOUT ANY WARRANTY; without even the implied warranty of
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
af84459fbf938e508fd10b01cb8d699c79083813takashi GNU General Public License for more details.
af84459fbf938e508fd10b01cb8d699c79083813takashi You should have received a copy of the GNU General Public License
3f08db06526d6901aa08c110b5bc7dde6bc39905nd along with this program. If not, see <http://www.gnu.org/licenses/>.
af84459fbf938e508fd10b01cb8d699c79083813takashi#define TEST_CONF_DB "test_responder_cache_req_conf.ldb"
af84459fbf938e508fd10b01cb8d699c79083813takashi#define run_cache_req(ctx, send_fn, done_fn, dom, crp, lookup, expret) do { \
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen req = send_fn(req_mem_ctx, ctx->tctx->ev, ctx->rctx, \
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe "responder_cache_req_test_b",
4bebf996eb7002ebfe897d46a0e0572390604a77nd "responder_cache_req_test_c",
4bebf996eb7002ebfe897d46a0e0572390604a77nd "responder_cache_req_test_d",
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowestruct cli_protocol_version *register_cli_protocol_version(void)
af84459fbf938e508fd10b01cb8d699c79083813takashistatic void cache_req_user_by_name_test_done(struct tevent_req *req)
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ctx->tctx->error = cache_req_user_by_name_recv(ctx, req,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowestatic void cache_req_user_by_id_test_done(struct tevent_req *req)
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ctx->tctx->error = cache_req_user_by_id_recv(ctx, req,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowestatic void cache_req_group_by_name_test_done(struct tevent_req *req)
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ctx->tctx->error = cache_req_group_by_name_recv(ctx, req,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowestatic void cache_req_group_by_id_test_done(struct tevent_req *req)
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ctx->tctx->error = cache_req_group_by_id_recv(ctx, req,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, TEST_UPN);
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowestatic void run_user_by_name(struct cache_req_test_ctx *test_ctx,
b7f8d802ecaed65eada1fc31472d06d8460d5528igalicstatic void run_user_by_upn(struct cache_req_test_ctx *test_ctx,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowestatic void run_user_by_id(struct cache_req_test_ctx *test_ctx,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowestatic void check_user(struct cache_req_test_ctx *test_ctx,
8559a67073808d84d85bb5dd552d4247caafe709sf const char *ldbname;
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe const char *ldbupn;
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0],
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ldbupn = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0],
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ldbuid = ldb_msg_find_attr_as_uint(test_ctx->result->msgs[0],
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe assert_string_equal(exp_dom->name, test_ctx->domain->name);
8559a67073808d84d85bb5dd552d4247caafe709sf ret = sysdb_store_group(domain, TEST_GROUP_NAME, TEST_GROUP_ID, NULL,
8559a67073808d84d85bb5dd552d4247caafe709sfstatic void run_group_by_name(struct cache_req_test_ctx *test_ctx,
8559a67073808d84d85bb5dd552d4247caafe709sfstatic void run_group_by_id(struct cache_req_test_ctx *test_ctx,
8559a67073808d84d85bb5dd552d4247caafe709sfstatic void check_group(struct cache_req_test_ctx *test_ctx,
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf const char *ldbname;
4bebf996eb7002ebfe897d46a0e0572390604a77nd ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0],
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe ldbgid = ldb_msg_find_attr_as_uint(test_ctx->result->msgs[0],
af84459fbf938e508fd10b01cb8d699c79083813takashi assert_string_equal(exp_dom->name, test_ctx->domain->name);
9534272616b71aaea50aeec4162e749a96aebd7fsf const char *opt_name,
7159c12b7697fe9f5ab3a533cc6dfc3d57803053igalic const char *extra)
1d45c1463a8bc69bab1c07a4729269ec7333e713rbowen ret = sysdb_store_group(ctx->tctx->dom, TEST_GROUP_NAME,
af84459fbf938e508fd10b01cb8d699c79083813takashi test_ctx = talloc_zero(NULL, struct cache_req_test_ctx);
af84459fbf938e508fd10b01cb8d699c79083813takashi test_ctx->tctx = create_dom_test_ctx(test_ctx, TESTS_PATH, TEST_CONF_DB,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe test_ctx->rctx = mock_rctx(test_ctx, test_ctx->tctx->ev,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
c8c717fafa0a09ed13469a603a178921b851dd22igalic test_ctx = talloc_zero(NULL, struct cache_req_test_ctx);
7e9c796f2dc0dba993a817b3a58cfd56b4e511edwrowe test_ctx->tctx = create_multidom_test_ctx(test_ctx, TESTS_PATH,
c8c717fafa0a09ed13469a603a178921b851dd22igalic test_ctx->rctx = mock_rctx(test_ctx, test_ctx->tctx->ev,
cd34a6fbf0a2619544a72eadb73f309370bf6682wrowe test_multidom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, domains);
af84459fbf938e508fd10b01cb8d699c79083813takashivoid test_user_by_name_multiple_domains_found(void **state)
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd /* Setup user. */
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd "responder_cache_req_test_d", true);
int opt;
switch(opt) {