added create_part_enumerator() to indentity, allows to enumerate RDNs etc.
This commit is contained in:
@@ -20,7 +20,8 @@ libstrongswan_unit_tester_la_SOURCES = unit_tester.c unit_tester.h tests.h \
|
||||
tests/test_chunk.c \
|
||||
tests/test_pool.c \
|
||||
tests/test_agent.c \
|
||||
tests/test_rng.c
|
||||
tests/test_rng.c \
|
||||
tests/test_id.c
|
||||
|
||||
libstrongswan_unit_tester_la_LDFLAGS = -module
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ DEFINE_TEST("simple enumerator", test_enumerate, FALSE)
|
||||
DEFINE_TEST("nested enumerator", test_enumerate_nested, FALSE)
|
||||
DEFINE_TEST("filtered enumerator", test_enumerate_filtered, FALSE)
|
||||
DEFINE_TEST("token enumerator", test_enumerate_token, FALSE)
|
||||
DEFINE_TEST("auth info", test_auth_info, FALSE)
|
||||
DEFINE_TEST("auth cfg", test_auth_cfg, FALSE)
|
||||
DEFINE_TEST("FIPS PRF", fips_prf_test, FALSE)
|
||||
DEFINE_TEST("CURL get", test_curl_get, FALSE)
|
||||
DEFINE_TEST("MySQL operations", test_mysql, FALSE)
|
||||
@@ -41,5 +41,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("RNG quality", test_rng, FALSE)
|
||||
DEFINE_TEST("ID parts", test_id_parts, FALSE)
|
||||
|
||||
/** @}*/
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <daemon.h>
|
||||
|
||||
/*******************************************************************************
|
||||
* identification part enumeration test
|
||||
******************************************************************************/
|
||||
bool test_id_parts()
|
||||
{
|
||||
identification_t *id;
|
||||
enumerator_t *enumerator;
|
||||
id_part_t part;
|
||||
chunk_t data;
|
||||
int i = 0;
|
||||
|
||||
id = identification_create_from_string("C=CH, O=strongSwan, CN=tester");
|
||||
|
||||
enumerator = id->create_part_enumerator(id);
|
||||
while (enumerator->enumerate(enumerator, &part, &data))
|
||||
{
|
||||
switch (i++)
|
||||
{
|
||||
case 0:
|
||||
if (part != ID_PART_RDN_C ||
|
||||
!chunk_equals(data, chunk_create("CH", 2)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (part != ID_PART_RDN_O ||
|
||||
!chunk_equals(data, chunk_create("strongSwan", 10)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (part != ID_PART_RDN_CN ||
|
||||
!chunk_equals(data, chunk_create("tester", 6)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (i < 3)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
id->destroy(id);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user