diff options
author | Martin Willi <martin@strongswan.org> | 2009-07-03 17:07:04 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-07-06 13:15:28 +0200 |
commit | d35650115bea2a634f2a61d7f833c2c5df17373a (patch) | |
tree | e7214057683ccd7454520dea9e938667c1ca5d64 /src | |
parent | 2147da40a5d79ca7921c028d38fe9503feb42bfb (diff) | |
download | strongswan-d35650115bea2a634f2a61d7f833c2c5df17373a.tar.bz2 strongswan-d35650115bea2a634f2a61d7f833c2c5df17373a.tar.xz |
added unit test for identification_t.contains_wildcard()
Diffstat (limited to 'src')
-rw-r--r-- | src/charon/plugins/unit_tester/tests.h | 1 | ||||
-rw-r--r-- | src/charon/plugins/unit_tester/tests/test_id.c | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/charon/plugins/unit_tester/tests.h b/src/charon/plugins/unit_tester/tests.h index dcf2a5d18..24579a845 100644 --- a/src/charon/plugins/unit_tester/tests.h +++ b/src/charon/plugins/unit_tester/tests.h @@ -36,5 +36,6 @@ DEFINE_TEST("Base64 converter", test_chunk_base64, FALSE) DEFINE_TEST("IP pool", test_pool, FALSE) DEFINE_TEST("SSH agent", test_agent, FALSE) DEFINE_TEST("ID parts", test_id_parts, FALSE) +DEFINE_TEST("ID wildcards", test_id_wildcards, FALSE) /** @}*/ diff --git a/src/charon/plugins/unit_tester/tests/test_id.c b/src/charon/plugins/unit_tester/tests/test_id.c index 56dab2421..82bbac773 100644 --- a/src/charon/plugins/unit_tester/tests/test_id.c +++ b/src/charon/plugins/unit_tester/tests/test_id.c @@ -67,3 +67,43 @@ bool test_id_parts() return TRUE; } +/******************************************************************************* + * identification contains_wildcards() test + ******************************************************************************/ + +static bool test_id_wildcards_has(char *string) +{ + identification_t *id; + bool contains; + + id = identification_create_from_string(string); + contains = id->contains_wildcards(id); + id->destroy(id); + return contains; +} + +bool test_id_wildcards() +{ + if (!test_id_wildcards_has("C=*, O=strongSwan, CN=gw")) + { + return FALSE; + } + if (!test_id_wildcards_has("C=CH, O=strongSwan, CN=*")) + { + return FALSE; + } + if (test_id_wildcards_has("C=**, O=a*, CN=*a")) + { + return FALSE; + } + if (!test_id_wildcards_has("*@strongswan.org")) + { + return FALSE; + } + if (!test_id_wildcards_has("*.strongswan.org")) + { + return FALSE; + } + return TRUE; +} + |