d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek sysdb_ts - Test for sysdb timestamp cache
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek Copyright (C) 2016 Red Hat
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek This program is free software; you can redistribute it and/or modify
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek it under the terms of the GNU General Public License as published by
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek the Free Software Foundation; either version 3 of the License, or
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek (at your option) any later version.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek This program is distributed in the hope that it will be useful,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek GNU General Public License for more details.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek You should have received a copy of the GNU General Public License
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek#define TEST_GROUP_SID "S-1-5-21-123-456-789-111"
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek#define TEST_USER_SID "S-1-5-21-123-456-789-222"
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek#define TS_FILTER_ALL "("SYSDB_CACHE_EXPIRE"=*)"
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek test_ctx->tctx = create_multidom_test_ctx(test_ctx, TESTS_PATH,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek //assert_true(check_leaks_pop(test_ctx));
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM1_NAME);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic struct sysdb_attrs *create_modstamp_attrs(TALLOC_CTX *mem_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic struct sysdb_attrs *create_str_attrs(TALLOC_CTX *mem_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *key,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_attrs_add_string(attrs, key, value);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic struct sysdb_attrs *create_sidstr_attrs(TALLOC_CTX *mem_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek return create_str_attrs(mem_ctx, SYSDB_SID_STR, sid_str);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic struct sysdb_attrs *create_upnstr_attrs(TALLOC_CTX *mem_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek return create_str_attrs(mem_ctx, SYSDB_UPN, upn_str);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic struct sysdb_attrs *create_ts_attrs(TALLOC_CTX *mem_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic struct ldb_result *sysdb_getgrnam_res(TALLOC_CTX *mem_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *name)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getgrnam(mem_ctx, domain, name, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic struct ldb_result *sysdb_getpwnam_res(TALLOC_CTX *mem_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *name)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getpwnam(mem_ctx, domain, name, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic uint64_t get_dn_cache_timestamp(struct sysdb_ts_test_ctx *test_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = ldb_search(test_ctx->tctx->sysdb->ldb, test_ctx, &res,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek if (ret != EOK || res == NULL || res->count != 1) {
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cache_expire_sysdb = ldb_msg_find_attr_as_uint64(res->msgs[0],
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic uint64_t get_gr_cache_timestamp(struct sysdb_ts_test_ctx *test_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *name)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek dn = sysdb_group_dn(test_ctx, test_ctx->tctx->dom, name);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cache_expire_sysdb = get_dn_cache_timestamp(test_ctx, dn);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic uint64_t get_pw_cache_timestamp(struct sysdb_ts_test_ctx *test_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *name)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek dn = sysdb_user_dn(test_ctx, test_ctx->tctx->dom, name);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cache_expire_sysdb = get_dn_cache_timestamp(test_ctx, dn);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic uint64_t get_dn_ts_cache_timestamp(struct sysdb_ts_test_ctx *test_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_ts_entry(test_ctx, test_ctx->tctx->sysdb,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cache_expire_ts = ldb_msg_find_attr_as_uint64(msgs[0],
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic uint64_t get_gr_ts_cache_timestamp(struct sysdb_ts_test_ctx *test_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *name)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek dn = sysdb_group_dn(test_ctx, test_ctx->tctx->dom, name);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cache_expire_ts = get_dn_ts_cache_timestamp(test_ctx, dn);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic uint64_t get_pw_ts_cache_timestamp(struct sysdb_ts_test_ctx *test_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *name)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek dn = sysdb_user_dn(test_ctx, test_ctx->tctx->dom, name);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cache_expire_ts = get_dn_ts_cache_timestamp(test_ctx, dn);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void get_gr_timestamp_attrs(struct sysdb_ts_test_ctx *test_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *name,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek *cache_expire_sysdb = get_gr_cache_timestamp(test_ctx, name);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek *cache_expire_ts = get_gr_ts_cache_timestamp(test_ctx, name);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void get_pw_timestamp_attrs(struct sysdb_ts_test_ctx *test_ctx,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *name,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek *cache_expire_sysdb = get_pw_cache_timestamp(test_ctx, name);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek *cache_expire_ts = get_pw_ts_cache_timestamp(test_ctx, name);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void test_sysdb_group_update(void **state)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Nothing must be stored in either cache at the beginning of the test */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getgrnam_res(test_ctx, test_ctx->tctx->dom, TEST_GROUP_NAME);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Store a group without a modifyTimestamp. Must not throw an error. This
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * tests that the sysdb timestamp code is able to cope with absence of an
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * attribute it operates on gracefully.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Store a group and add a modifyTimestamp this time.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * Since we want to write the timestamp attributes if they are not present,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * both caches will be bumped.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek group_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Update the same attrs and the same modifyTimestamp.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * Only the timestamp cache must be bumped */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Update with different modifyTimestamp but same attrs as previously
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * saved to the timestamp cache. We should detect the 'real' attributes
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * are the same and only bump the timestamp cache
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek group_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_4);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Update with different modifyTimestamp and different attrs (add a
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * member as a real-world example). Both caches must be updated. */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek group_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek test_user_member = sysdb_user_strdn(group_attrs,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_attrs_add_string(group_attrs, SYSDB_MEMBER, test_user_member);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_5);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_5);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Try to save the same member again, while it's already saved. Only the
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * timestamps cache must be bumped now
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_5);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_6);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void test_sysdb_group_delete(void **state)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ts_res = talloc_zero(test_ctx, struct ldb_result);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Nothing must be stored in either cache at the beginning of the test */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getgrnam_res(test_ctx, test_ctx->tctx->dom, TEST_GROUP_NAME);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek group_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Nothing must be stored in either cache at the end of the test */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getgrnam_res(test_ctx, test_ctx->tctx->dom, TEST_GROUP_NAME);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void test_sysdb_group_rename(void **state)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ts_res = talloc_zero(test_ctx, struct ldb_result);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Nothing must be stored in either cache at the beginning of the test */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getgrnam_res(test_ctx, test_ctx->tctx->dom, TEST_GROUP_NAME);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getgrnam_res(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek filter = talloc_asprintf(ts_res, "(|(%s=%s)(%s=%s))",
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Store an old group */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME_OLD,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Replace with a new one */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* The old entry must be gone from both caches */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME_OLD,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getgrnam_res(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void assert_ts_attrs_msg(struct ldb_message *msg,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Attributes normally requested with getgrnam are merged */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek expiration = ldb_msg_find_attr_as_uint64(msg, SYSDB_CACHE_EXPIRE, 0);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek last_update = ldb_msg_find_attr_as_uint64(msg, SYSDB_LAST_UPDATE, 0);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(last_update, exp_last_update);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Attributes not requested are not */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek modstamp = ldb_msg_find_attr_as_string(msg, SYSDB_ORIG_MODSTAMP, NULL);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void assert_ts_attrs_res(struct ldb_result *res,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek return assert_ts_attrs_msg(res->msgs[0], exp_expiration, exp_last_update);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void assert_ts_attrs_msgs_list(size_t msgs_count,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek return assert_ts_attrs_res(&res, exp_expiration, exp_last_update);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void test_sysdb_getgr_merges(void **state)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *gr_fetch_attrs[] = SYSDB_GRSRC_ATTRS;
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek group_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek group_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getgrnam(test_ctx, test_ctx->tctx->dom, TEST_GROUP_NAME, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getgrgid(test_ctx, test_ctx->tctx->dom, TEST_GROUP_GID, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_groups(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek group_attrs = create_ts_attrs(test_ctx, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_set_group_attr(test_ctx->tctx->dom, TEST_GROUP_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getgrnam(test_ctx, test_ctx->tctx->dom, TEST_GROUP_NAME, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Make sure sysdb_search_group_by_name includes timestamp attributes */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_group_by_name(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_msg(msg, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_group_by_gid(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_msg(msg, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void test_merge_ldb_results(void **state)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *gr_fetch_attrs[] = SYSDB_GRSRC_ATTRS;
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res1 = talloc_zero(test_ctx, struct ldb_result);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res2 = talloc_zero(test_ctx, struct ldb_result);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek filter = talloc_asprintf(test_ctx, "(|(%s=%s)(%s=%s))",
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_groups(res1, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek filter = talloc_asprintf(test_ctx, "(|(%s=%s)(%s=%s))",
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_groups(res2, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek const char *gr_fetch_attrs[] = SYSDB_GRSRC_ATTRS;
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek group_attrs = create_sidstr_attrs(test_ctx, TEST_GROUP_SID);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_msg(msg, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_delete_by_sid(test_ctx->tctx->dom->sysdb,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void test_sysdb_user_update(void **state)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Nothing must be stored in either cache at the beginning of the test */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getpwnam_res(test_ctx, test_ctx->tctx->dom, TEST_USER_NAME);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Store a user without a modifyTimestamp. Must not throw an error. This
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * tests that the sysdb timestamp code is able to cope with absence of an
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * attribute it operates on gracefully.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Store a user and add a modifyTimestamp this time.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * Since we want to write the timestamp attributes if they are not present,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * both caches will be bumped.
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Update with different modifyTimestamp but same attrs as previously
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * saved to the timestamp cache. We should detect the 'real' attributes
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * are the same and only bump the timestamp cache
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_4);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Update with different modifyTimestamp and different attrs (change
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek * the shell as a real-world example). Both caches must be updated. */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_5);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_5);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void test_sysdb_user_delete(void **state)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ts_res = talloc_zero(test_ctx, struct ldb_result);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Nothing must be stored in either cache at the beginning of the test */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getpwnam_res(test_ctx, test_ctx->tctx->dom, TEST_USER_NAME);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_sysdb, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_int_equal(cache_expire_ts, TEST_CACHE_TIMEOUT + TEST_NOW_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Nothing must be stored in either cache at the end of the test */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek res = sysdb_getpwnam_res(test_ctx, test_ctx->tctx->dom, TEST_USER_NAME);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozekstatic void test_sysdb_getpw_merges(void **state)
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* sysdb cache will have test_now1 and ts cache test_now2 at this point */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* getpwnam must return the timestamp from the ts cache */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getpwnam(test_ctx, test_ctx->tctx->dom, TEST_USER_NAME, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* getpwuid must return the timestamp from the ts cache */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getpwuid(test_ctx, test_ctx->tctx->dom, TEST_USER_UID, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_users(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* set_user_attrs must bump the ts cache */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_ts_attrs(test_ctx, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_set_user_attr(test_ctx->tctx->dom, TEST_USER_NAME,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* getpwnam must return the timestamp from the ts cache */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getpwnam(test_ctx, test_ctx->tctx->dom, TEST_USER_NAME, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_initgroups(test_ctx, test_ctx->tctx->dom, TEST_USER_NAME, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_get_user_attr(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Make sure sysdb_search_user_by_name includes timestamp attributes */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_user_by_name(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_msg(msg, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_user_by_uid(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_msg(msg, TEST_NOW_3 + TEST_CACHE_TIMEOUT, TEST_NOW_3);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_sidstr_attrs(test_ctx, TEST_USER_SID);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_msg(msg, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_delete_by_sid(test_ctx->tctx->dom->sysdb,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek user_attrs = create_upnstr_attrs(test_ctx, TEST_USER_UPN);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_getpwupn(test_ctx, test_ctx->tctx->dom, TEST_USER_UPN, &res);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_user_by_upn_res(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_search_user_by_upn(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_msg(msg, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek ret = sysdb_initgroups_by_upn(test_ctx, test_ctx->tctx->dom,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek assert_ts_attrs_res(res, TEST_NOW_2 + TEST_CACHE_TIMEOUT, TEST_NOW_2);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek struct sysdb_ts_test_ctx *test_ctx = talloc_get_type_abort(*state,
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek /* Nothing must be stored in either cache at the beginning of the test */
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek res = sysdb_getpwnam_res(test_ctx, test_ctx->tctx->dom, TEST_USER_NAME);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek res = sysdb_getgrnam_res(test_ctx, test_ctx->tctx->dom, TEST_GROUP_NAME);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek ret = sysdb_store_user(test_ctx->tctx->dom, TEST_USER_NAME, NULL,
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek attrs = create_modstamp_attrs(test_ctx, TEST_MODSTAMP_1);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek /* Even though we passed zero as the timestamp, the timestamp cache should
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek * have used the current time instead
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek get_pw_timestamp_attrs(test_ctx, TEST_USER_NAME,
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek assert_true(cache_expire_sysdb > TEST_CACHE_TIMEOUT);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek assert_true(cache_expire_ts > TEST_CACHE_TIMEOUT);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek get_gr_timestamp_attrs(test_ctx, TEST_GROUP_NAME,
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek assert_true(cache_expire_sysdb > TEST_CACHE_TIMEOUT);
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek assert_true(cache_expire_ts > TEST_CACHE_TIMEOUT);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek {"no-cleanup", 'n', POPT_ARG_NONE, &no_cleanup, 0,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek _("Do not delete the test database after a test run"), NULL },
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_sysdb_group_update,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_sysdb_group_delete,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_sysdb_group_rename,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_sysdb_getgr_merges,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_group_bysid,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_merge_ldb_results,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_sysdb_user_update,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_sysdb_user_delete,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_sysdb_getpw_merges,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_user_bysid,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek cmocka_unit_test_setup_teardown(test_user_byupn,
eb92441b65e0db9e64c88a57eb74358640e85d56Jakub Hrozek cmocka_unit_test_setup_teardown(test_sysdb_zero_now,
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek /* Set debug level to invalid value so we can deside if -d 0 was used. */
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek pc = poptGetContext(argv[0], argc, argv, long_options, 0);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek test_multidom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, domains);
d36f4db9bb5efc63b94190cca25adb08ee56971cJakub Hrozek rv = cmocka_run_group_tests(tests, NULL, NULL);