summaryrefslogtreecommitdiffstats
path: root/src/tests/common_dom.c
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2014-11-04 14:50:45 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-01-09 15:15:59 +0100
commitacc1c0c07fc76bc05d91c0bd2f172cd638ff3546 (patch)
treea4d45c2ff0200ae068566775dd02ecb573830732 /src/tests/common_dom.c
parentdbb990fb29e7178a3cce53474e48ce69ab3a97a0 (diff)
downloadsssd-acc1c0c07fc76bc05d91c0bd2f172cd638ff3546.tar.gz
sssd-acc1c0c07fc76bc05d91c0bd2f172cd638ff3546.tar.xz
sssd-acc1c0c07fc76bc05d91c0bd2f172cd638ff3546.zip
tests: add create_multidom_test_ctx()
This will allow to create a multi domain test environment. Reviewed-by: Michal Židek <mzidek@redhat.com>
Diffstat (limited to 'src/tests/common_dom.c')
-rw-r--r--src/tests/common_dom.c71
1 files changed, 50 insertions, 21 deletions
diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c
index 95732b4b8..f4fe0b66d 100644
--- a/src/tests/common_dom.c
+++ b/src/tests/common_dom.c
@@ -213,15 +213,18 @@ done:
}
struct sss_test_ctx *
-create_dom_test_ctx(TALLOC_CTX *mem_ctx,
- const char *tests_path,
- const char *confdb_path,
- const char *domain_name,
- const char *id_provider,
- struct sss_test_conf_param *params)
+create_multidom_test_ctx(TALLOC_CTX *mem_ctx,
+ const char *tests_path,
+ const char *cdb_file,
+ const char **domains,
+ const char *id_provider,
+ struct sss_test_conf_param *params)
{
- struct sss_test_ctx *test_ctx;
+ struct sss_domain_info *domain = NULL;
+ struct sss_test_ctx *test_ctx = NULL;
+ char *cdb_path = NULL;
errno_t ret;
+ int i;
test_ctx = create_ev_test_ctx(mem_ctx);
if (test_ctx == NULL) {
@@ -229,32 +232,43 @@ create_dom_test_ctx(TALLOC_CTX *mem_ctx,
goto fail;
}
- ret = mock_confdb(test_ctx, tests_path, confdb_path, &test_ctx->confdb);
+ ret = mock_confdb(test_ctx, tests_path, cdb_file, &test_ctx->confdb);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize confdb [%d]: %s\n",
ret, sss_strerror(ret));
goto fail;
}
- ret = mock_confdb_domain(test_ctx, test_ctx->confdb, tests_path,
- domain_name, id_provider, params,
- &test_ctx->conf_dom_path);
- if (ret != EOK) {
- DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize confdb domain "
- "[%d]: %s\n", ret, sss_strerror(ret));
- goto fail;
+ /* create confdb objects for the domains */
+ for (i = 0; domains[i] != NULL; i++) {
+ ret = mock_confdb_domain(test_ctx, test_ctx->confdb, tests_path,
+ domains[i], id_provider, params,
+ (cdb_path == NULL ? &cdb_path : NULL));
+ if (ret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize confdb domain "
+ "[%d]: %s\n", ret, sss_strerror(ret));
+ goto fail;
+ }
}
- ret = mock_domain(test_ctx, test_ctx->confdb, tests_path, domain_name,
- &test_ctx->dom);
- if (ret != EOK) {
- DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize sss domain "
- "[%d]: %s\n", ret, sss_strerror(ret));
- goto fail;
+ /* initialize domain list and sysdb of the domains */
+ for (i = 0; domains[i] != NULL; i++) {
+ ret = mock_domain(test_ctx, test_ctx->confdb, tests_path, domains[i],
+ (domain == NULL ? &domain : NULL));
+ if (ret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "Unable to add new domain [%d]: %s\n",
+ ret, sss_strerror(ret));
+ goto fail;
+ }
}
+ /* the first domain we obtained is already head of the complete list */
+ test_ctx->dom = domain;
+
+ /* set data from the first domain */
test_ctx->sysdb = test_ctx->dom->sysdb;
test_ctx->nctx = test_ctx->dom->names;
+ test_ctx->conf_dom_path = cdb_path;
return test_ctx;
@@ -263,6 +277,21 @@ fail:
return NULL;
}
+
+struct sss_test_ctx *
+create_dom_test_ctx(TALLOC_CTX *mem_ctx,
+ const char *tests_path,
+ const char *confdb_path,
+ const char *domain_name,
+ const char *id_provider,
+ struct sss_test_conf_param *params)
+{
+ const char *domains[] = {domain_name, NULL};
+
+ return create_multidom_test_ctx(mem_ctx, tests_path, confdb_path, domains,
+ id_provider, params);
+}
+
void test_dom_suite_setup(const char *tests_path)
{
errno_t ret;