test_ad_common.c revision 60e54ce78177b72ae82b8986e37dc4d09fce5681
/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2013 Red Hat
SSSD tests: AD access control filter tests
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 <unistd.h>
#include <ifaddrs.h>
#include "util/crypto/sss_crypto.h"
#ifdef HAVE_NSS
#include "util/crypto/nss/nss_util.h"
#endif
#include "util/util_sss_idmap.h"
/* In order to access opaque types */
#include "providers/ad/ad_common.c"
#include "tests/cmocka/common_mock.h"
#include "tests/cmocka/common_mock_krb5.h"
#define DOMNAME "domname"
#define ONEWAY_DOMNAME "ONEWAY"
#define TEST_CONF_DB "test_ad_sysdb.ldb"
#define TEST_ID_PROVIDER "ad"
#define TEST_DOM1_NAME "test_sysdb_subdomains_1"
#define TEST_DOM2_NAME "child2.test_sysdb_subdomains_2"
#define TEST_USER "test_user"
static bool call_real_sasl_options;
const char *domains[] = { TEST_DOM1_NAME,
NULL };
struct ad_sysdb_test_ctx {
struct sss_test_ctx *tctx;
};
static int test_ad_sysdb_setup(void **state)
{
struct ad_sysdb_test_ctx *test_ctx;
struct sss_test_conf_param params[] = {
};
struct ad_sysdb_test_ctx);
return 0;
}
static int test_ad_sysdb_teardown(void **state)
{
struct ad_sysdb_test_ctx *test_ctx =
return 0;
}
static void test_check_if_pac_is_available(void **state)
{
int ret;
struct ad_sysdb_test_ctx *test_ctx =
struct be_acct_req *ar;
struct sysdb_attrs *attrs;
/* PAC available but too old */
/* PAC available but still too old */
/* PAC available but still too old */
}
#define TEST_PAC_BASE64 \
"BQAAAAAAAAABAAAA6AEAAFgAAAAAAAAACgAAABAAAABAAgAAAA" \
"AAAAwAAAA4AAAAUAIAAAAAAAAGAAAAFAAAAIgCAAAAAAAABwAA" \
"ABQAAACgAgAAAAAAAAEQCADMzMzM2AEAAAAAAAAAAAIA2hr35p" \
"Ji0QH/////////f/////////9/4veKrwAP0AHit/TZyQ/QAf//" \
"//////9/BgAGAAQAAgAGAAYACAACAAAAAAAMAAIAAAAAABAAAg" \
"AAAAAAFAACAAAAAAAYAAIATwAAAFAEAAABAgAABQAAABwAAgAg" \
"AAAAAAAAAAAAAAAAAAAAAAAAABIAFAAgAAIABAAGACQAAgAoAA" \
"IAAAAAAAAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \
"AAAAAAEAAAAsAAIAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAdA" \
"B1ADEAAAADAAAAAAAAAAMAAAB0ACAAdQAAAAAAAAAAAAAAAAAA" \
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \
"UAAAD9ogAABwAAAAECAAAHAAAAXAQAAAcAAABWBAAABwAAAImm" \
"AAAHAAAACgAAAAAAAAAJAAAAQQBEAC0AUwBFAFIAVgBFAFIAAA" \
"ADAAAAAAAAAAIAAABBAEQABAAAAAEEAAAAAAAFFQAAAPgSE9xH" \
"8xx2Ry8u1wEAAAAwAAIABwAAAAUAAAABBQAAAAAABRUAAAApyU" \
"AAAAAAAAAAB0AHUAMQBAAGEAZAAuAGQAZQB2AGUAbABBAEQALg" \
"BEAEUAVgBFAEwAdv///4yBQZ5ZQnp3qwj2lKGcd0UAAAAAdv//" \
"/39fn4UneD5l6YxP8w/U0coAAAAA"
static void test_ad_get_data_from_pac(void **state)
{
int ret;
struct PAC_LOGON_INFO *logon_info;
struct ad_common_test_ctx);
&logon_info);
}
static void test_ad_get_sids_from_pac(void **state)
{
int ret;
struct PAC_LOGON_INFO *logon_info;
char *user_sid;
char *primary_group_sid;
char **sid_list;
struct sss_idmap_ctx *idmap_ctx;
enum idmap_error_code err;
size_t c;
size_t s;
const char *sid_check_list[] = { "S-1-5-21-3692237560-1981608775-3610128199-513",
"S-1-5-21-3692237560-1981608775-3610128199-1110",
"S-1-5-21-3692237560-1981608775-3610128199-1116",
"S-1-5-21-3692237560-1981608775-3610128199-41725",
"S-1-5-21-3692237560-1981608775-3610128199-42633",
"S-1-5-21-3645884713-2026060994-4169618742-1108",
NULL };
struct ad_common_test_ctx);
&idmap_ctx);
&logon_info);
"S-1-5-21-3692237560-1981608775-3610128199-1104");
"S-1-5-21-3692237560-1981608775-3610128199-513");
for (c = 0; sid_check_list[c] != NULL; c++) {
for (s = 0; s < num_sids; s++) {
break;
}
}
if (s == num_sids) {
}
}
}
static void test_ad_get_pac_data_from_user_entry(void **state)
{
int ret;
struct ldb_message *user_msg;
struct ad_common_test_ctx);
struct sss_idmap_ctx *idmap_ctx;
enum idmap_error_code err;
char *username;
char *user_sid;
char *primary_group_sid;
char **sid_list;
size_t c;
size_t s;
const char *sid_check_list[] = { "S-1-5-21-3692237560-1981608775-3610128199-513",
"S-1-5-21-3692237560-1981608775-3610128199-1110",
"S-1-5-21-3692237560-1981608775-3610128199-1116",
"S-1-5-21-3692237560-1981608775-3610128199-41725",
"S-1-5-21-3692237560-1981608775-3610128199-42633",
"S-1-5-21-3645884713-2026060994-4169618742-1108",
NULL };
&idmap_ctx);
&sid_list);
"S-1-5-21-3692237560-1981608775-3610128199-1104");
"S-1-5-21-3692237560-1981608775-3610128199-513");
for (c = 0; sid_check_list[c] != NULL; c++) {
for (s = 0; s < num_sids; s++) {
break;
}
}
if (s == num_sids) {
}
}
}
{
}
struct ad_common_test_ctx {
struct ad_id_ctx *subdom_ad_ctx;
struct sss_domain_info *dom;
struct sss_domain_info *subdom;
};
static void test_ad_create_default_options(void **state)
{
struct ad_options *ad_options;
const char *s;
/* Not too much to test here except some defaults */
assert_null(s);
}
static int test_ad_common_setup(void **state)
{
struct ad_common_test_ctx *test_ctx;
return 0;
}
static int test_ad_common_teardown(void **state)
{
int ret;
struct ad_common_test_ctx);
return 0;
}
static void test_ad_create_1way_trust_options(void **state)
{
struct ad_common_test_ctx);
const char *s;
call_real_sasl_options = true;
/* Make sure this is not the keytab that __wrap_krb5_kt_default uses */
assert_non_null(s);
assert_non_null(s);
assert_non_null(s);
assert_non_null(s);
assert_non_null(s);
assert_non_null(s);
assert_non_null(s);
assert_non_null(s);
}
static void test_ad_create_2way_trust_options(void **state)
{
struct ad_common_test_ctx);
const char *s;
call_real_sasl_options = true;
assert_non_null(s);
assert_non_null(s);
assert_non_null(s);
assert_null(s); /* This is the system keytab */
assert_non_null(s);
assert_non_null(s);
assert_non_null(s);
}
static int
test_ldap_conn_setup(void **state)
{
struct ad_common_test_ctx *test_ctx;
struct sdap_domain *sdom;
struct ad_id_ctx *subdom_ad_ctx;
struct sdap_id_conn_ctx *subdom_ldap_ctx;
struct sdap_options);
return 0;
}
static int
test_ldap_conn_teardown(void **state)
{
struct ad_common_test_ctx);
test_ad_common_teardown((void **) &test_ctx);
return 0;
}
char *default_primary,
char *default_realm,
const char *keytab_path);
char *default_primary,
char *default_realm,
const char *keytab_path)
{
/* Pretend SASL is fine */
if (call_real_sasl_options == true) {
return __real_sdap_set_sasl_options(id_opts,
}
return EOK;
}
void test_ad_get_dom_ldap_conn(void **state)
{
struct sdap_id_conn_ctx *conn;
struct ad_common_test_ctx);
}
void test_gc_conn_list(void **state)
{
struct sdap_id_conn_ctx **conn_list;
struct ad_common_test_ctx);
AD_ENABLE_GC));
/* If there is a fallback, we should ignore the offline mode */
/* Subdomain error should not set the backend offline! */
AD_ENABLE_GC));
}
void test_ldap_conn_list(void **state)
{
struct sdap_id_conn_ctx **conn_list;
struct ad_common_test_ctx);
}
void test_user_conn_list(void **state)
{
struct sdap_id_conn_ctx **conn_list;
struct ad_common_test_ctx);
/* Subdomain error should not set the backend offline! */
}
{
int opt;
int ret;
struct poptOption long_options[] = {
};
const struct CMUnitTest tests[] = {
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
#ifdef HAVE_NSS
/* Cleanup NSS and NSPR to make valgrind happy. */
#endif
return ret;
}