summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-07-16 19:07:09 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-07-19 13:51:17 +0200
commit35872dc24058c5e8028cb4082fd405a27835dcd1 (patch)
treead566dae5cc1a32cc9cc53b6fe509e3a5295d331 /src/tests
parent52ae806bd17c3c00d70bd1aed437f10f5ae51a1c (diff)
downloadsssd-35872dc24058c5e8028cb4082fd405a27835dcd1.tar.gz
sssd-35872dc24058c5e8028cb4082fd405a27835dcd1.tar.bz2
sssd-35872dc24058c5e8028cb4082fd405a27835dcd1.zip
AD: Set the bool value same as default value in opts
https://fedorahosted.org/sssd/ticket/2023 When the option values are copied using dp_opt_copy_map, the .val member is used if it's not NULL. At the same time, the bool options are never NULL, unlike integers or strings that can have special NULL-like values such as NULL_STRING. This effectively means that when copying a bool option, the .val member is always used. But in the AD maps, some .val fields were set differently from the .def_val fields. The effect was that when the AD subdomain provider was initialized from IPA subdomain provider using only the defaults, some options (notably referral chasing) were set to a value that didn't make sense for the AD provider. This patch makes sure that for all boolean option, the .val is always the same as .def_val.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/ipa_ldap_opt-tests.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/tests/ipa_ldap_opt-tests.c b/src/tests/ipa_ldap_opt-tests.c
index ea4991c8..40afa5cb 100644
--- a/src/tests/ipa_ldap_opt-tests.c
+++ b/src/tests/ipa_ldap_opt-tests.c
@@ -161,6 +161,71 @@ START_TEST(test_compare_2307_with_2307bis)
}
END_TEST
+START_TEST(test_copy_opts)
+{
+ errno_t ret;
+ TALLOC_CTX *tmp_ctx;
+ struct dp_option *opts;
+
+ tmp_ctx = talloc_new(NULL);
+ fail_unless(tmp_ctx != NULL, "talloc_new failed");
+
+ ret = dp_copy_options(tmp_ctx, ad_def_ldap_opts, SDAP_OPTS_BASIC, &opts);
+ fail_unless(ret == EOK, "[%s]", strerror(ret));
+
+ for (int i=0; i < SDAP_OPTS_BASIC; i++) {
+ char *s1, *s2;
+ bool b1, b2;
+ int i1, i2;
+ struct dp_opt_blob bl1, bl2;
+
+ switch (opts[i].type) {
+ case DP_OPT_STRING:
+ s1 = dp_opt_get_string(opts, i);
+ s2 = opts[i].def_val.string;
+
+ if (s1 != NULL || s2 != NULL) {
+ fail_unless(strcmp(s1, s2) == 0,
+ "Option %s does not have default value after copy\n",
+ opts[i].opt_name);
+ }
+ break;
+
+ case DP_OPT_NUMBER:
+ i1 = dp_opt_get_int(opts, i);
+ i2 = opts[i].def_val.number;
+
+ fail_unless(i1 == i2,
+ "Option %s does not have default value after copy\n",
+ opts[i].opt_name);
+ break;
+
+ case DP_OPT_BOOL:
+ b1 = dp_opt_get_bool(opts, i);
+ b2 = opts[i].def_val.boolean;
+
+ fail_unless(b1 == b2,
+ "Option %s does not have default value after copy\n",
+ opts[i].opt_name);
+ break;
+
+ case DP_OPT_BLOB:
+ bl1 = dp_opt_get_blob(opts, i);
+ bl2 = opts[i].def_val.blob;
+
+ fail_unless(bl1.length == bl2.length,
+ "Blobs differ in size for option %s\n",
+ opts[i].opt_name);
+ fail_unless(memcmp(bl1.data, bl2.data, bl1.length) == 0,
+ "Blobs differ in value for option %s\n",
+ opts[i].opt_name);
+ }
+ }
+
+ talloc_free(tmp_ctx);
+}
+END_TEST
+
Suite *ipa_ldap_opt_suite (void)
{
Suite *s = suite_create ("ipa_ldap_opt");
@@ -176,6 +241,10 @@ Suite *ipa_ldap_opt_suite (void)
tcase_add_test (tc_ipa_utils, test_domain_to_basedn);
suite_add_tcase (s, tc_ipa_utils);
+ TCase *tc_dp_opts = tcase_create ("dp_opts");
+ tcase_add_test (tc_dp_opts, test_copy_opts);
+ suite_add_tcase (s, tc_dp_opts);
+
return s;
}