/*
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"
#include "providers/ldap/ldap_opts.h"
const char *module_name,
...)
{
return true;
}
/* put users and groups under the same container so we can easily run the
* same tests cases for several search base scenarios */
struct nested_groups_test_ctx {
unsigned long num_users;
unsigned long num_groups;
/* External members tests */
};
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]);
}
}
{
&ctx->missing_external);
}
{
"rootgroup", NULL);
/* mock return values */
/* run test, check for memory leaks */
/* check return code */
/* check generated values */
}
{
"cn=user2,"USER_BASE_DN,
NULL };
"user2" };
/* mock return values */
"rootgroup", users);
/* run test, check for memory leaks */
/* check return code */
/* Check the users */
}
{
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 */
}
{
"cn=emptygroup2,"GROUP_BASE_DN,
NULL };
"emptygroup1",
"emptygroup2" };
/* mock return values */
"rootgroup", groups);
/* run test, check for memory leaks */
/* check return code */
/* Check the users */
}
{
"cn=emptygroup1,"GROUP_BASE_DN,
NULL };
"emptygroup1" };
/* mock return values */
"rootgroup", groups);
/* run test, check for memory leaks */
/* check return code */
}
{
"cn=group1,"GROUP_BASE_DN,
NULL };
"cn=group2,"GROUP_BASE_DN,
NULL };
NULL };
/* mock return values */
"rootgroup", rootgroup_members);
1001, "group1",
1002, "group2",
/* run test, check for memory leaks */
/* check return code */
/* Check the users */
}
{
NULL };
NULL };
NULL };
/* mock return values */
"rootgroup", rootgroup_members);
1001, "group1",
1002, "group2",
/* run test, check for memory leaks */
/* check return code */
}
{
{ "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;
}
{
return 0;
}
struct test_ext_pvt {
};
struct test_ext_member {
const char *sid;
const char *short_name;
} test_ext_member_table[] = {
{ "S-1-5-21-3623811015-3361044348-30300820-10001",
{ "S-1-5-21-3623811015-3361044348-30300820-20001",
};
struct test_resolve_ext_state {
};
struct sss_domain_info *dom,
const char *name,
enum sysdb_member_type member_type,
struct sysdb_attrs **_member);
struct tevent_context *ev,
const char *ext_member,
void *pvt)
{
return NULL;
}
&member);
goto immediate;
}
goto immediate;
}
}
} else {
}
return req;
}
struct sss_domain_info *dom,
const char *name,
enum sysdb_member_type member_type,
struct sysdb_attrs **_member)
{
char *home;
char *fqdn;
return ENOMEM;
}
goto done;
}
if (member_type == SYSDB_MEMBER_USER) {
goto done;
}
goto done;
}
goto done;
}
} else if (member_type == SYSDB_MEMBER_GROUP) {
goto done;
}
goto done;
}
} else {
goto done;
}
goto done;
}
done:
return ret;
}
struct tevent_req *req,
enum sysdb_member_type *_member_type,
struct sss_domain_info **_dom,
struct sysdb_attrs **_member)
{
struct test_resolve_ext_state);
if (_member_type != NULL) {
}
if (_dom) {
}
}
return EOK;
}
{
int ret;
assert_int_equal(ret, 0);
return 0;
}
{
struct nested_groups_test_ctx);
char *fqdn;
int i;
return 1;
}
return 1;
}
switch (test_ext_member_table[i].member_type) {
case SYSDB_MEMBER_USER:
fqdn, 0);
break;
case SYSDB_MEMBER_GROUP:
fqdn, 0);
break;
default:
continue;
}
return 1;
}
}
return nested_groups_test_setup(*state);
}
{
}
static struct sysdb_attrs *
const char *name,
const char *ext_members[])
{
int i;
const struct sysdb_attrs *,
2);
if (ext_group_reply == NULL) {
return NULL;
}
SYSDB_GIDNUM, gid);
return NULL;
}
for (i = 0; ext_members[i] != NULL; i++) {
ext_members[i]);
return NULL;
}
}
ext_group_reply[0] = ext_group;
return ext_group;
}
static errno_t
struct sysdb_attrs *ldap_attrs,
{
const char *s;
char *fqdn_gr;
if (sysdb_grattrs == NULL) {
return ENOMEM;
}
return ret;
}
return ret;
}
return ENOMEM;
}
return ret;
}
return EOK;
}
static errno_t
const char *shortname_parent,
const char *shortname_child)
{
char *fqdn_parent;
char *fqdn_child;
if (fqdn_parent == NULL) {
return ENOMEM;
}
if (fqdn_child == NULL) {
return ENOMEM;
}
SYSDB_MEMBER_GROUP, false);
return ret;
}
struct ldb_message *msg,
const char *shortname)
{
const char *s;
char *fqname;
}
const char *member_name,
const char *exp_member_name)
{
const char *s;
char *fqname;
fqname);
assert_non_null(s);
}
{
struct nested_groups_test_ctx);
const char *rootgroup_members[] = {
"cn=nested_group,"GROUP_BASE_DN,
"cn=extgroup,"GROUP_BASE_DN,
};
const char *nestedgroup_members[] = {
"cn=extgroup_nested,"GROUP_BASE_DN,
};
const char *extgroup_members[] = {
"S-1-5-21-3623811015-3361044348-30300820-10001",
};
const char *extgroup_nested_members[] = {
"S-1-5-21-3623811015-3361044348-30300820-10001",
"S-1-5-21-3623811015-3361044348-30300820-20001",
};
};
char *fqdn;
/* LDAP provider doesn't support external groups by default */
/* run test, check for memory leaks */
/* Save the groups to sysdb so that external membership code can link
* external members against this group
*/
&rootgroup);
&ext_group);
&nested_group);
/* Resolve external members */
/* Make sure that extuser1001 is a member of rootgroup now */
fqdn,
&msg);
}
{
int ret;
char *ep_filter;
}
{
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;
}
}
/* 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;
}