test_ipa_subdomains_server.c revision eca74a9559ce1b0f123c14906ad8394fc303f468
/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2015 Red Hat
SSSD tests: IPA subdomain server utils 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 <stdlib.h>
#include <ifaddrs.h>
#include "providers/ipa/ipa_subdomains.h"
#include "providers/ipa/ipa_opts.h"
#include "providers/data_provider.h"
#include "tests/cmocka/common_mock.h"
#include "tests/cmocka/common_mock_resp.h"
#include "tests/cmocka/common_mock_krb5.h"
#include "tests/cmocka/common_mock_sdap.h"
#include "tests/cmocka/common_mock_be.h"
#define DOM_REALM "DOM.MAIN"
#define HOSTNAME "ipaserver.dom.main"
#define DOM_FLAT "DOM"
#define SUBDOM_NAME "twoway.subdom.test"
#define SUBDOM_REALM "TWOWAY.SUBDOM.TEST"
#define SUBDOM_FLAT "TWOWAY"
#define SUBDOM_SID "S-1-2-3"
#define CHILD_FLAT "CHILD"
#define CHILD_SID "S-1-2-3-4"
#define TESTS_PATH "tests_ipa_subdom_server"
#define TEST_CONF_DB "test_ipa_subdom_server.ldb"
#define TEST_DOM_NAME "ipa_subdom_server_test"
#define TEST_ID_PROVIDER "ipa"
{
}
static void create_dummy_keytab(void)
{
assert_int_equal(ret, 0);
}
{
_exit(0);
}
{
_exit(0);
}
struct trust_test_ctx {
struct sss_test_ctx *tctx;
struct ipa_id_ctx *ipa_ctx;
};
struct sss_test_ctx *tctx,
const char *krb5_realm,
const char *hostname)
{
struct ipa_id_ctx *ipa_ctx;
struct sdap_options);
IPA_SERVER_MODE, true);
return ipa_ctx;
}
{
struct ipa_server_mode_ctx *server_mode;
return server_mode;
}
{
/* Add two subdomains */
true, false, SUBDOM_REALM,
true, false, SUBDOM_REALM,
}
{
}
{
}
static int test_ipa_server_create_trusts_setup(void **state)
{
struct trust_test_ctx *test_ctx;
struct sss_test_conf_param params[] = {
};
struct trust_test_ctx);
return 0;
}
static int test_ipa_server_create_trusts_teardown(void **state)
{
struct trust_test_ctx *test_ctx =
assert_int_equal(ret, 0);
/* Ignore failures */
return 0;
}
static void test_ipa_server_create_trusts(void **state)
{
struct trust_test_ctx *test_ctx =
struct tevent_req *req;
}
{
struct trust_test_ctx *test_ctx = \
/* Add two subdomains */
}
const char *dom_name,
const char *dom_realm,
const char *sid,
const char *keytab,
const char *authid,
const char *sdap_realm)
{
const char *s;
assert_non_null(s);
} else {
assert_null(s);
}
assert_non_null(s);
} else {
assert_null(s);
}
/* the system keytab is always used with two-way trusts */
assert_non_null(s);
} else {
assert_null(s);
}
if (sdap_realm != NULL) {
assert_non_null(s);
} else {
assert_null(s);
}
assert_non_null(s);
} else {
assert_null(s);
}
}
{
struct trust_test_ctx *test_ctx = \
struct sss_domain_info *child_dom;
/* Trust object should be around now */
/* Two-way trusts should use the system realm */
NULL,
NULL,
/* No more trust objects */
NULL,
}
static void
struct tevent_timer *te,
{
struct trust_test_ctx *test_ctx =
}
static void test_ipa_server_trust_init(void **state)
{
struct trust_test_ctx *test_ctx =
struct tevent_timer *timeout_handler;
/* Trust object should be around now */
/* Two-way trusts should use the system realm */
NULL,
NULL,
/* No more trust objects */
}
struct dir_test_ctx {
struct ldb_context *ldb;
struct sysdb_attrs *tdo;
};
static int test_get_trust_direction_setup(void **state)
{
struct dir_test_ctx *test_ctx;
struct dir_test_ctx);
return 0;
}
static int test_get_trust_direction_teardown(void **state)
{
struct dir_test_ctx *test_ctx =
return 0;
}
/* These are stupid tests, but test real data */
{
}
static void test_get_trust_direction_inbound(void **state)
{
struct dir_test_ctx *test_ctx =
}
static void test_get_trust_direction_outbound(void **state)
{
struct dir_test_ctx *test_ctx =
}
static void test_get_trust_direction_twoway(void **state)
{
struct dir_test_ctx *test_ctx =
}
static void test_get_trust_direction_notset_root(void **state)
{
struct dir_test_ctx *test_ctx =
"cn=AD.DOM,cn=ad,cn=trusts,dc=example,dc=com");
/* With root domains we assume two-way trust */
}
static void test_get_trust_direction_notset_member(void **state)
{
struct dir_test_ctx *test_ctx =
"cn=SUB.AD.DOM,cn=AD.DOM,cn=ad,cn=trusts,dc=example,dc=com");
/* With members we set zero and take a look at the parent */
assert_int_equal(dir, 0);
}
static void test_ipa_server_create_oneway(void **state)
{
struct trust_test_ctx *test_ctx =
struct tevent_req *req;
assert_int_not_equal(ret, 0);
}
{
struct trust_test_ctx *test_ctx = \
assert_int_equal(ret, 0);
/* Trust object should be around now */
CHILD_NAME, /* AD domain name */
CHILD_REALM, /* AD realm can be child if SDAP realm is parent's */
ONEWAY_KEYTAB, /* Keytab shared with parent AD dom */
ONEWAY_PRINC, /* Principal shared with parent AD dom */
SUBDOM_REALM); /* SDAP realm must be AD root domain */
/* Here all properties point to the AD domain */
}
static void test_ipa_server_create_oneway_kt_exists(void **state)
{
struct trust_test_ctx *test_ctx =
struct tevent_req *req;
assert_int_equal(ret, 0);
}
static void test_ipa_server_trust_oneway_init(void **state)
{
struct trust_test_ctx *test_ctx =
struct tevent_timer *timeout_handler;
}
static void test_ipa_trust_dir2str(void **state)
{
/* Just make sure the caller can rely on getting a valid string.. */
}
{
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;
}