OpenDNSSEC-enforcer
1.4.5
Main Page
Data Structures
Files
File List
Globals
enforcer
test
cunit
test_ksm_update.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008-2009 Nominet UK. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
*
13
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
*
25
*/
26
27
/*+
28
* Filename: test_ksm_update.c - Test Key update Module
29
*
30
* Description:
31
* This is a short test module to check the functions in the Ksm update
32
* module.
33
*
34
* The test program makes use of the CUnit framework, as described in
35
* http://cunit.sourceforge.net
36
-*/
37
38
#include <stdlib.h>
39
#include <stdio.h>
40
#include <string.h>
41
#include <time.h>
42
43
#include "CUnit/Basic.h"
44
45
#include "
ksm/ksm.h
"
46
#include "
ksm/datetime.h
"
47
#include "
test_routines.h
"
48
49
50
/*+
51
* TestKsmUpdateInternal - Test Update code
52
*
53
* Description:
54
* Tests that keys times can be updated
55
-*/
56
57
static
void
TestKsmUpdateInternal(
void
)
58
{
59
int
status;
/* Status return */
60
int
policy_id = 2;
61
int
zone_id = 1;
62
DB_ID
dnsseckey_id;
/* Created key ID */
63
char
* datetime =
DtParseDateTimeString
(
"now"
);
64
65
/* Create a new dnsseckeys entry (use our previously tested routines)
66
* keys 3 - 15 are unallocated */
67
68
status =
KsmDnssecKeyCreate
(zone_id, 3,
KSM_TYPE_ZSK
,
KSM_STATE_GENERATE
, datetime, NULL, &dnsseckey_id);
69
CU_ASSERT_EQUAL(status, 0);
70
71
/* push a key into some state that update can operate on */
72
status =
KsmRequestChangeStateN
(
KSM_TYPE_ZSK
, datetime, 1,
73
KSM_STATE_GENERATE
,
KSM_STATE_PUBLISH
, zone_id);
74
75
CU_ASSERT_EQUAL(status, 0);
76
77
/* Check that the call works? We get no feedback */
78
status =
KsmUpdate
(policy_id, zone_id);
79
CU_ASSERT_EQUAL(status, 0);
/* not that it can be anything else */
80
81
/* TODO check the keys have updated */
82
}
83
84
/*
85
* TestKsmUpdate - Create Test Suite
86
*
87
* Description:
88
* Adds the test suite to the CUnit test registry and adds all the tests
89
* to it.
90
*
91
* Arguments:
92
* None.
93
*
94
* Returns:
95
* int
96
* Return status. 0 => Success.
97
*/
98
99
int
TestKsmUpdate
(
void
);
/* Declaration */
100
int
TestKsmUpdate
(
void
)
101
{
102
struct
test_testdef
tests[] = {
103
{
"KsmUpdate"
, TestKsmUpdateInternal},
104
{NULL, NULL}
105
};
106
107
/* TODO
108
* have been a bit lazy here and reuse TdbSetup etc...
109
* this has the consequence of all the setups running for each suite
110
* if this gets too slow then we will need to separate them out
111
* */
112
return
TcuCreateSuite
(
"KsmUpdate"
,
TdbSetup
,
TdbTeardown
, tests);
113
}
Generated on Tue Jul 22 2014 00:37:50 for OpenDNSSEC-enforcer by
1.8.1.2