|
|
b2d430 |
From 4319dabb39ea91d1c1cd9fe5294e17706045bd48 Mon Sep 17 00:00:00 2001
|
|
|
b2d430 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
b2d430 |
Date: Mon, 11 Jul 2016 17:05:29 +0200
|
|
|
b2d430 |
Subject: [PATCH 40/44] tests: add tests for netlogon_get_domain_info
|
|
|
b2d430 |
|
|
|
b2d430 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
b2d430 |
---
|
|
|
b2d430 |
Makefile.am | 1 +
|
|
|
b2d430 |
src/tests/cmocka/test_ad_common.c | 81 +++++++++++++++++++++++++++++++++++++++
|
|
|
b2d430 |
2 files changed, 82 insertions(+)
|
|
|
b2d430 |
|
|
|
b2d430 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
b2d430 |
index d05919705910fa565ff954224ce40feb5d7ff39f..cefd9a43442fc19933f1e373d4f2ed4bb3ba3201 100644
|
|
|
b2d430 |
--- a/Makefile.am
|
|
|
b2d430 |
+++ b/Makefile.am
|
|
|
b2d430 |
@@ -2470,6 +2470,7 @@ ad_common_tests_SOURCES = \
|
|
|
b2d430 |
src/providers/ad/ad_opts.c \
|
|
|
b2d430 |
src/providers/ad/ad_pac.c \
|
|
|
b2d430 |
src/providers/ad/ad_pac_common.c \
|
|
|
b2d430 |
+ src/providers/ad/ad_domain_info.c \
|
|
|
b2d430 |
src/providers/ldap/sdap_async_initgroups_ad.c \
|
|
|
b2d430 |
$(NULL)
|
|
|
b2d430 |
ad_common_tests_CFLAGS = \
|
|
|
b2d430 |
diff --git a/src/tests/cmocka/test_ad_common.c b/src/tests/cmocka/test_ad_common.c
|
|
|
b2d430 |
index b7a5838de04e1a788bb9a61e84df00fc9bcc784b..7987330e2d0f5df93b62e4a68f34bc4ae23bd79b 100644
|
|
|
b2d430 |
--- a/src/tests/cmocka/test_ad_common.c
|
|
|
b2d430 |
+++ b/src/tests/cmocka/test_ad_common.c
|
|
|
b2d430 |
@@ -802,6 +802,84 @@ void test_user_conn_list(void **state)
|
|
|
b2d430 |
talloc_free(conn_list);
|
|
|
b2d430 |
}
|
|
|
b2d430 |
|
|
|
b2d430 |
+void test_netlogon_get_domain_info(void **state)
|
|
|
b2d430 |
+{
|
|
|
b2d430 |
+ int ret;
|
|
|
b2d430 |
+ struct sysdb_attrs *attrs;
|
|
|
b2d430 |
+ struct ldb_val val = { 0 };
|
|
|
b2d430 |
+ char *flat_name;
|
|
|
b2d430 |
+ char *site;
|
|
|
b2d430 |
+ char *forest;
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ struct ad_common_test_ctx *test_ctx = talloc_get_type(*state,
|
|
|
b2d430 |
+ struct ad_common_test_ctx);
|
|
|
b2d430 |
+ assert_non_null(test_ctx);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ attrs = sysdb_new_attrs(test_ctx);
|
|
|
b2d430 |
+ assert_non_null(attrs);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = netlogon_get_domain_info(test_ctx, attrs, false, NULL, NULL, NULL);
|
|
|
b2d430 |
+ assert_int_equal(ret, ENOENT);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = sysdb_attrs_add_val(attrs, AD_AT_NETLOGON, &val;;
|
|
|
b2d430 |
+ assert_int_equal(ret, EOK);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = netlogon_get_domain_info(test_ctx, attrs, false, NULL, NULL, NULL);
|
|
|
b2d430 |
+ assert_int_equal(ret, EBADMSG);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ talloc_free(attrs);
|
|
|
b2d430 |
+ attrs = sysdb_new_attrs(test_ctx);
|
|
|
b2d430 |
+ assert_non_null(attrs);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ val.data = sss_base64_decode(test_ctx, "FwAAAP0zAABsGcIYI7j2TL97Rd+TvpATAmFkBWRldmVsAMAYCWFkLXNlcnZlcsAYAkFEAAlBRC1TRVJWRVIAABdEZWZhdWx0LUZpcnN0LVNpdGUtTmFtZQDAQAUAAAD/////", &val.length);
|
|
|
b2d430 |
+ assert_non_null(val.data);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = sysdb_attrs_add_val(attrs, AD_AT_NETLOGON, &val;;
|
|
|
b2d430 |
+ assert_int_equal(ret, EOK);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = netlogon_get_domain_info(test_ctx, attrs, false, &flat_name, &site, &forest);
|
|
|
b2d430 |
+ assert_int_equal(ret, EOK);
|
|
|
b2d430 |
+ assert_string_equal(flat_name, "AD");
|
|
|
b2d430 |
+ assert_string_equal(site, "Default-First-Site-Name");
|
|
|
b2d430 |
+ assert_string_equal(forest, "ad.devel");
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ /* missing site */
|
|
|
b2d430 |
+ talloc_free(flat_name);
|
|
|
b2d430 |
+ talloc_free(site);
|
|
|
b2d430 |
+ talloc_free(forest);
|
|
|
b2d430 |
+ talloc_free(val.data);
|
|
|
b2d430 |
+ talloc_free(attrs);
|
|
|
b2d430 |
+ attrs = sysdb_new_attrs(test_ctx);
|
|
|
b2d430 |
+ assert_non_null(attrs);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ val.data = sss_base64_decode(test_ctx, "FwAAAH0zAABsGcIYI7j2TL97Rd+TvpATAmFkBWRldmVsAMAYCWFkLXNlcnZlcsAYAkFEAAlBRC1TRVJWRVIAABdEZWZhdWx0LUZpcnN0LVNpdGUtTmFtZQAABQAAAP////8=", &val.length);
|
|
|
b2d430 |
+ assert_non_null(val.data);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = sysdb_attrs_add_val(attrs, AD_AT_NETLOGON, &val;;
|
|
|
b2d430 |
+ assert_int_equal(ret, EOK);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = netlogon_get_domain_info(test_ctx, attrs, false, &flat_name, &site, &forest);
|
|
|
b2d430 |
+ assert_int_equal(ret, EOK);
|
|
|
b2d430 |
+ assert_string_equal(flat_name, "AD");
|
|
|
b2d430 |
+ assert_null(site);
|
|
|
b2d430 |
+ assert_string_equal(forest, "ad.devel");
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ talloc_free(flat_name);
|
|
|
b2d430 |
+ talloc_free(site);
|
|
|
b2d430 |
+ talloc_free(forest);
|
|
|
b2d430 |
+ ret = netlogon_get_domain_info(test_ctx, attrs, true, &flat_name, &site, &forest);
|
|
|
b2d430 |
+ assert_int_equal(ret, EOK);
|
|
|
b2d430 |
+ assert_string_equal(flat_name, "AD");
|
|
|
b2d430 |
+ assert_null(site);
|
|
|
b2d430 |
+ assert_string_equal(forest, "ad.devel");
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ talloc_free(flat_name);
|
|
|
b2d430 |
+ talloc_free(site);
|
|
|
b2d430 |
+ talloc_free(forest);
|
|
|
b2d430 |
+ talloc_free(val.data);
|
|
|
b2d430 |
+ talloc_free(attrs);
|
|
|
b2d430 |
+}
|
|
|
b2d430 |
+
|
|
|
b2d430 |
int main(int argc, const char *argv[])
|
|
|
b2d430 |
{
|
|
|
b2d430 |
poptContext pc;
|
|
|
b2d430 |
@@ -845,6 +923,9 @@ int main(int argc, const char *argv[])
|
|
|
b2d430 |
cmocka_unit_test_setup_teardown(test_ad_get_pac_data_from_user_entry,
|
|
|
b2d430 |
test_ad_common_setup,
|
|
|
b2d430 |
test_ad_common_teardown),
|
|
|
b2d430 |
+ cmocka_unit_test_setup_teardown(test_netlogon_get_domain_info,
|
|
|
b2d430 |
+ test_ad_common_setup,
|
|
|
b2d430 |
+ test_ad_common_teardown),
|
|
|
b2d430 |
};
|
|
|
b2d430 |
|
|
|
b2d430 |
/* Set debug level to invalid value so we can deside if -d 0 was used. */
|
|
|
b2d430 |
--
|
|
|
b2d430 |
2.4.11
|
|
|
b2d430 |
|