/*
Authors:
Jakub Hrozek <jhrozek@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 <talloc.h>
#include <tevent.h>
#include <errno.h>
#include <popt.h>
#include "tests/cmocka/common_mock.h"
#include "providers/ldap/ldap_opts.h"
#include "providers/ipa/ipa_opts.h"
#include "util/crypto/sss_crypto.h"
/* mock an LDAP entry */
struct mock_ldap_attr {
const char *name;
const char **values;
};
struct mock_ldap_entry {
const char *dn;
};
static int mock_ldap_entry_iter(void)
{
return sss_mock_type(int);
}
{
return sss_mock_ptr_type(struct mock_ldap_entry *);
}
{
}
struct mock_ldap_entry *entry)
{
/* no attributes, done */
return dref;
}
}
} else {
}
}
return dref;
}
/* libldap wrappers */
int option,
void *invalue)
{
return LDAP_OPT_SUCCESS;
}
{
}
void __wrap_ldap_memfree(void *p)
{
return;
}
LDAP_CONST char *target)
{
const char **attrvals;
/* Should we return empty array here? */
break;
}
}
return NULL;
}
count = 0;
for (i = 0; attrvals[i]; i++) {
count++;
}
struct berval *,
count + 1);
for (i = 0; attrvals[i]; i++) {
assert_non_null(vals[i]);
return NULL;
}
}
return vals;
}
{
}
BerElement **berout)
{
}
{
char *val;
}
return val;
}
/* Mock parsing search base without overlinking the test */
struct sdap_search_base ***_search_bases)
{
return EOK;
}
/* Utility function */
const char *attr,
const char *value)
{
const char *v;
int ret;
assert_non_null(v);
assert_string_equal(v, value);
}
const char *attr)
{
int ret;
const char *v;
}
struct parse_test_ctx {
};
{
return 0;
}
{
struct parse_test_ctx);
return 0;
}
{
int ret;
struct parse_test_ctx);
};
&attrs, false);
/* Every entry has a DN */
"cn=testuser,dc=example,dc=com");
/* Test the single-valued attribute */
/* Multivalued attributes must return all values */
/* The SSH attribute must be base64 encoded */
&key_len);
/* The extra attribute must not be downloaded, it's not present in map */
}
/* Some searches, like rootDSE search do not use any map */
{
int ret;
struct parse_test_ctx);
};
"cn=testentry,dc=example,dc=com");
/* Multivalued attributes must return all values */
}
/* Only DN and OC, no real attributes */
{
int ret;
struct parse_test_ctx);
};
&attrs, false);
"cn=testuser,dc=example,dc=com");
}
{
int ret;
struct parse_test_ctx);
int i;
};
/* Set both uidNumber and gidNumber to idNumber */
for (i = 0; i < SDAP_OPTS_USER; i++) {
}
}
&attrs, false);
/* Every entry has a DN */
"cn=dupuser,dc=example,dc=com");
/* Test the single-valued attribute */
}
{
struct parse_test_ctx);
};
/* The extra attribute must not be downloaded, it's not present in map */
assert_non_null(res[0]);
"cn=testuser,dc=example,dc=com");
}
{
struct parse_test_ctx);
}
{
struct parse_test_ctx);
};
/* the group map didn't match, so no attrs will be parsed out of the map */
}
{
int ret;
struct parse_test_ctx);
};
&attrs, false);
}
/* Negative test - objectclass doesn't match the map */
{
int ret;
struct parse_test_ctx);
};
&attrs, false);
}
/* Negative test - the entry has no objectClass. Just make sure
* we don't crash
*/
{
int ret;
struct parse_test_ctx);
};
&attrs, false);
}
/* Negative test - the entry has no DN. Just make sure
* we don't crash and detect the failure.
*/
{
int ret;
struct parse_test_ctx);
};
&attrs, false);
}
struct copy_map_entry_test_ctx {
};
{
int ret;
struct copy_map_entry_test_ctx);
return 0;
}
{
struct copy_map_entry_test_ctx);
return 0;
}
{
}
{
struct copy_map_entry_test_ctx);
}
{
struct copy_map_entry_test_ctx);
}
struct test_sdap_inherit_ctx {
};
{
int ret;
return opts;
}
{
int ret;
struct test_sdap_inherit_ctx);
discard_const("test_princ");
SDAP_PURGE_CACHE_TIMEOUT, 123);
return 0;
}
{
return 0;
}
{
int val;
assert_int_equal(val, 0);
assert_int_equal(val, 0);
}
{
int val;
assert_int_equal(val, 0);
/* parent has nondefault, but it's not supposed to be inherited */
assert_int_equal(val, 0);
}
{
int val;
assert_int_equal(val, 0);
/* parent has nondefault, but it's not supposed to be inherited */
}
{
"krbPrincipalName");
/* parent has nondefault, but it's not supposed to be inherited */
"test_princ");
}
struct copy_dom_obj_test_ctx {
};
const char *name,
const char *basedn)
{
const char *orig_dn;
return obj;
}
struct sss_domain_info *dom)
{
NULL,
&sdom->search_bases[0]);
return sdom;
}
{
struct copy_dom_obj_test_ctx);
/* These two objects were 'returned by LDAP' */
struct sysdb_attrs *, 2);
/* This is the array we'll filter to */
struct sysdb_attrs *, 2);
return 0;
}
{
struct copy_dom_obj_test_ctx);
return 0;
}
{
struct copy_dom_obj_test_ctx);
0,
2, true);
1,
2, true);
}
{
struct copy_dom_obj_test_ctx);
0,
2, false);
}
{
int opt;
};
/* Negative tests */
/* Map option tests */
/* Option inherit tests */
/* Per-domain object filter tests */
};
/* 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 */
}