360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina Pavel Březina <pbrezina@redhat.com>
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina Copyright (C) 2014 Red Hat
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina This program is free software; you can redistribute it and/or modify
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina it under the terms of the GNU General Public License as published by
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina the Free Software Foundation; either version 3 of the License, or
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina (at your option) any later version.
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina This program is distributed in the hope that it will be useful,
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina GNU General Public License for more details.
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina You should have received a copy of the GNU General Public License
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
4169fb26ea2ff93c19ecdad6e09382732ea5deebPavel Březina#include "responder/common/cache_req/cache_req.h"
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina#define TEST_CONF_DB "test_responder_cache_req_conf.ldb"
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina#define TEST_DOM_NAME "responder_cache_req_test"
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina} users[] = {{"test-user1", "upn1@upndomain.com",
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina "S-1-5-21-3623811015-3361044348-30300820-1001", 1001, 1001},
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina "S-1-5-21-3623811015-3361044348-30300820-1002", 1002, 1002}};
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina} groups[] = {{"test-group1", "S-1-5-21-3623811015-3361044348-30300820-2001", 2001},
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina {"test-group2", "S-1-5-21-3623811015-3361044348-30300820-2002", 2002}};
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_ ## test, \
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_ ## test, \
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina#define run_cache_req(ctx, send_fn, done_fn, dom, crp, lookup, expret) do { \
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina req_mem_ctx = talloc_new(global_talloc_context); \
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina req = send_fn(req_mem_ctx, ctx->tctx->ev, ctx->rctx, \
5928fcbb57b92bfd18ad15aaaf4a5e1ab8dabe61Petr Cech /* NOTE: Please, instead of adding new create_[user|group] bool,
5928fcbb57b92bfd18ad15aaaf4a5e1ab8dabe61Petr Cech * use bitshift. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březinaconst char *domains[] = {"responder_cache_req_test_a",
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina "responder_cache_req_test_b",
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina "responder_cache_req_test_c",
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina "responder_cache_req_test_d",
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březinastruct cli_protocol_version *register_cli_protocol_version(void)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina static struct cli_protocol_version version[] = {
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březinastatic void cache_req_user_by_name_test_done(struct tevent_req *req)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina ctx->tctx->error = cache_req_user_by_name_recv(ctx, req,
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březinastatic void cache_req_user_by_id_test_done(struct tevent_req *req)
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina ctx->tctx->error = cache_req_user_by_id_recv(ctx, req,
641d684ee88c6540a4cf1d74d258614f615699fePavel Březinastatic void cache_req_group_by_name_test_done(struct tevent_req *req)
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina ctx->tctx->error = cache_req_group_by_name_recv(ctx, req,
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březinastatic void cache_req_group_by_id_test_done(struct tevent_req *req)
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina ctx->tctx->error = cache_req_group_by_id_recv(ctx, req,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinastatic void cache_req_object_by_sid_test_done(struct tevent_req *req)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina ctx->tctx->error = cache_req_object_by_sid_recv(ctx, req,
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březinastatic void prepare_user(struct sss_domain_info *domain,
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, user->upn);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, user->sid);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek fqname = sss_create_internal_fqname(attrs, user->short_name, domain->name);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březinastatic void run_user_by_name(struct cache_req_test_ctx *test_ctx,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_cache_req(test_ctx, cache_req_user_by_name_send,
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek cache_refresh_percent, users[0].short_name, exp_ret);
6c2e507bd1571f9c7e26c5c9d60753b29fb75578Jakub Hrozekstatic void run_user_by_upn(struct cache_req_test_ctx *test_ctx,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_cache_req(test_ctx, cache_req_user_by_name_send,
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina cache_refresh_percent, users[0].upn, exp_ret);
6c2e507bd1571f9c7e26c5c9d60753b29fb75578Jakub Hrozekstatic void run_user_by_id(struct cache_req_test_ctx *test_ctx,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_cache_req(test_ctx, cache_req_user_by_id_send,
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina cache_refresh_percent, users[0].uid, exp_ret);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozekstatic void assert_msg_has_shortname(struct cache_req_test_ctx *test_ctx,
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek ldbname = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek ret = sss_parse_internal_fqname(test_ctx, ldbname, &shortname, NULL);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březinastatic void check_user(struct cache_req_test_ctx *test_ctx,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina ldbupn = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0],
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina ldbsid = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0],
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina ldbuid = ldb_msg_find_attr_as_uint(test_ctx->result->msgs[0],
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina assert_string_equal(exp_dom->name, test_ctx->domain->name);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březinastatic void prepare_group(struct sss_domain_info *domain,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, group->sid);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek fqname = sss_create_internal_fqname(attrs, group->short_name, domain->name);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek ret = sysdb_store_group(domain, fqname, group->gid, attrs,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březinastatic void run_group_by_name(struct cache_req_test_ctx *test_ctx,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_cache_req(test_ctx, cache_req_group_by_name_send,
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek cache_refresh_percent, groups[0].short_name, exp_ret);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březinastatic void run_group_by_id(struct cache_req_test_ctx *test_ctx,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_cache_req(test_ctx, cache_req_group_by_id_send,
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina cache_refresh_percent, groups[0].gid, exp_ret);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březinastatic void check_group(struct cache_req_test_ctx *test_ctx,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina ldbsid = ldb_msg_find_attr_as_string(test_ctx->result->msgs[0],
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina ldbgid = ldb_msg_find_attr_as_uint(test_ctx->result->msgs[0],
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina assert_string_equal(exp_dom->name, test_ctx->domain->name);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinastatic void run_object_by_sid(struct cache_req_test_ctx *test_ctx,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina const char *sid,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina const char **attrs,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina req_mem_ctx = talloc_new(global_talloc_context);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina req = cache_req_object_by_sid_send(req_mem_ctx, test_ctx->tctx->ev,
beb07d2f45856d4f3135f173cce551a2aa878f57Petr Cech test_ctx->rctx, test_ctx->ncache, cache_refresh_percent,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina (domain == NULL ? NULL : domain->name), sid, attrs);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina tevent_req_set_callback(req, cache_req_object_by_sid_test_done, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina__wrap_sss_dp_get_account_send(TALLOC_CTX *mem_ctx,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina ctx = sss_mock_ptr_type(struct cache_req_test_ctx*);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(ctx->tctx->dom, &users[0], 1000, time(NULL));
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(ctx->tctx->dom, &users[1], 1000, time(NULL));
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(ctx->tctx->dom, &groups[0], 1000, time(NULL));
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(ctx->tctx->dom, &groups[1], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina return test_req_succeed_send(mem_ctx, rctx->ev);
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int test_single_domain_setup(void **state)
c19374b2a9b676ca534f52ef76d80f0945fe8fb2Pavel Březina test_ctx = talloc_zero(global_talloc_context, struct cache_req_test_ctx);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx->tctx = create_dom_test_ctx(test_ctx, TESTS_PATH, TEST_CONF_DB,
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx->rctx = mock_rctx(test_ctx, test_ctx->tctx->ev,
e7ccfb139388c947ec2dee16cfe3005f5643b90dPetr Cech ret = sss_ncache_init(test_ctx, 10, 0, &test_ctx->ncache);
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int test_single_domain_teardown(void **state)
c19374b2a9b676ca534f52ef76d80f0945fe8fb2Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int test_multi_domain_setup(void **state)
c19374b2a9b676ca534f52ef76d80f0945fe8fb2Pavel Březina test_ctx = talloc_zero(global_talloc_context, struct cache_req_test_ctx);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx->tctx = create_multidom_test_ctx(test_ctx, TESTS_PATH,
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx->rctx = mock_rctx(test_ctx, test_ctx->tctx->ev,
e7ccfb139388c947ec2dee16cfe3005f5643b90dPetr Cech ret = sss_ncache_init(test_ctx, 10, 0, &test_ctx->ncache);
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int test_multi_domain_teardown(void **state)
c19374b2a9b676ca534f52ef76d80f0945fe8fb2Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_multidom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, domains);
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březinavoid test_user_by_name_multiple_domains_found(void **state)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina "responder_cache_req_test_d", true);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(domain, &users[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina will_return_always(sss_dp_get_account_recv, 0);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek mock_parse_inp(users[0].short_name, NULL, ERR_OK);
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březinavoid test_user_by_name_multiple_domains_notfound(void **state)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina will_return_always(sss_dp_get_account_recv, 0);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek mock_parse_inp(users[0].short_name, NULL, ERR_OK);
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březinavoid test_user_by_name_multiple_domains_parse(void **state)
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Add user to the first domain with different uid then test user. */
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina "responder_cache_req_test_a", true);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek fqname = sss_create_internal_fqname(test_ctx, users[0].short_name, domain->name);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek ret = sysdb_store_user(domain, fqname, "pwd", 2000, 1000,
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina NULL, NULL, NULL, "cn=test-user,dc=test", NULL,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Add test user to the last domain. */
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina "responder_cache_req_test_d", true);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(domain, &users[0], 1000, time(NULL));
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek /* Append domain name to the username to form the qualified input.
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek * We don't use the internal fqname here on purpose, because this is
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek * the user's input.
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek input_fqn = talloc_asprintf(test_ctx, "%s@%s", users[0].short_name,
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek "responder_cache_req_test_d");
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek mock_parse_inp(users[0].short_name, "responder_cache_req_test_d", ERR_OK);
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina req_mem_ctx = talloc_new(global_talloc_context);
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina req = cache_req_user_by_name_send(req_mem_ctx, test_ctx->tctx->ev,
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina tevent_req_set_callback(req, cache_req_user_by_name_test_done, test_ctx);
d20a56f2f05a011e62ba921e70124583e3c5b652Jakub Hrozek assert_string_equal(input_fqn, test_ctx->name);
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březinavoid test_user_by_name_cache_valid(void **state)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_name(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březinavoid test_user_by_name_cache_expired(void **state)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], -1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina /* DP should be contacted */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_name(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březinavoid test_user_by_name_cache_midpoint(void **state)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], 50, time(NULL) - 26);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina /* DP should be contacted without callback */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_name(test_ctx, test_ctx->tctx->dom, 50, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek fqname = sss_create_internal_fqname(test_ctx, users[0].short_name,
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina ret = sss_ncache_set_user(test_ctx->ncache, false,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_name(test_ctx, test_ctx->tctx->dom, 0, ENOENT);
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březinavoid test_user_by_name_missing_found(void **state)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_name(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březinavoid test_user_by_name_missing_notfound(void **state)
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_name(test_ctx, test_ctx->tctx->dom, 0, ENOENT);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březinavoid test_user_by_upn_multiple_domains_found(void **state)
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina "responder_cache_req_test_d", true);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(domain, &users[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina will_return_always(sss_dp_get_account_recv, 0);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březinavoid test_user_by_upn_multiple_domains_notfound(void **state)
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina will_return_always(sss_dp_get_account_recv, 0);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březinavoid test_user_by_upn_cache_valid(void **state)
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březinavoid test_user_by_upn_cache_expired(void **state)
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], -1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina /* DP should be contacted */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březinavoid test_user_by_upn_cache_midpoint(void **state)
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], 50, time(NULL) - 26);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina /* DP should be contacted without callback */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina ret = sss_ncache_set_user(test_ctx->ncache, false,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březinavoid test_user_by_upn_missing_found(void **state)
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březinavoid test_user_by_upn_missing_notfound(void **state)
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březinavoid test_user_by_id_multiple_domains_found(void **state)
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina "responder_cache_req_test_d", true);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(domain, &users[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina will_return_always(sss_dp_get_account_recv, 0);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březinavoid test_user_by_id_multiple_domains_notfound(void **state)
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina will_return_always(sss_dp_get_account_recv, 0);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_id(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březinavoid test_user_by_id_cache_expired(void **state)
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], -1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* DP should be contacted. */
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_id(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březinavoid test_user_by_id_cache_midpoint(void **state)
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[0], 50, time(NULL) - 26);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina /* DP should be contacted without callback */
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_id(test_ctx, test_ctx->tctx->dom, 50, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup user. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina ret = sss_ncache_set_uid(test_ctx->ncache, false, NULL, users[0].uid);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_id(test_ctx, test_ctx->tctx->dom, 0, ENOENT);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březinavoid test_user_by_id_missing_found(void **state)
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_id(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březinavoid test_user_by_id_missing_notfound(void **state)
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_user_by_id(test_ctx, test_ctx->tctx->dom, 0, ENOENT);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březinavoid test_group_by_name_multiple_domains_found(void **state)
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina "responder_cache_req_test_d", true);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(domain, &groups[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina will_return_always(sss_dp_get_account_recv, 0);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek mock_parse_inp(groups[0].short_name, NULL, ERR_OK);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březinavoid test_group_by_name_multiple_domains_notfound(void **state)
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina will_return_always(sss_dp_get_account_recv, 0);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek mock_parse_inp(groups[0].short_name, NULL, ERR_OK);
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březinavoid test_group_by_name_multiple_domains_parse(void **state)
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Add group to the first domain. */
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina "responder_cache_req_test_a", true);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek fqname = sss_create_internal_fqname(test_ctx, users[0].short_name, domain->name);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek ret = sysdb_store_group(domain, fqname, 2000, NULL,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Add group to the last domain, with different gid. */
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina "responder_cache_req_test_d", true);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(domain, &groups[0], 1000, time(NULL));
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek /* Append domain name to the groupname.
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek * We don't use the internal fqname here on purpose, because this is
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek * the user's input.
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek input_fqn = talloc_asprintf(test_ctx, "%s@%s", groups[0].short_name,
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek "responder_cache_req_test_d");
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina req_mem_ctx = talloc_new(global_talloc_context);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek mock_parse_inp(groups[0].short_name, "responder_cache_req_test_d", ERR_OK);
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina req = cache_req_group_by_name_send(req_mem_ctx, test_ctx->tctx->ev,
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina tevent_req_set_callback(req, cache_req_group_by_name_test_done, test_ctx);
d20a56f2f05a011e62ba921e70124583e3c5b652Jakub Hrozek assert_string_equal(input_fqn, test_ctx->name);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březinavoid test_group_by_name_cache_valid(void **state)
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_name(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březinavoid test_group_by_name_cache_expired(void **state)
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], -1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina /* DP should be contacted */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_name(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březinavoid test_group_by_name_cache_midpoint(void **state)
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], 50, time(NULL) - 26);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina /* DP should be contacted without callback */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_name(test_ctx, test_ctx->tctx->dom, 50, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek fqname = sss_create_internal_fqname(test_ctx, groups[0].short_name,
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina ret = sss_ncache_set_group(test_ctx->ncache, false,
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_name(test_ctx, test_ctx->tctx->dom, 0, ENOENT);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březinavoid test_group_by_name_missing_found(void **state)
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_name(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
641d684ee88c6540a4cf1d74d258614f615699fePavel Březinavoid test_group_by_name_missing_notfound(void **state)
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_name(test_ctx, test_ctx->tctx->dom, 0, ENOENT);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březinavoid test_group_by_id_multiple_domains_found(void **state)
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina "responder_cache_req_test_d", true);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(domain, &groups[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina will_return_always(sss_dp_get_account_recv, 0);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březinavoid test_group_by_id_multiple_domains_notfound(void **state)
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina will_return_always(sss_dp_get_account_recv, 0);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březinavoid test_group_by_id_cache_valid(void **state)
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], 1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_id(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březinavoid test_group_by_id_cache_expired(void **state)
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], -1000, time(NULL));
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina /* DP should be contacted */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_id(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březinavoid test_group_by_id_cache_midpoint(void **state)
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], 50, time(NULL) - 26);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina /* DP should be contacted without callback */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_id(test_ctx, test_ctx->tctx->dom, 50, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Setup group. */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina ret = sss_ncache_set_gid(test_ctx->ncache, false, NULL, groups[0].gid);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_id(test_ctx, test_ctx->tctx->dom, 0, ENOENT);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březinavoid test_group_by_id_missing_found(void **state)
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_id(test_ctx, test_ctx->tctx->dom, 0, ERR_OK);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březinavoid test_group_by_id_missing_notfound(void **state)
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina /* Mock values. */
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
3688374991afb34bbaf2b7843683fc13dd77879dPavel Březina run_group_by_id(test_ctx, test_ctx->tctx->dom, 0, ENOENT);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozekstatic void cache_req_user_by_filter_test_done(struct tevent_req *req)
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek ctx->tctx->error = cache_req_user_by_filter_recv(ctx, req,
da79bee1472a06b89be2df903fb0bd8ce600c610Petr Cechvoid test_user_by_recent_filter_valid(void **state)
da79bee1472a06b89be2df903fb0bd8ce600c610Petr Cech test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[1], 1000, time(NULL) - 1);
da79bee1472a06b89be2df903fb0bd8ce600c610Petr Cech /* Filters always go to DP */
da79bee1472a06b89be2df903fb0bd8ce600c610Petr Cech will_return(__wrap_sss_dp_get_account_send, test_ctx);
da79bee1472a06b89be2df903fb0bd8ce600c610Petr Cech /* User TEST_USER is created with a DP callback. */
da79bee1472a06b89be2df903fb0bd8ce600c610Petr Cech req = cache_req_user_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
da79bee1472a06b89be2df903fb0bd8ce600c610Petr Cech tevent_req_set_callback(req, cache_req_user_by_filter_test_done, test_ctx);
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cechvoid test_users_by_recent_filter_valid(void **state)
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cech test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cech /* Filters always go to DP */
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cech will_return(__wrap_sss_dp_get_account_send, test_ctx);
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cech /* User TEST_USER1 and TEST_USER2 are created with a DP callback. */
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cech req = cache_req_user_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cech tevent_req_set_callback(req, cache_req_user_by_filter_test_done, test_ctx);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek user_names = talloc_zero_array(test_ctx, const char *, num_users);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek user_names[0] = sss_create_internal_fqname(user_names, users[0].short_name,
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek user_names[1] = sss_create_internal_fqname(user_names, users[1].short_name,
c19374b2a9b676ca534f52ef76d80f0945fe8fb2Pavel Březina for (int i = 0; i < num_users; ++i) {
c19374b2a9b676ca534f52ef76d80f0945fe8fb2Pavel Březina ldb_results[i] = ldb_msg_find_attr_as_string(test_ctx->result->msgs[i],
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cech assert_string_not_equal(ldb_results[0], ldb_results[1]);
c19374b2a9b676ca534f52ef76d80f0945fe8fb2Pavel Březina assert_true(are_values_in_array(user_names, num_users,
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozekvoid test_users_by_filter_filter_old(void **state)
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek /* This user was updated in distant past, so it wont't be reported by
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek * the filter search */
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_user(test_ctx->tctx->dom, &users[1], 1000, 1);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req_mem_ctx = talloc_new(global_talloc_context);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek /* Filters always go to DP */
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek will_return(__wrap_sss_dp_get_account_send, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req = cache_req_user_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek tevent_req_set_callback(req, cache_req_user_by_filter_test_done, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozekvoid test_users_by_filter_notfound(void **state)
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req_mem_ctx = talloc_new(global_talloc_context);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek /* Filters always go to DP */
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek will_return(__wrap_sss_dp_get_account_send, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req = cache_req_user_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek "nosuchuser*");
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek tevent_req_set_callback(req, cache_req_user_by_filter_test_done, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozekstatic void test_users_by_filter_multiple_domains_notfound(void **state)
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek domain = find_domain_by_name(test_ctx->tctx->dom,
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek "responder_cache_req_test_d", true);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req_mem_ctx = talloc_new(global_talloc_context);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek /* Filters always go to DP */
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek will_return(__wrap_sss_dp_get_account_send, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req = cache_req_user_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek "nosuchuser*");
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek tevent_req_set_callback(req, cache_req_user_by_filter_test_done, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozekstatic void cache_req_group_by_filter_test_done(struct tevent_req *req)
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek ctx = tevent_req_callback_data(req, struct cache_req_test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek ctx->tctx->error = cache_req_group_by_filter_recv(ctx, req,
fe6dd669d1e8606862879127f92c177bb7fdc1bdPetr Cechvoid test_group_by_recent_filter_valid(void **state)
fe6dd669d1e8606862879127f92c177bb7fdc1bdPetr Cech test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(test_ctx->tctx->dom, &groups[1], 1001, time(NULL) - 1);
fe6dd669d1e8606862879127f92c177bb7fdc1bdPetr Cech /* Filters always go to DP */
fe6dd669d1e8606862879127f92c177bb7fdc1bdPetr Cech will_return(__wrap_sss_dp_get_account_send, test_ctx);
fe6dd669d1e8606862879127f92c177bb7fdc1bdPetr Cech /* Group TEST_GROUP is created with a DP callback. */
fe6dd669d1e8606862879127f92c177bb7fdc1bdPetr Cech req = cache_req_group_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
fe6dd669d1e8606862879127f92c177bb7fdc1bdPetr Cech tevent_req_set_callback(req, cache_req_group_by_filter_test_done, test_ctx);
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cechvoid test_groups_by_recent_filter_valid(void **state)
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
8be4efb91f9af1bf49628c497a9de4b258bb893ePavel Březina prepare_group(test_ctx->tctx->dom, &groups[1], 1001, time(NULL) - 1);
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech /* Filters always go to DP */
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech will_return(__wrap_sss_dp_get_account_send, test_ctx);
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech /* Group TEST_GROUP1 and TEST_GROUP2 are created with a DP callback. */
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech req = cache_req_group_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech tevent_req_set_callback(req, cache_req_group_by_filter_test_done, test_ctx);
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech group_names = talloc_array(tmp_ctx, const char *, 2);
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek group_names[0] = sss_create_internal_fqname(group_names, groups[0].short_name,
187f65802ed26c49dbac2fba5e7cd1508f3db1e8Jakub Hrozek group_names[1] = sss_create_internal_fqname(group_names, groups[1].short_name,
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech ldb_results = talloc_array(tmp_ctx, const char *, 2);
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech for (int i = 0; i < 2; ++i) {
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech ldbname = ldb_msg_find_attr_as_string(test_ctx->result->msgs[i],
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech assert_string_not_equal(ldb_results[0], ldb_results[1]);
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech assert_true(tc_are_values_in_array(group_names, ldb_results));
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozekvoid test_groups_by_filter_notfound(void **state)
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req_mem_ctx = talloc_new(global_talloc_context);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek /* Filters always go to DP */
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek will_return(__wrap_sss_dp_get_account_send, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req = cache_req_group_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek "nosuchgroup*");
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek tevent_req_set_callback(req, cache_req_group_by_filter_test_done, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozekvoid test_groups_by_filter_multiple_domains_notfound(void **state)
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek domain = find_domain_by_name(test_ctx->tctx->dom,
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek "responder_cache_req_test_d", true);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req_mem_ctx = talloc_new(global_talloc_context);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek /* Filters always go to DP */
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek will_return(__wrap_sss_dp_get_account_send, test_ctx);
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek req = cache_req_group_by_filter_send(req_mem_ctx, test_ctx->tctx->ev,
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek "nosuchgroup*");
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek tevent_req_set_callback(req, cache_req_group_by_filter_test_done, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_user_cache_valid(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina prepare_user(test_ctx->tctx->dom, &users[0], 1000, time(NULL));
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_user_cache_expired(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina prepare_user(test_ctx->tctx->dom, &users[0], -1000, time(NULL));
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* DP should be contacted */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_user_cache_midpoint(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina prepare_user(test_ctx->tctx->dom, &users[0], 50, time(NULL) - 26);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* DP should be contacted without callback */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_user_ncache(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina ret = sss_ncache_set_sid(test_ctx->ncache, false, users[0].sid);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_user_missing_found(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina check_user(test_ctx, &users[0], test_ctx->tctx->dom);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_user_missing_notfound(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_user_multiple_domains_found(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina "responder_cache_req_test_d", true);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina prepare_user(domain, &users[0], 1000, time(NULL));
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return_always(sss_dp_get_account_recv, 0);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, NULL, users[0].sid, attrs, 0, ERR_OK);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_user_multiple_domains_notfound(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return_always(sss_dp_get_account_recv, 0);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, NULL, users[0].sid, attrs, 0, ENOENT);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_group_cache_valid(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], 1000, time(NULL));
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_group_cache_expired(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], -1000, time(NULL));
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* DP should be contacted */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_group_cache_midpoint(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina prepare_group(test_ctx->tctx->dom, &groups[0], 50, time(NULL) - 26);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* DP should be contacted without callback */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_group_ncache(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina ret = sss_ncache_set_sid(test_ctx->ncache, false, groups[0].sid);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_group_missing_found(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina check_group(test_ctx, &groups[0], test_ctx->tctx->dom);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_group_missing_notfound(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_group_multiple_domains_found(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Setup user. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina domain = find_domain_by_name(test_ctx->tctx->dom,
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina "responder_cache_req_test_d", true);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina prepare_group(domain, &groups[0], 1000, time(NULL));
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return_always(sss_dp_get_account_recv, 0);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, NULL, groups[0].sid, attrs, 0, ERR_OK);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březinavoid test_object_by_sid_group_multiple_domains_notfound(void **state)
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina test_ctx = talloc_get_type_abort(*state, struct cache_req_test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina /* Mock values. */
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return_always(__wrap_sss_dp_get_account_send, test_ctx);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina will_return_always(sss_dp_get_account_recv, 0);
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina run_object_by_sid(test_ctx, NULL, groups[0].sid, attrs, 0, ENOENT);
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březina new_single_domain_test(user_by_name_cache_valid),
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březina new_single_domain_test(user_by_name_cache_expired),
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březina new_single_domain_test(user_by_name_cache_midpoint),
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březina new_single_domain_test(user_by_name_missing_found),
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březina new_single_domain_test(user_by_name_missing_notfound),
54ed1b1214dbf9da1f481e8d193c81ce4312516bPavel Březina new_multi_domain_test(user_by_name_multiple_domains_found),
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina new_multi_domain_test(user_by_name_multiple_domains_notfound),
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina new_multi_domain_test(user_by_name_multiple_domains_parse),
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina new_single_domain_test(user_by_upn_cache_valid),
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina new_single_domain_test(user_by_upn_cache_expired),
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina new_single_domain_test(user_by_upn_cache_midpoint),
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina new_single_domain_test(user_by_upn_missing_found),
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina new_single_domain_test(user_by_upn_missing_notfound),
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina new_multi_domain_test(user_by_upn_multiple_domains_found),
28ebfa4373d1e7ce45b5d70a3619df1c074a661ePavel Březina new_multi_domain_test(user_by_upn_multiple_domains_notfound),
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina new_single_domain_test(user_by_id_cache_valid),
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina new_single_domain_test(user_by_id_cache_expired),
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina new_single_domain_test(user_by_id_cache_midpoint),
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina new_single_domain_test(user_by_id_missing_found),
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina new_single_domain_test(user_by_id_missing_notfound),
3a5ea81007bd38ce511c37f65cc45d4b6b95ec44Pavel Březina new_multi_domain_test(user_by_id_multiple_domains_found),
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina new_multi_domain_test(user_by_id_multiple_domains_notfound),
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina new_single_domain_test(group_by_name_cache_valid),
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina new_single_domain_test(group_by_name_cache_expired),
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina new_single_domain_test(group_by_name_cache_midpoint),
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina new_single_domain_test(group_by_name_missing_found),
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina new_single_domain_test(group_by_name_missing_notfound),
641d684ee88c6540a4cf1d74d258614f615699fePavel Březina new_multi_domain_test(group_by_name_multiple_domains_found),
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina new_multi_domain_test(group_by_name_multiple_domains_notfound),
e87b2a6e94c1066b3044fe683825ff5b4f8716c2Pavel Březina new_multi_domain_test(group_by_name_multiple_domains_parse),
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina new_single_domain_test(group_by_id_cache_valid),
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina new_single_domain_test(group_by_id_cache_expired),
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina new_single_domain_test(group_by_id_cache_midpoint),
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina new_single_domain_test(group_by_id_missing_found),
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina new_single_domain_test(group_by_id_missing_notfound),
71965bb18407ff45ada9e47cb6def086e48663c6Pavel Březina new_multi_domain_test(group_by_id_multiple_domains_found),
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek new_multi_domain_test(group_by_id_multiple_domains_notfound),
da79bee1472a06b89be2df903fb0bd8ce600c610Petr Cech new_single_domain_test(user_by_recent_filter_valid),
a6a5a08a357d2adbb653b81bacc602ca3543c4c4Petr Cech new_single_domain_test(users_by_recent_filter_valid),
fe6dd669d1e8606862879127f92c177bb7fdc1bdPetr Cech new_single_domain_test(group_by_recent_filter_valid),
16212bbb2aaa55d0587515e72c0018479ae51be9Petr Cech new_single_domain_test(groups_by_recent_filter_valid),
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek new_single_domain_test(users_by_filter_filter_old),
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek new_single_domain_test(users_by_filter_notfound),
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek new_multi_domain_test(users_by_filter_multiple_domains_notfound),
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek new_single_domain_test(groups_by_filter_notfound),
fd04b25eaa5cd105da4122854d8bc1e702760e60Jakub Hrozek new_multi_domain_test(groups_by_filter_multiple_domains_notfound),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_user_cache_valid),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_user_cache_expired),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_user_cache_midpoint),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_user_ncache),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_user_missing_found),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_user_missing_notfound),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_multi_domain_test(object_by_sid_user_multiple_domains_found),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_multi_domain_test(object_by_sid_user_multiple_domains_notfound),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_group_cache_valid),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_group_cache_expired),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_group_cache_midpoint),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_group_ncache),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_group_missing_found),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_single_domain_test(object_by_sid_group_missing_notfound),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_multi_domain_test(object_by_sid_group_multiple_domains_found),
0d111f6975c7e132bf1069d6d7bd6d6afd2127dfPavel Březina new_multi_domain_test(object_by_sid_group_multiple_domains_notfound),
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina /* Set debug level to invalid value so we can deside if -d 0 was used. */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina pc = poptGetContext(argv[0], argc, argv, long_options, 0);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina fprintf(stderr, "\nInvalid option %s: %s\n\n",
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina /* Even though normally the tests should clean up after themselves
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina * they might not after a failed run. Remove the old db to be sure */
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_multidom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, domains);
360a4be4266d6a72be99dfd252623dc0527f5b84Pavel Březina test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);