summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-12-13 11:44:59 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-12-19 11:11:40 +0100
commitcbbbde7a66e176871aae37ed323e53ac41859e8d (patch)
tree8be1b07e25c7d5bc76ee5e5be2024a9d5e7ef9c4 /src/tests
parent2e96a84a2be53586db82a20287988a8a422c98ea (diff)
downloadsssd-cbbbde7a66e176871aae37ed323e53ac41859e8d.tar.gz
sssd-cbbbde7a66e176871aae37ed323e53ac41859e8d.tar.xz
sssd-cbbbde7a66e176871aae37ed323e53ac41859e8d.zip
Use lower-case name for case-insensitive searches
The patch makes sure that a completely lower-cased version of a fully qualified name is used for case insensitive searches. Currently there are code paths where the domain name was used as configured and was not lower-cased. To make sure this patch does not break with old entries in the cache or case sensitive domains a third template was added to the related filters templates which is either filled with a completely lower-cased version or with the old version. The other two template values are unchanged.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cmocka/test_utils.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c
index 1be59ab69..61e8e9f07 100644
--- a/src/tests/cmocka/test_utils.c
+++ b/src/tests/cmocka/test_utils.c
@@ -177,6 +177,41 @@ void test_find_subdomain_by_sid_missing_sid(void **state)
}
}
+#define TEST_SANITIZE_INPUT "TestUser@Test.Domain"
+#define TEST_SANITIZE_LC_INPUT "testuser@test.domain"
+
+void test_sss_filter_sanitize_for_dom(void **state)
+{
+ struct dom_list_test_ctx *test_ctx;
+ int ret;
+ char *sanitized;
+ char *lc_sanitized;
+ struct sss_domain_info *dom;
+
+ test_ctx = talloc_get_type(*state, struct dom_list_test_ctx);
+ dom = test_ctx->dom_list;
+
+ dom->case_sensitive = true;
+
+ ret = sss_filter_sanitize_for_dom(test_ctx, TEST_SANITIZE_INPUT, dom,
+ &sanitized, &lc_sanitized);
+ assert_int_equal(ret, EOK);
+ assert_string_equal(sanitized, TEST_SANITIZE_INPUT);
+ assert_string_equal(lc_sanitized, TEST_SANITIZE_INPUT);
+ talloc_free(sanitized);
+ talloc_free(lc_sanitized);
+
+ dom->case_sensitive = false;
+
+ ret = sss_filter_sanitize_for_dom(test_ctx, TEST_SANITIZE_INPUT, dom,
+ &sanitized, &lc_sanitized);
+ assert_int_equal(ret, EOK);
+ assert_string_equal(sanitized, TEST_SANITIZE_INPUT);
+ assert_string_equal(lc_sanitized, TEST_SANITIZE_LC_INPUT);
+ talloc_free(sanitized);
+ talloc_free(lc_sanitized);
+}
+
int main(int argc, const char *argv[])
{
poptContext pc;
@@ -194,6 +229,9 @@ int main(int argc, const char *argv[])
setup_dom_list, teardown_dom_list),
unit_test_setup_teardown(test_find_subdomain_by_sid_missing_sid,
setup_dom_list, teardown_dom_list),
+
+ unit_test_setup_teardown(test_sss_filter_sanitize_for_dom,
+ setup_dom_list, teardown_dom_list),
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */