2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 /*******************************************************************************
19 * identification part enumeration test
20 ******************************************************************************/
24 enumerator_t
*enumerator
;
29 id
= identification_create_from_string("C=CH, O=strongSwan, CN=tester");
31 enumerator
= id
->create_part_enumerator(id
);
32 while (enumerator
->enumerate(enumerator
, &part
, &data
))
37 if (part
!= ID_PART_RDN_C
||
38 !chunk_equals(data
, chunk_create("CH", 2)))
44 if (part
!= ID_PART_RDN_O
||
45 !chunk_equals(data
, chunk_create("strongSwan", 10)))
51 if (part
!= ID_PART_RDN_CN
||
52 !chunk_equals(data
, chunk_create("tester", 6)))
65 enumerator
->destroy(enumerator
);
70 /*******************************************************************************
71 * identification contains_wildcards() test
72 ******************************************************************************/
74 static bool test_id_wildcards_has(char *string
)
79 id
= identification_create_from_string(string
);
80 contains
= id
->contains_wildcards(id
);
85 bool test_id_wildcards()
87 if (!test_id_wildcards_has("C=*, O=strongSwan, CN=gw"))
91 if (!test_id_wildcards_has("C=CH, O=strongSwan, CN=*"))
95 if (test_id_wildcards_has("C=**, O=a*, CN=*a"))
99 if (!test_id_wildcards_has("*@strongswan.org"))
103 if (!test_id_wildcards_has("*.strongswan.org"))