sysdb-tests.c revision 8455d5ab61184e0d126fc074a9ce6e98391eb909
/*
SSSD
System Database
Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009
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 <stdlib.h>
#include <check.h>
#include <talloc.h>
#include <tevent.h>
#include <popt.h>
#include "confdb/confdb_setup.h"
#include "db/sysdb_private.h"
#include "db/sysdb_services.h"
#include "db/sysdb_autofs.h"
#define TESTS_PATH "tests_sysdb"
#define TEST_CONF_FILE "tests_conf.ldb"
#define TEST_ATTR_NAME "test_attr_name"
#define TEST_ATTR_VALUE "test_attr_value"
#define TEST_ATTR_UPDATE_VALUE "test_attr_update_value"
#define TEST_ATTR_ADD_NAME "test_attr_add_name"
#define TEST_ATTR_ADD_VALUE "test_attr_add_value"
#define CUSTOM_TEST_CONTAINER "custom_test_container"
#define CUSTOM_TEST_OBJECT "custom_test_object"
#define ASQ_TEST_USER "testuser27010"
#define ASQ_TEST_USER_UID 27010
#define MBO_USER_BASE 27500
#define MBO_GROUP_BASE 28500
#define TEST_AUTOFS_MAP_BASE 29500
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) */
return EFAULT;
}
fail("Could not allocate memory for test context");
return ENOMEM;
}
/* Create an event context
* It will not be used except in confdb_init and sysdb_init
*/
fail("Could not create event context");
return EIO;
}
fail("Out of memory, aborting!");
return ENOMEM;
}
/* Connect to the conf db */
fail("Could not initialize connection to the confdb");
return ret;
}
val[0] = "LOCAL";
fail("Could not initialize domains placeholder");
return ret;
}
val[0] = "local";
fail("Could not initialize provider");
return ret;
}
val[0] = "TRUE";
fail("Could not initialize LOCAL domain");
return ret;
}
val[0] = "TRUE";
fail("Could not initialize LOCAL domain");
return ret;
}
return ret;
}
return EOK;
}
struct test_data {
struct tevent_context *ev;
struct sysdb_test_ctx *ctx;
const char *username;
const char *groupname;
const char *netgrname;
const char *autofsmapname;
const char *shell;
bool finished;
int error;
struct sysdb_attrs *attrs;
const char **attrlist;
struct ldb_message *msg;
struct ldb_message **msgs;
};
{
char *homedir;
char *gecos;
int ret;
return ret;
}
{
char *homedir;
char *gecos;
int ret;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
}
return ret;
}
{
int ret;
return ret;
}
{
const char *username;
int ret;
return ENOMEM;
}
return ret;
}
{
const char *username;
int ret;
return ENOMEM;
}
return ret;
}
{
char *object_name;
int ret;
if (!object_name) {
return ENOMEM;
}
return ret;
}
{
int ret;
return ret;
}
{
int ret;
"LOCAL");
return ENOMEM;
}
LDB_SCOPE_SUBTREE, "objectClass=user",
return ret;
}
{
int ret;
"LOCAL");
if (!dn) {
return ENOMEM;
}
return ret;
}
{
int ret;
char *member;
int i;
if (!attrs) {
return ENOMEM;
}
if (!member) {
return ENOMEM;
}
return ret;
}
}
return ret;
}
{
const char *description;
int ret;
return ret;
}
{
struct ldb_dn *netgroup_dn;
int ret;
if (!netgroup_dn) return ENOMEM;
return ret;
}
{
int ret;
return ret;
}
{
int ret;
const char *description;
if (!attrs) {
return ENOMEM;
}
if (ret) {
return ret;
}
return ret;
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
struct ldb_result *res;
const char *username;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
if (ret) {
fail("sysdb_getpwnam failed for username %s (%d: %s)",
goto done;
}
goto done;
}
/* Search for the user with the wrong case */
if (ret) {
fail("sysdb_getpwnam failed for username %s (%d: %s)",
goto done;
}
fail("The upper-case username search should fail.");
}
done:
}
{
struct sysdb_test_ctx *test_ctx;
struct ldb_result *res;
const char *groupname;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
if (ret) {
fail("sysdb_getgrnam failed for groupname %s (%d: %s)",
goto done;
}
goto done;
}
"Did not find the expected GID (found %d expected %d)",
/* Search for the group with the wrong case */
if (ret) {
fail("sysdb_getgrnam failed for groupname %s (%d: %s)",
goto done;
}
fail("The upper-case groupname search should fail.");
}
done:
}
{
struct sysdb_test_ctx *test_ctx;
struct ldb_result *res;
const char *e_groupname;
const char *groupname;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
if (ret) {
fail("sysdb_getgrgid failed for gid %d (%d: %s)",
goto done;
}
if (e_groupname == NULL) {
fail("Cannot allocate memory");
goto done;
}
"Did not find the expected groupname (found %s expected %s)",
done:
}
{
struct sysdb_test_ctx *test_ctx;
struct ldb_result *res;
const char *e_username;
const char *username;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
if (ret) {
fail("sysdb_getpwuid failed for uid %d (%d: %s)",
goto done;
}
fail("Cannot allocate memory");
goto done;
}
"Did not find the expected username (found %s expected %s)",
done:
}
{
struct sysdb_test_ctx *test_ctx;
struct ldb_result *res;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
&res);
"sysdb_enumgrent failed (%d: %s)",
/* 10 groups + 10 users (we're MPG) */
}
{
struct sysdb_test_ctx *test_ctx;
struct ldb_result *res;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
&res);
"sysdb_enumpwent failed (%d: %s)",
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
fail("Could not create the changeset");
return;
}
fail("Could not create the changeset");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
struct ldb_result *res;
const char *attrval;
char *username;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
if (ret) {
goto done;
}
"Got bad attribute value for user %s", username);
done:
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
fail("Could not create attribute list");
return;
}
fail("Could not add attribute");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
char *object_name;
/* Setup */
fail("Could not set up the test");
return;
}
&data->msgs_count,
"Wrong number of objects, exptected [1] got [%d]",
data->msgs_count);
"Wrong number of results, expected [1] got [%d]",
"Wrong attribute name");
"Wrong number of attribute values");
"Wrong attribute value");
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
fail("Could not create attribute list");
return;
}
fail("Could not add attribute");
return;
}
fail("Could not add attribute");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
char *object_name;
struct ldb_message_element *el;
/* Setup */
fail("Could not set up the test");
return;
}
&data->msgs_count,
"Wrong number of objects, exptected [1] got [%d]",
data->msgs_count);
"Wrong number of results, expected [2] got [%d]",
"Wrong attribute value");
"Wrong attribute value");
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
const char *filter = "(distinguishedName=*)";
/* Setup */
fail("Could not set up the test");
return;
}
&data->msgs_count,
"Wrong number of objects, exptected [10] got [%d]",
data->msgs_count);
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
}
static void cached_authentication_without_expiration(const char *username,
const char *password,
int expected_result)
{
struct sysdb_test_ctx *test_ctx;
int ret;
const char *val[2];
/* Setup */
val[0] = "0";
fail("Could not initialize provider");
return;
}
"return expected result [%d].",
0, expire_date);
-1, delayed_until);
}
static void cached_authentication_with_expiration(const char *username,
const char *password,
int expected_result)
{
struct sysdb_test_ctx *test_ctx;
int ret;
const char *val[2];
/* Setup */
val[0] = "1";
fail("Could not initialize provider");
return;
}
"sysdb_cache_auth request does not return expected "
"Wrong expire date, expected [%d], got [%d]",
-1, delayed_until);
}
{
char *username;
}
{
char *username;
}
{
char *username;
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
struct ldb_message **msgs;
int i;
char *gid_str;
/* Setup */
fail("Could not set up the test");
return;
}
"found [%d] expected [10]", msgs_count);
for (i = 0; i < msgs_count; i++) {
"found [%d] expected [1]",
msgs[i]->num_elements);
"wrong number of values, found [%d] expected [1]",
"wrong value, found [%.*s] expected [%s]",
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
int i;
char *uid_str;
/* Setup */
fail("Could not set up the test");
return;
}
"wrong number of results, found [%d] expected [10]",
data->msgs_count);
for (i = 0; i < data->msgs_count; i++) {
"wrong number of elements, found [%d] expected [1]",
"wrong number of values, found [%d] expected [1]",
"wrong value, found [%.*s] expected [%s]",
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_attrs *attrs;
struct ldb_message_element *el;
int ret;
"sysdb_attrs_replace overwrites existing attribute");
"Wrong number of values for attribute oof, "
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
if (_i == 0) {
} else {
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
_i + MBO_GROUP_BASE,
if (_i == 5) {
"sysdb_search_group_by_gid found "
"already deleted group");
} else {
"Wrong number of results, expected [1] got [%d]",
"Wrong attribute name");
"Wrong number of attribute values, "
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
_i + MBO_GROUP_BASE,
"Wrong number of results, expected [1] got [%d]",
"Wrong attribute name");
"Wrong number of attribute values, expected [%d] got [%d]",
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
_i + MBO_GROUP_BASE,
"Wrong number of results, expected [1] got [%d]",
"Wrong attribute name");
"Wrong number of attribute values, expected [%d] got [%d]",
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
_i + MBO_GROUP_BASE,
if (_i == 5) {
"sysdb_search_group_by_gid_send found "
"already deleted group");
} else {
"Wrong number of results, expected [1] got [%d]",
"Wrong attribute name");
"Wrong number of attribute values, expected [%d] got [%d]",
}
}
{
char **list;
"test_attr", &list);
list[0]);
list[1]);
}
{
struct sysdb_test_ctx *test_ctx;
const char *name;
const char *fromname = "fromgroup";
const char *toname = "togroup";
struct ldb_result *res;
/* Setup */
/* Store and verify the first group */
goto done;
}
"Did not find the expected GID (found %llu expected %llu)",
"Did not find the expected name (found %s expected %s)",
/* Perform rename and check that GID is the same, but name changed */
goto done;
}
"Did not find the expected GID (found %llu expected %llu)",
"Did not find the expected GID (found %s expected %s)",
/* Verify the first name is gone */
done:
}
{
struct sysdb_test_ctx *test_ctx;
const char *name;
const char *fromname = "fromuser";
const char *toname = "touser";
struct ldb_result *res;
/* Setup */
/* Store and verify the first user */
goto done;
}
"Did not find the expected UID (found %llu expected %llu)",
"Did not find the expected name (found %s expected %s)",
/* Perform rename and check that GID is the same, but name changed */
goto done;
}
"Did not find the expected UID (found %llu expected %llu)",
"Did not find the expected name (found %s expected %s)",
/* Verify the first name is gone */
done:
}
{
struct sysdb_test_ctx *test_ctx;
char **add_groups;
char **del_groups;
const char *user = "testuser27000";
/* Setup */
/* Add a user to two groups */
(const char *const *)add_groups, NULL);
/* Remove a user from one group and add to another */
(const char *const *)add_groups,
(const char *const *)del_groups);
/* Remove a user from two groups */
NULL, (const char *const *)del_groups);
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
const char *groupname;
char *parsed;
/* Setup */
fail("Could not set up the test");
return;
}
fail("Out of memory");
return;
}
"Names don't match (got %s)", parsed);
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
const char *netgrname;
struct ldb_message *msg;
struct ldb_dn *netgroup_dn;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
int ret;
const char *description;
const char *netgrname;
struct ldb_result *res;
const char *attrval;
/* Setup */
fail("Could not set up the test");
return;
}
"Got bad attribute value for netgroup %s", netgrname);
}
{
struct sysdb_test_ctx *test_ctx;
const char *netgrname;
const char *hostname;
const char *username;
const char *domainname;
struct ldb_result *res;
struct sysdb_netgroup_ctx **entries;
/* Setup */
fail("Could not set up the test");
return;
}
"Got more than one triple back");
"Got [%s], expected [%s] for hostname",
"Got [%s], expected [%s] for username",
"Got [%s], expected [%s] for domainname",
}
{
struct sysdb_test_ctx *test_ctx;
const char *netgrname;
const char *hostname;
const char *username;
const char *domainname;
struct ldb_result *res;
struct sysdb_netgroup_ctx **entries;
/* Setup */
fail("Could not set up the test");
return;
}
}
{
struct sysdb_test_ctx *test_ctx;
const char *netgrname;
const char *membername;
struct ldb_result *res;
struct sysdb_netgroup_ctx **entries;
char *hostname1;
char *username1;
char *domainname1;
char *hostname2;
char *username2;
char *domainname2;
/* Setup */
fail("Could not set up the test");
return;
}
"Did not get exactly two responses");
"Got [%s], expected [%s] for hostname",
"Got [%s], expected [%s] for username",
"Got [%s], expected [%s] for domainname",
"Got [%s], expected [%s] for hostname",
"Got [%s], expected [%s] for username",
"Got [%s], expected [%s] for domainname",
}
{
struct sysdb_test_ctx *test_ctx;
const char *netgrname;
const char *membername;
struct ldb_result *res;
struct sysdb_netgroup_ctx **entries;
char *hostname;
char *username;
char *domainname;
/* Setup */
fail("Could not set up the test");
return;
}
"Did not get exactly one response");
"Got [%s], expected [%s] for hostname",
"Got [%s], expected [%s] for username",
"Got [%s], expected [%s] for domainname",
}
{
struct sysdb_test_ctx *test_ctx;
struct ldb_result *res;
struct ldb_message *msg;
const char odd_username[] = "*(odd)\\user,name";
const char odd_groupname[] = "*(odd\\*)\\group,name";
const char odd_netgroupname[] = "*(odd\\*)\\netgroup,name";
const char *received_user;
const char *received_group;
static const char *user_attrs[] = SYSDB_PW_ATTRS;
static const char *netgr_attrs[] = SYSDB_NETGR_ATTRS;
/* Setup */
fail("Could not set up the test");
return;
}
/* ===== Groups ===== */
/* Add */
/* Retrieve */
"Expected [%s], got [%s]",
/* ===== Users ===== */
/* Add */
10000, 10000,
"","","");
/* Retrieve */
"Expected [%s] got [%s]\n",
/* Add to the group */
"Expected [%s], got [%s]",
/* Attributes */
/* Delete User */
/* Delete Group */
/* ===== Netgroups ===== */
/* Add */
odd_netgroupname, "No description",
/* Retrieve */
odd_netgroupname, &res);
/* ===== Arbitrary Entries ===== */
}
/* == SERVICE TESTS == */
bool by_name,
const char *primary_name,
int port,
const char **aliases,
const char **protocols)
{
unsigned int i, j;
bool matched;
const char *ret_name;
int ret_port;
struct ldb_result *res;
struct ldb_message *msg;
struct ldb_message_element *el;
if (by_name) {
/* Look up the service by name */
} else {
/* Look up the newly-added service by port */
}
/* Make sure the returned entry matches */
for (i = 0; i < el->num_values; i++) {
matched = false;
for (j = 0; aliases[j]; j++) {
matched = true;
}
}
}
for (i = 0; i < el->num_values; i++) {
matched = false;
for (j = 0; protocols[j]; j++) {
matched = true;
}
}
}
}
do { \
} while(0);
do { \
} while(0);
const char *primary_name,
int port,
const char **aliases,
const char **protocols,
{
struct sysdb_test_ctx *test_ctx;
char *primary_name;
const char **aliases;
const char **protocols;
int port = 3890;
/* Setup */
NULL);
/* Search by name and make sure the results match */
/* Search by port and make sure the results match */
/* Clean up after ourselves (and test deleting by name)
*
* We have to do this after the transaction, because LDB
* doesn't like adding and deleting the same entry in a
* single transaction.
*/
}
{
struct sysdb_test_ctx *test_ctx;
const char *primary_name = "test_store_service";
const char *alt_primary_name = "alt_test_store_service";
const char **aliases;
const char **protocols;
int port = 3890;
int altport = 3891;
/* Setup */
/* Store this group (which will add it) */
/* Search by name and make sure the results match */
/* Search by port and make sure the results match */
/* Change the service name */
/* Search by port and make sure the results match */
/* Change it back */
/* Change the port number */
/* Search by name and make sure the results match */
/* Search by port and make sure the results match */
/* TODO: Test changing aliases and protocols */
/* Clean up after ourselves (and test deleting by port)
*
* We have to do this after the transaction, because LDB
* doesn't like adding and deleting the same entry in a
* single transaction.
*/
}
const char *alias);
{
struct sysdb_test_ctx *test_ctx;
const char *primary_name = "remove_alias_test";
const char **aliases;
const char **protocols;
int port = 3990;
/* Setup */
NULL);
/* Search by name and make sure the results match */
/* Search by port and make sure the results match */
/* Now remove an alias */
/* Set aliases[1] to NULL to perform validation checks */
/* Search by name and make sure the results match */
/* Search by port and make sure the results match */
}
{
struct sysdb_test_ctx *test_ctx;
bool enumerated;
/* Setup */
true);
/* Recheck enumeration status */
&enumerated);
}
{
struct sysdb_test_ctx *test_ctx;
const char *filter;
struct ldb_message **msgs;
/* Setup */
"case_sensitive_group1", 29000,
"cn=case_sensitive_group1,cn=example,cn=com",
true, 0);
"case_sensitive_group2", 29001,
"cn=CASE_SENSITIVE_GROUP1,cn=EXAMPLE,cn=COM",
true, 0);
/* Search by originalDN should yield 2 entries */
"cn=case_sensitive_group1,cn=example,cn=com");
"case insensitive originalDN search");
}
{
struct sysdb_test_ctx *test_ctx;
int num_subdom1 = 1;
int num_subdom2 = 1;
"Unexpected sub-domain found, expected [%s], got [%s]",
"Unexpected sub-domain found, expected [%s], got [%s]",
}
{
struct sysdb_test_ctx *test_ctx;
int num_subdom = 1;
"name=subdomuser,cn=users,cn=test.sub,cn=sysdb");
"expected [%d], got [%d]",
"Unexpedted DN returned");
"expected [%d], got [%d]",
}
{
struct sysdb_test_ctx *test_ctx;
int num_subdom = 1;
"name=subdomuser,cn=users,cn=test.sub,cn=sysdb");
&msg);
"Unexpedted DN returned");
"Unexpedted DN returned");
}
{
struct sysdb_test_ctx *test_ctx;
int num_subdom = 1;
"name=subdomgroup,cn=groups,cn=test.sub,cn=sysdb");
&msg);
"Unexpedted DN returned");
"Unexpedted DN returned");
}
#ifdef BUILD_AUTOFS
{
struct sysdb_test_ctx *test_ctx;
const char *autofsmapname;
autofsmapname, NULL, 0, 0);
}
{
struct sysdb_test_ctx *test_ctx;
const char *autofsmapname;
autofsmapname, &map);
}
{
struct sysdb_test_ctx *test_ctx;
const char *autofsmapname;
}
{
struct sysdb_test_ctx *test_ctx;
const char *autofsmapname;
autofsmapname, &map);
}
{
struct sysdb_test_ctx *test_ctx;
const char *autofsmapname;
const char *autofskey;
const char *autofsval;
int ii;
const int limit = 10;
autofsmapname, ii);
}
}
{
struct sysdb_test_ctx *test_ctx;
const char *autofsmapname;
struct ldb_message **entries;
const int expected = 10;
}
{
struct sysdb_test_ctx *test_ctx;
const char *autofsmapname;
const char *autofskey;
const char *autofsval;
}
{
struct sysdb_test_ctx *test_ctx;
const char *autofskey;
const char *attrs[] = { SYSDB_AUTOFS_ENTRY_KEY,
NULL };
struct ldb_message **msgs;
const char *filter;
const int expected = 10;
}
#endif /* BUILD_AUTOFS */
Suite *create_sysdb_suite(void)
{
/* Create a new user */
/* Verify the users were added */
/* Create a new group */
/* Verify the groups were added */
/* sysdb_group_dn_name returns the name of the group in question */
/* sysdb_store_user allows setting attributes for existing users */
/* test the change */
/* Add and remove users in a group with sysdb_update_members */
/* Remove the other half by gid */
/* Remove the other half by uid */
/* Create a new user */
/* Verify the users were added */
/* Verify the users can be queried by UID */
/* Enumerate the users */
/* Change their attribute */
/* Verify the change */
/* Create a new group */
/* Verify the groups were added */
/* Verify the groups can be queried by GID */
/* Enumerate the groups */
/* Add some members to the groups */
/* Authenticate with missing cached password */
27010, 27011);
/* Add a cached password */
/* Authenticate against cached password */
27010, 27011);
/* ASQ search test */
/* Test search with more than one result */
/* Remove the members from the groups */
/* Remove the users by name */
/* Remove the groups by name */
/* test the ignore_not_found parameter for users */
/* test the ignore_not_found parameter for groups */
/* Create incomplete groups - remove will fail if the LDB objects don't exist */
/* test custom operations */
/* test recursive delete */
/* Test unusual characters */
/* Test sysdb enumerated flag */
/* Test originalDN searches */
/* Test user and group renames */
/* ===== NETGROUP TESTS ===== */
/* Create a new netgroup */
/* Verify the netgroups were added */
/* Test setting attributes */
/* Verify they have been changed */
/* Add some tuples */
/* Add a nested netgroup */
/* Remove the nested netgroup */
/* Remove the tuples */
/* Remove half of them by name */
/* Remove the other half by DN */
/* ===== SERVICE TESTS ===== */
/* Create a new service */
/* Add all test cases to the test suite */
suite_add_tcase(s, tc_sysdb);
0, 10);
0, 10);
0, 10);
0, 10);
0, 10);
0, 10);
#ifdef BUILD_AUTOFS
suite_add_tcase(s, tc_autofs);
#endif
return s;
}
int opt;
int ret;
int failure_count;
int no_cleanup = 0;
struct poptOption long_options[] = {
_("Do not delete the test database after a test run"), NULL },
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
return EXIT_FAILURE;
}
/* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
if (failure_count == 0 && !no_cleanup) {
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}