- basic test for ike_sa_t written (must be refined later)

This commit is contained in:
Jan Hutter 2005-11-08 14:39:39 +00:00
parent 7ba3876169
commit 4acf505acd
4 changed files with 113 additions and 3 deletions

View File

@ -70,8 +70,8 @@ struct ike_sa_s {
* Creates an ike_sa_t-object with a specific ike_sa_id_t-object
*
* @param[in] ike_sa_id ike_sa_id_t-object to associate with new IKE_SA.
* The object is internal getting cloned
* and so has to be destroyed by the caller.
* The object is internal getting cloned
* and so has to be destroyed by the caller.
*
* @warning the Content of internal ike_sa_id_t-Object can change over time
* e.g. when a IKE_SA_INIT has been finished

View File

@ -38,6 +38,7 @@
#include "tests/scheduler_test.h"
#include "tests/receiver_test.h"
#include "tests/ike_sa_id_test.h"
#include "tests/ike_sa_test.h"
/* output for test messages */
@ -103,6 +104,11 @@ test_t receiver_test = {test_receiver,"Receiver"};
*/
test_t ike_sa_id_test = {test_ike_sa_id,"IKE_SA-Identifier"};
/**
* Test for ike_sa_t
*/
test_t ike_sa_test = {test_ike_sa,"IKE_SA"};
/**
* Global job-queue
*/
@ -140,6 +146,7 @@ socket_t *global_socket;
&scheduler_test,
&receiver_test,
&ike_sa_id_test,
&ike_sa_test,
NULL
};
@ -152,7 +159,7 @@ socket_t *global_socket;
tester_t *tester = tester_create(test_output, FALSE);
tester->perform_tests(tester,all_tests);
/* tester->perform_test(tester,&ike_sa_id_test); */
/* tester->perform_test(tester,&ike_sa_test); */
tester->destroy(tester);

View File

@ -0,0 +1,67 @@
/**
* @file ike_sa_test.c
*
* @brief Tests to test the IKE_SA type ike_sa_t
*
*/
/*
* Copyright (C) 2005 Jan Hutter, 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 "ike_sa_test.h"
#include "../types.h"
#include "../tester.h"
#include "../message.h"
#include "../configuration.h"
#include "../ike_sa.h"
void test_ike_sa(tester_t *tester)
{
ike_sa_t *ike_sa;
ike_sa_id_t *ike_sa_id;
spi_t initiator, responder;
ike_sa_role_t role;
message_t *message;
configuration_t *configuration;
initiator.high = 0;
initiator.low = 0;
responder.high = 34334;
responder.low = 9655;
role = INITIATOR;
/* create a ike_sa_id object for the new IKE_SA */
ike_sa_id = ike_sa_id_create(initiator, responder, role);
/* empty message and configuration objects are created */
message = message_create();
configuration = configuration_create();
/* test every ike_sa function */
ike_sa = ike_sa_create(ike_sa_id);
tester->assert_true(tester,(ike_sa != NULL), "ike_sa pointer check");
tester->assert_true(tester,(ike_sa->process_message(ike_sa,message) == SUCCESS), "process_message call check");
tester->assert_true(tester,(ike_sa->process_configuration(ike_sa,configuration) == SUCCESS), "process_configuration call check");
tester->assert_true(tester,(ike_sa->destroy(ike_sa) == SUCCESS), "destroy call check");
ike_sa_id->destroy(ike_sa_id);
message->destroy(message);
configuration->destroy(configuration);
}

View File

@ -0,0 +1,36 @@
/**
* @file ike_sa_test.h
*
* @brief Tests to test the IKE_SA type ike_sa_t
*
*/
/*
* Copyright (C) 2005 Jan Hutter, 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.
*/
#ifndef IKE_SA_TEST_H_
#define IKE_SA_TEST_H_
#include "../tester.h"
/**
* @brief Test function used to test the ike_sa_t functionality
*
*
* @param tester associated tester_t-object
*/
void test_ike_sa(tester_t *tester);
#endif /*IKE_SA_TEST_H_*/