summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/providers/ad/ad_common.c18
-rw-r--r--src/providers/ad/ad_common.h2
-rw-r--r--src/tests/cmocka/test_ad_common.c17
3 files changed, 34 insertions, 3 deletions
diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c
index e945958fc..60b234dc2 100644
--- a/src/providers/ad/ad_common.c
+++ b/src/providers/ad/ad_common.c
@@ -108,9 +108,7 @@ fail:
}
struct ad_options *
-ad_create_2way_trust_options(TALLOC_CTX *mem_ctx,
- const char *realm,
- const char *hostname)
+ad_create_default_options(TALLOC_CTX *mem_ctx)
{
struct ad_options *ad_options;
errno_t ret;
@@ -134,6 +132,20 @@ ad_create_2way_trust_options(TALLOC_CTX *mem_ctx,
return NULL;
}
+ return ad_options;
+}
+
+struct ad_options *
+ad_create_2way_trust_options(TALLOC_CTX *mem_ctx,
+ const char *realm,
+ const char *hostname)
+{
+ struct ad_options *ad_options;
+ errno_t ret;
+
+ ad_options = ad_create_default_options(mem_ctx);
+ if (ad_options == NULL) return NULL;
+
ret = dp_opt_set_string(ad_options->basic, AD_KRB5_REALM, realm);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, "Cannot set AD domain\n");
diff --git a/src/providers/ad/ad_common.h b/src/providers/ad/ad_common.h
index 5be2bcd84..07b9d734f 100644
--- a/src/providers/ad/ad_common.h
+++ b/src/providers/ad/ad_common.h
@@ -103,6 +103,8 @@ ad_get_common_options(TALLOC_CTX *mem_ctx,
struct sss_domain_info *dom,
struct ad_options **_opts);
+struct ad_options *ad_create_default_options(TALLOC_CTX *mem_ctx);
+
struct ad_options *ad_create_2way_trust_options(TALLOC_CTX *mem_ctx,
const char *realm,
const char *hostname);
diff --git a/src/tests/cmocka/test_ad_common.c b/src/tests/cmocka/test_ad_common.c
index 0013d7833..de00e53f9 100644
--- a/src/tests/cmocka/test_ad_common.c
+++ b/src/tests/cmocka/test_ad_common.c
@@ -59,6 +59,22 @@ struct ad_common_test_ctx {
struct sss_domain_info *subdom;
};
+static void test_ad_create_default_options(void **state)
+{
+ struct ad_options *ad_options;
+ const char *s;
+
+ ad_options = ad_create_default_options(global_talloc_context);
+
+ assert_non_null(ad_options->basic);
+
+ /* Not too much to test here except some defaults */
+ s = dp_opt_get_string(ad_options->basic, AD_DOMAIN);
+ assert_null(s);
+
+ assert_non_null(ad_options->id);
+}
+
static int test_ad_common_setup(void **state)
{
struct ad_common_test_ctx *test_ctx;
@@ -318,6 +334,7 @@ int main(int argc, const char *argv[])
};
const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_ad_create_default_options),
cmocka_unit_test_setup_teardown(test_ad_create_2way_trust_options,
test_ad_common_setup,
test_ad_common_teardown),