test_sysdb_views.c revision 696c17580b49d6817f1dd33915e0e209dcfe4225
/*
SSSD
sysdb_views - Tests for view and override related sysdb calls
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2014 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" /* for sysdb->ldb member */
#define TESTS_PATH "tests_sysdb_views"
#define TEST_CONF_FILE "tests_conf.ldb"
#define TEST_ANCHOR_PREFIX ":ANCHOR:"
#define TEST_VIEW_NAME "test view"
#define TEST_USER_NAME "test_user"
#define TEST_USER_UID 1234
#define TEST_USER_GID 5678
#define TEST_USER_GECOS "Gecos field"
#define TEST_USER_HOMEDIR "/home/home"
#define TEST_USER_SHELL "/bin/shell"
#define TEST_USER_SID "S-1-2-3-4"
#define TEST_GID_OVERRIDE_BASE 100
struct sysdb_test_ctx {
struct confdb_ctx *confdb;
struct tevent_context *ev;
struct sss_domain_info *domain;
};
{
struct sysdb_test_ctx *test_ctx;
char *conf_db;
int ret;
const char *val[2];
/* Create tests directory if it doesn't exist */
/* (relative to current dir) */
/* Create an event context
* It will not be used except in confdb_init and sysdb_init
*/
/* Connect to the conf db */
val[0] = "LOCAL";
val[0] = "local";
val[0] = "TRUE";
return EOK;
}
static int test_sysdb_setup(void **state)
{
int ret;
struct sysdb_test_ctx *test_ctx;
return 0;
}
static int test_sysdb_teardown(void **state)
{
struct sysdb_test_ctx);
return 0;
}
static void test_sysdb_store_override(void **state)
{
int ret;
struct ldb_message *msg;
struct ldb_message **msgs;
struct sysdb_attrs *attrs;
struct sysdb_test_ctx);
0,0);
/* No override exists */
/* Missing anchor attribute */
/* With anchor */
}
void test_sysdb_add_overrides_to_object(void **state)
{
int ret;
struct ldb_message *orig;
struct ldb_message *override;
struct ldb_message_element *el;
char *tmp_str;
struct sysdb_test_ctx);
"ORIGNAME");
"ORIGGECOS");
NULL),
"OVERRIDENAME");
NULL),
"OVERRIDEGECOS");
}
void test_split_ipa_anchor(void **state)
{
int ret;
char *dom;
char *uuid;
struct sysdb_test_ctx);
}
void test_sysdb_delete_view_tree(void **state)
{
int ret;
struct ldb_message *msg;
struct sysdb_attrs *attrs;
struct sysdb_test_ctx);
0,0);
}
void test_sysdb_invalidate_overrides(void **state)
{
int ret;
struct ldb_message *msg;
struct sysdb_attrs *attrs;
const char *user_attrs[] = { SYSDB_NAME,
NULL};
struct sysdb_test_ctx);
10,0);
user_attrs, &msg);
user_attrs, &msg);
1);
}
const char *name)
{
int ret;
struct sysdb_attrs *attrs;
const char *anchor;
const char *override_gecos;
}
const char *usernames[])
{
int i;
int ret;
struct sysdb_attrs *attrs;
}
}
const char *usernames[])
{
int i;
int ret;
fail();
}
}
}
static int test_enum_users_setup(void **state)
{
int ret;
struct sysdb_test_ctx *test_ctx;
return 0;
}
const char *name,
bool has_views)
{
const char *str;
if (has_views) {
char *override;
} else {
}
}
static int test_enum_users_teardown(void **state)
{
struct sysdb_test_ctx);
return test_sysdb_teardown(state);
}
{
}
static void test_sysdb_enumpwent(void **state)
{
int ret;
struct sysdb_test_ctx);
struct ldb_result *res;
}
static void test_sysdb_enumpwent_views(void **state)
{
int ret;
struct sysdb_test_ctx);
struct ldb_result *res;
}
static void test_sysdb_enumpwent_filter(void **state)
{
int ret;
struct sysdb_test_ctx);
struct ldb_result *res;
char *addtl_filter;
/* Test searching based on time as well */
SYSDB_LAST_UPDATE, 1233);
SYSDB_LAST_UPDATE, 1234);
}
static void test_sysdb_enumpwent_filter_views(void **state)
{
int ret;
struct sysdb_test_ctx);
struct ldb_result *res;
char *addtl_filter;
SYSDB_LAST_UPDATE, 1235);
}
const char *name,
unsigned override_gid)
{
int ret;
struct sysdb_attrs *attrs;
const char *anchor;
}
const char *groupnames[])
{
int i;
int ret;
struct sysdb_attrs *attrs;
for (i = 0; groupnames[i] != NULL; i++) {
TEST_GID_OVERRIDE_BASE + i);
}
}
const char *groupnames[])
{
int i;
int ret;
for (i = 0; groupnames[i] != NULL; i++) {
fail();
}
}
}
static int test_enum_groups_setup(void **state)
{
int ret;
struct sysdb_test_ctx *test_ctx;
return 0;
}
static int test_enum_groups_teardown(void **state)
{
struct sysdb_test_ctx);
return test_sysdb_teardown(state);
}
const char *name,
unsigned expected_override_gid)
{
const char *str;
unsigned gid;
if (expected_override_gid) {
}
}
{
}
static void test_sysdb_enumgrent(void **state)
{
int ret;
struct sysdb_test_ctx);
struct ldb_result *res;
}
static void test_sysdb_enumgrent_views(void **state)
{
int ret;
struct sysdb_test_ctx);
struct ldb_result *res;
}
static void test_sysdb_enumgrent_filter(void **state)
{
int ret;
struct sysdb_test_ctx);
struct ldb_result *res;
char *addtl_filter;
SYSDB_LAST_UPDATE, 1233);
SYSDB_LAST_UPDATE, 1234);
}
static void test_sysdb_enumgrent_filter_views(void **state)
{
int ret;
struct sysdb_test_ctx);
struct ldb_result *res;
char *addtl_filter;
SYSDB_LAST_UPDATE, 1235);
}
{
int rv;
int no_cleanup = 0;
int opt;
struct poptOption long_options[] = {
_("Do not delete the test database after a test run"), NULL },
};
const struct CMUnitTest tests[] = {
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
if (rv == 0 && no_cleanup == 0) {
}
return rv;
}