From f81af1030b43df2024a329a868b32bf4007d5d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Wed, 11 Aug 2004 21:49:46 +0000 Subject: [PATCH] test variables in default_cc_name git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14112 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/test_cc.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/krb5/test_cc.c b/lib/krb5/test_cc.c index 6fceb36d5..0ae3c8b29 100644 --- a/lib/krb5/test_cc.c +++ b/lib/krb5/test_cc.c @@ -267,6 +267,48 @@ test_mcc_default(void) } } +struct { + char *str; + int fail; + char *res; +} cc_names[] = { + { "foo", 0, "foo" }, + { "${uid}", 0 }, + { "foo${null}", 0, "foo" }, + { "foo${null}bar", 0, "foobar" }, + { "${", 1 }, + { "${foo ${", 1 }, + { "${{", 1 }, +}; + +static void +test_def_cc_name(krb5_context context) +{ + krb5_error_code ret; + char *str; + int i; + + for (i = 0; i < sizeof(cc_names)/sizeof(cc_names[0]); i++) { + ret = _krb5_expand_default_cc_name(context, cc_names[i].str, &str); + if (ret) { + if (cc_names[i].fail == 0) + krb5_errx(context, 1, "test %d \"%s\" failed", + i, cc_names[i].str); + } else { + if (cc_names[i].fail) + krb5_errx(context, 1, "test %d \"%s\" was successful", + i, cc_names[i].str); + if (cc_names[i].res && strcmp(cc_names[i].res, str) != 0) + krb5_errx(context, 1, "test %d %s != %s", + i, cc_names[i].res, str); +#if 0 + printf("%s => %s\n", cc_names[i].str, str); +#endif + free(str); + } + } +} + int main(int argc, char **argv) { @@ -285,6 +327,7 @@ main(int argc, char **argv) test_init_vs_destroy(context, &krb5_mcc_ops); test_init_vs_destroy(context, &krb5_fcc_ops); test_mcc_default(); + test_def_cc_name(context); krb5_free_context(context);