From db6e764580f29c658a3f5486b74e13ad4de7abd4 Mon Sep 17 00:00:00 2001 From: Jan Hutter Date: Tue, 29 Nov 2005 09:57:22 +0000 Subject: - added and tested id_payload_t --- Source/charon/testcases/parser_test.c | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'Source/charon/testcases/parser_test.c') diff --git a/Source/charon/testcases/parser_test.c b/Source/charon/testcases/parser_test.c index 70560b25b..ae12c5720 100644 --- a/Source/charon/testcases/parser_test.c +++ b/Source/charon/testcases/parser_test.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -221,6 +222,47 @@ void test_parser_with_nonce_payload(tester_t *tester) allocator_free_chunk(&result); } +/* + * Described in Header + */ +void test_parser_with_id_payload(tester_t *tester) +{ + parser_t *parser; + id_payload_t *id_payload; + status_t status; + chunk_t id_chunk, result; + + u_int8_t id_bytes[] = { + 0x00,0x00,0x00,0x14, /* payload header */ + 0x05,0x01,0x02,0x03, + 0x04,0x05,0x06,0x07,/* 12 Byte nonce */ + 0x08,0x09,0x0A,0x2B, + 0x0C,0x0D,0x0E,0x0F + }; + + id_chunk.ptr = id_bytes; + id_chunk.len = sizeof(id_bytes); + + parser = parser_create(id_chunk); + tester->assert_true(tester,(parser != NULL), "parser create check"); + status = parser->parse_payload(parser, ID_INITIATOR, (payload_t**)&id_payload); + tester->assert_true(tester,(status == SUCCESS),"parse_payload call check"); + parser->destroy(parser); + + if (status != SUCCESS) + { + return; + } + result = id_payload->get_data(id_payload); + tester->assert_true(tester,(id_payload->get_initiator(id_payload) == TRUE), "is IDi payload"); + tester->assert_true(tester,(id_payload->get_id_type(id_payload) == ID_IPV6_ADDR), "is ID_IPV6_ADDR ID type"); + tester->assert_true(tester,(result.len == 12), "parsed data lenght"); + tester->assert_false(tester,(memcmp(id_bytes + 8, result.ptr, result.len)), "parsed nonce data"); + id_payload->destroy(id_payload); + allocator_free_chunk(&result); +} + + /* * Described in Header */ -- cgit v1.2.3