• Main Page
  • Data Structures
  • Files
  • File List
  • Globals

/srv/bpo/opendnssec/opendnssec-1.3.2/enforcer/test/cunit/test_ksm_update.c

Go to the documentation of this file.
00001 /*
00002  * $Id: test_ksm_update.c 3811 2010-08-26 15:05:19Z jakob $
00003  *
00004  * Copyright (c) 2008-2009 Nominet UK. All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00016  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00017  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00018  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00019  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00020  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00021  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
00023  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00024  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
00025  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *
00027  */
00028 
00029 /*+
00030  * Filename: test_ksm_update.c - Test Key update Module
00031  *
00032  * Description:
00033  *      This is a short test module to check the functions in the Ksm update
00034  *      module.
00035  *
00036  *      The test program makes use of the CUnit framework, as described in
00037  *      http://cunit.sourceforge.net
00038 -*/
00039 
00040 #include <stdlib.h>
00041 #include <stdio.h>
00042 #include <string.h>
00043 #include <time.h>
00044 
00045 #include "CUnit/Basic.h"
00046 
00047 #include "ksm/ksm.h"
00048 #include "ksm/datetime.h"
00049 #include "test_routines.h"
00050 
00051 
00052 /*+
00053  * TestKsmUpdateInternal - Test Update code
00054  *
00055  * Description:
00056  *      Tests that keys times can be updated
00057 -*/
00058 
00059 static void TestKsmUpdateInternal(void)
00060 {
00061         int                     status;         /* Status return */
00062     int         policy_id = 2;
00063     int         zone_id = 1;
00064     DB_ID       dnsseckey_id;   /* Created key ID */
00065     char*   datetime = DtParseDateTimeString("now");
00066 
00067     /* Create a new dnsseckeys entry (use our previously tested routines) 
00068      * keys 3 - 15 are unallocated */
00069 
00070     status = KsmDnssecKeyCreate(zone_id, 3, KSM_TYPE_ZSK, KSM_STATE_GENERATE, datetime, &dnsseckey_id);
00071         CU_ASSERT_EQUAL(status, 0);
00072 
00073         /* push a key into some state that update can operate on */
00074     status = KsmRequestChangeStateN( KSM_TYPE_ZSK, datetime, 1,
00075         KSM_STATE_GENERATE, KSM_STATE_PUBLISH, zone_id);
00076 
00077     CU_ASSERT_EQUAL(status, 0);
00078 
00079         /* Check that the call works? We get no feedback */
00080     status = KsmUpdate(policy_id, zone_id);
00081         CU_ASSERT_EQUAL(status, 0); /* not that it can be anything else */
00082 
00083     /* TODO check the keys have updated */
00084 }
00085 
00086 /*
00087  * TestKsmUpdate - Create Test Suite
00088  *
00089  * Description:
00090  *      Adds the test suite to the CUnit test registry and adds all the tests
00091  *      to it.
00092  *
00093  * Arguments:
00094  *      None.
00095  *
00096  * Returns:
00097  *      int
00098  *          Return status.  0 => Success.
00099  */
00100 
00101 int TestKsmUpdate(void);        /* Declaration */
00102 int TestKsmUpdate(void)
00103 {
00104     struct test_testdef tests[] = {
00105         {"KsmUpdate", TestKsmUpdateInternal},
00106         {NULL,                      NULL}
00107     };
00108 
00109     /* TODO 
00110      * have been a bit lazy here and reuse TdbSetup etc...
00111      * this has the consequence of all the setups running for each suite
00112      * if this gets too slow then we will need to separate them out
00113      * */
00114     return TcuCreateSuite("KsmUpdate", TdbSetup, TdbTeardown, tests);
00115 }

Generated on Mon Oct 31 2011 14:38:31 for OpenDNSSEC-enforcer by  doxygen 1.7.1