summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-12-21 19:17:42 +0100
committerStephen Gallagher <sgallagh@redhat.com>2011-12-21 14:47:41 -0500
commit85ecf49fdacd910f804caab1be7bf68d23702dc9 (patch)
treef2a3dcd490ce79c01c2800d46108f4b4cc81be8e /src/tests
parent65b813f8bb176d5db33cb486e1cc1bcd6dd8f1cc (diff)
downloadsssd-85ecf49fdacd910f804caab1be7bf68d23702dc9.tar.gz
sssd-85ecf49fdacd910f804caab1be7bf68d23702dc9.tar.xz
sssd-85ecf49fdacd910f804caab1be7bf68d23702dc9.zip
Honor case sensitive flag when creating the ccname template
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/krb5_utils-tests.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/tests/krb5_utils-tests.c b/src/tests/krb5_utils-tests.c
index 6993398a4..aacc384de 100644
--- a/src/tests/krb5_utils-tests.c
+++ b/src/tests/krb5_utils-tests.c
@@ -421,7 +421,7 @@ static void do_test(const char *file_template, const char *dir_template,
fail_unless(ret == EOK, "Failed to set Ccache dir");
result = expand_ccname_template(tmp_ctx, kr, file_template, true,
- &private_path);
+ true, &private_path);
fail_unless(result != NULL, "Cannot expand template [%s].", file_template);
fail_unless(strcmp(result, expected) == 0,
@@ -448,6 +448,37 @@ START_TEST(test_username)
}
END_TEST
+START_TEST(test_case_sensitive)
+{
+ char *result;
+ int ret;
+ bool private_path = false;
+ const char *file_template = BASE"_%u";
+ const char *expected_cs = BASE"_TestUser";
+ const char *expected_ci = BASE"_testuser";
+
+ kr->pd->user = discard_const("TestUser");
+ ret = dp_opt_set_string(kr->krb5_ctx->opts, KRB5_CCACHEDIR, CCACHE_DIR);
+ fail_unless(ret == EOK, "Failed to set Ccache dir");
+
+ result = expand_ccname_template(tmp_ctx, kr, file_template, true,
+ true, &private_path);
+
+ fail_unless(result != NULL, "Cannot expand template [%s].", file_template);
+ fail_unless(strcmp(result, expected_cs) == 0,
+ "Expansion failed, result [%s], expected [%s].",
+ result, expected_cs);
+
+ result = expand_ccname_template(tmp_ctx, kr, file_template, true,
+ false, &private_path);
+
+ fail_unless(result != NULL, "Cannot expand template [%s].", file_template);
+ fail_unless(strcmp(result, expected_ci) == 0,
+ "Expansion failed, result [%s], expected [%s].",
+ result, expected_ci);
+}
+END_TEST
+
START_TEST(test_uid)
{
do_test(BASE"_%U", CCACHE_DIR, BASE"_"UID, false);
@@ -488,7 +519,7 @@ START_TEST(test_ccache_dir)
fail_unless(ret == EOK, "Failed to set Ccache dir");
result = expand_ccname_template(tmp_ctx, kr, "%d/"FILENAME, true,
- &private_path);
+ true, &private_path);
fail_unless(result == NULL, "Using %%d in ccache dir should fail.");
fail_unless(private_path == false,
@@ -509,7 +540,7 @@ START_TEST(test_pid)
fail_unless(ret == EOK, "Failed to set Ccache dir");
result = expand_ccname_template(tmp_ctx, kr, "%d/"FILENAME, true,
- &private_path);
+ true, &private_path);
fail_unless(result == NULL, "Using %%P in ccache dir should fail.");
fail_unless(private_path == false,
@@ -533,7 +564,7 @@ START_TEST(test_unknow_template)
bool private_path = false;
result = expand_ccname_template(tmp_ctx, kr, test_template, true,
- &private_path);
+ true, &private_path);
fail_unless(result == NULL, "Unknown template [%s] should fail.",
test_template);
@@ -542,7 +573,7 @@ START_TEST(test_unknow_template)
fail_unless(ret == EOK, "Failed to set Ccache dir");
test_template = "%d/"FILENAME;
result = expand_ccname_template(tmp_ctx, kr, test_template, true,
- &private_path);
+ true, &private_path);
fail_unless(result == NULL, "Unknown template [%s] should fail.",
test_template);
@@ -559,7 +590,7 @@ START_TEST(test_NULL)
bool private_path = false;
result = expand_ccname_template(tmp_ctx, kr, test_template, true,
- &private_path);
+ true, &private_path);
fail_unless(result == NULL, "Expected NULL as a result for an empty input.",
test_template);
@@ -576,7 +607,7 @@ START_TEST(test_no_substitution)
bool private_path = false;
result = expand_ccname_template(tmp_ctx, kr, test_template, true,
- &private_path);
+ true, &private_path);
fail_unless(result != NULL, "Cannot expand template [%s].", test_template);
fail_unless(strcmp(result, test_template) == 0,
@@ -599,6 +630,7 @@ Suite *krb5_utils_suite (void)
tcase_add_test (tc_ccname_template, test_NULL);
tcase_add_test (tc_ccname_template, test_unknow_template);
tcase_add_test (tc_ccname_template, test_username);
+ tcase_add_test (tc_ccname_template, test_case_sensitive);
tcase_add_test (tc_ccname_template, test_uid);
tcase_add_test (tc_ccname_template, test_upn);
tcase_add_test (tc_ccname_template, test_realm);