test_nested_groups.c revision 50c9d542e8bf641412debaa82a4dcf67ddb72258
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2013 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 <talloc.h>
#include <tevent.h>
#include <errno.h>
#include <popt.h>
#include "tests/cmocka/common_mock.h"
#include "tests/cmocka/common_mock_sdap.h"
#include "tests/cmocka/common_mock_be.h"
#include "tests/cmocka/common_mock_sysdb_objects.h"
#include "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_idmap.h"
#include "providers/ldap/sdap_async_private.h"
#define TEST_CONF_DB "test_ldap_nested_groups_conf.ldb"
#define TEST_DOM_NAME "ldap_nested_groups_test"
#define TEST_ID_PROVIDER "ldap"
/* put users and groups under the same container so we can easily run the
* same tests cases for several search base scenarios */
#define OBJECT_BASE_DN "cn=objects,dc=test,dc=com"
struct nested_groups_test_ctx {
struct sss_test_ctx *tctx;
struct sdap_options *sdap_opts;
struct sdap_handle *sdap_handle;
struct sdap_domain *sdap_domain;
struct sdap_idmap_ctx *idmap_ctx;
struct sdap_id_ctx *sdap_id_ctx;
struct sysdb_attrs **users;
struct sysdb_attrs **groups;
unsigned long num_users;
unsigned long num_groups;
};
const char *conf_path,
int opt_id)
{
return EOK;
}
/* Both arrays must have the same length! */
const char **string_array,
{
int i, ii;
const char *name;
/* Check the returned groups. The order is irrelevant. */
for (i = 0; i < len; i++) {
continue;
}
break;
}
}
}
for (i = 0; i < len; i++) {
assert_null(string_array[i]);
}
}
{
}
static void nested_groups_test_one_group_no_members(void **state)
{
"rootgroup", NULL);
/* mock return values */
/* run test, check for memory leaks */
/* check return code */
/* check generated values */
}
static void nested_groups_test_one_group_unique_members(void **state)
{
"cn=user2,"USER_BASE_DN,
NULL };
const char * expected[] = { "user1",
"user2" };
/* mock return values */
"rootgroup", users);
/* run test, check for memory leaks */
/* check return code */
/* Check the users */
}
static void nested_groups_test_one_group_dup_users(void **state)
{
const char *name;
"cn=user1,"USER_BASE_DN,
NULL };
/* mock return values */
"rootgroup", users);
/* run test, check for memory leaks */
/* check return code */
/* Check the users */
}
static void nested_groups_test_one_group_unique_group_members(void **state)
{
"cn=emptygroup2,"GROUP_BASE_DN,
NULL };
const char * expected[] = { "rootgroup",
"emptygroup1",
"emptygroup2" };
/* mock return values */
"rootgroup", groups);
/* run test, check for memory leaks */
/* check return code */
/* Check the users */
}
static void nested_groups_test_one_group_dup_group_members(void **state)
{
"cn=emptygroup1,"GROUP_BASE_DN,
NULL };
const char * expected[] = { "rootgroup",
"emptygroup1" };
/* mock return values */
"rootgroup", groups);
/* run test, check for memory leaks */
/* check return code */
}
static void nested_groups_test_nested_chain(void **state)
{
"cn=group1,"GROUP_BASE_DN,
NULL };
"cn=group2,"GROUP_BASE_DN,
NULL };
NULL };
struct sysdb_attrs *rootgroup;
/* mock return values */
"rootgroup", rootgroup_members);
1001, "group1",
1002, "group2",
/* run test, check for memory leaks */
/* check return code */
/* Check the users */
}
static void nested_groups_test_nested_chain_with_error(void **state)
{
NULL };
NULL };
NULL };
struct sysdb_attrs *rootgroup;
/* mock return values */
"rootgroup", rootgroup_members);
1001, "group1",
1002, "group2",
/* run test, check for memory leaks */
/* check return code */
}
static int nested_groups_test_setup(void **state)
{
static struct sss_test_conf_param params[] = {
{ "ldap_schema", "rfc2307bis" }, /* enable nested groups */
{ "ldap_search_base", OBJECT_BASE_DN },
{ "ldap_user_search_base", USER_BASE_DN },
{ "ldap_group_search_base", GROUP_BASE_DN },
};
/* initialize domain */
/* mock SDAP */
return 0;
}
static int nested_groups_test_teardown(void **state)
{
return 0;
}
{
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;
}
}
/* Even though normally the tests should clean up after themselves
* they might not after a failed run. Remove the old db to be sure */
if (rv == 0 && !no_cleanup) {
}
return rv;
}