/*
SSSD
sysdb_ts - Test for sysdb timestamp cache
Copyright (C) 2016 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <popt.h>
#include "tests/cmocka/common_mock.h"
#include "db/sysdb_private.h"
struct sysdb_ts_test_ctx {
};
NULL };
{
struct sysdb_ts_test_ctx);
return 0;
}
{
struct sysdb_ts_test_ctx);
//assert_true(check_leaks_pop(test_ctx));
return 0;
}
const char *modstamp)
{
int ret;
return NULL;
}
modstamp);
return NULL;
}
return attrs;
}
const char *key,
const char *value)
{
int ret;
return NULL;
}
return NULL;
}
return attrs;
}
const char *sid_str)
{
}
const char *upn_str)
{
}
{
int ret;
return NULL;
}
return NULL;
}
return NULL;
}
return attrs;
}
struct sss_domain_info *domain,
const char *name)
{
int ret;
return res;
}
struct sss_domain_info *domain,
const char *name)
{
int ret;
return res;
}
{
int ret;
NULL,
};
return 0;
}
0);
return cache_expire_sysdb;
}
const char *name)
{
return 0;
}
return cache_expire_sysdb;
}
const char *name)
{
return 0;
}
return cache_expire_sysdb;
}
{
NULL,
};
int ret;
return 0;
}
if (msg_count != 1) {
return 0;
}
SYSDB_CACHE_EXPIRE, 0);
return cache_expire_ts;
}
const char *name)
{
return 0;
}
return cache_expire_ts;
}
const char *name)
{
return 0;
}
return cache_expire_ts;
}
const char *name,
{
}
const char *name,
{
}
{
int ret;
struct sysdb_ts_test_ctx);
/* Nothing must be stored in either cache at the beginning of the test */
/* Store a group without a modifyTimestamp. Must not throw an error. This
* tests that the sysdb timestamp code is able to cope with absence of an
* attribute it operates on gracefully.
*/
/* Store a group and add a modifyTimestamp this time.
* Since we want to write the timestamp attributes if they are not present,
* both caches will be bumped.
*/
/* Update the same attrs and the same modifyTimestamp.
* Only the timestamp cache must be bumped */
/* Update with different modifyTimestamp but same attrs as previously
* saved to the timestamp cache. We should detect the 'real' attributes
* are the same and only bump the timestamp cache
*/
/* Update with different modifyTimestamp and different attrs (add a
* member as a real-world example). Both caches must be updated. */
NULL,
/* Try to save the same member again, while it's already saved. Only the
* timestamps cache must be bumped now
*/
}
{
int ret;
struct sysdb_ts_test_ctx);
/* Nothing must be stored in either cache at the beginning of the test */
ts_res);
ts_res);
/* Nothing must be stored in either cache at the end of the test */
ts_res);
}
{
int ret;
struct sysdb_ts_test_ctx);
char *filter;
/* Nothing must be stored in either cache at the beginning of the test */
ts_res);
/* Store an old group */
NULL,
/* Replace with a new one */
NULL,
/* The old entry must be gone from both caches */
}
{
const char *modstamp;
/* Attributes normally requested with getgrnam are merged */
/* Attributes not requested are not */
}
{
}
struct ldb_message **msgs,
{
}
{
int ret;
struct sysdb_ts_test_ctx);
&msgs_count, &msgs);
/* Make sure sysdb_search_group_by_name includes timestamp attributes */
}
{
int ret;
struct sysdb_ts_test_ctx);
char *filter;
NULL,
NULL,
NULL,
}
{
int ret;
struct sysdb_ts_test_ctx);
&res);
NULL,
&res);
&msg);
&res);
&ts_res);
}
{
int ret;
struct sysdb_ts_test_ctx);
/* Nothing must be stored in either cache at the beginning of the test */
/* Store a user without a modifyTimestamp. Must not throw an error. This
* tests that the sysdb timestamp code is able to cope with absence of an
* attribute it operates on gracefully.
*/
/* Store a user and add a modifyTimestamp this time.
* Since we want to write the timestamp attributes if they are not present,
* both caches will be bumped.
*/
/* Update with different modifyTimestamp but same attrs as previously
* saved to the timestamp cache. We should detect the 'real' attributes
* are the same and only bump the timestamp cache
*/
/* Update with different modifyTimestamp and different attrs (change
* the shell as a real-world example). Both caches must be updated. */
}
{
int ret;
struct sysdb_ts_test_ctx);
/* Nothing must be stored in either cache at the beginning of the test */
ts_res);
ts_res);
/* Nothing must be stored in either cache at the end of the test */
ts_res);
}
{
int ret;
struct sysdb_ts_test_ctx);
/* sysdb cache will have test_now1 and ts cache test_now2 at this point */
/* getpwnam must return the timestamp from the ts cache */
/* getpwuid must return the timestamp from the ts cache */
&msgs_count, &msgs);
/* set_user_attrs must bump the ts cache */
/* getpwnam must return the timestamp from the ts cache */
/* Make sure sysdb_search_user_by_name includes timestamp attributes */
}
{
int ret;
struct sysdb_ts_test_ctx);
&res);
&res);
&msg);
&res);
&ts_res);
}
{
int ret;
struct sysdb_ts_test_ctx);
false, TEST_USER_UPN, pw_fetch_attrs,
&res);
false, TEST_USER_UPN, pw_fetch_attrs,
&msg);
TEST_USER_UPN, &res);
}
{
int ret;
struct sysdb_ts_test_ctx);
/* Nothing must be stored in either cache at the beginning of the test */
0);
0);
0);
0);
/* Even though we passed zero as the timestamp, the timestamp cache should
* have used the current time instead
*/
}
{
int rv;
int no_cleanup = 0;
int opt;
_("Do not delete the test database after a test run"), NULL },
};
};
/* Set debug level to invalid value so we can decide if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
if (rv == 0 && no_cleanup == 0) {
}
return rv;
}