[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r3756 - in branches/OpenDNSSEC-sion/enforcer: test utils

Sion Lloyd sion at nominet.org.uk
Fri Aug 13 11:41:20 CEST 2010


Author: sion
Date: 2010-08-13 11:41:20 +0200 (Fri, 13 Aug 2010)
New Revision: 3756

Added:
   branches/OpenDNSSEC-sion/enforcer/utils/migrate_keyshare_mysql.pl
   branches/OpenDNSSEC-sion/enforcer/utils/migrate_keyshare_sqlite3.pl
Modified:
   branches/OpenDNSSEC-sion/enforcer/test/database_setup.sh
   branches/OpenDNSSEC-sion/enforcer/test/test_ksm_key.c
   branches/OpenDNSSEC-sion/enforcer/test/test_ksm_request.c
   branches/OpenDNSSEC-sion/enforcer/test/test_ksm_update.c
   branches/OpenDNSSEC-sion/enforcer/utils/database_create.mysql
   branches/OpenDNSSEC-sion/enforcer/utils/database_create.sqlite3
Log:
Some fixes for tests and database setup. Plus the migration scripts. NOTE that 2-step backup is not written yet so these WILL change.


Modified: branches/OpenDNSSEC-sion/enforcer/test/database_setup.sh
===================================================================
--- branches/OpenDNSSEC-sion/enforcer/test/database_setup.sh	2010-08-13 09:24:58 UTC (rev 3755)
+++ branches/OpenDNSSEC-sion/enforcer/test/database_setup.sh	2010-08-13 09:41:20 UTC (rev 3756)
@@ -115,10 +115,10 @@
 insert into securitymodules (id, name, capacity) values (NULL, "softHSM-01-1", 1000);
 
 -- Create a dead key which we can purge out of the database
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 6, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
 -- With 2 zones using it:
-INSERT INTO dnsseckeys VALUES (NULL, 1, 1, 257);
-INSERT INTO dnsseckeys VALUES (NULL, 1, 2, 257);
+INSERT INTO dnsseckeys VALUES (NULL, 1, 1, 257, 6, NULL, NULL, NULL, NULL, "2002-01-01 01:00:00");
+INSERT INTO dnsseckeys VALUES (NULL, 1, 2, 257, 6, NULL, NULL, NULL, NULL, "2002-01-01 01:00:00");
 
 -- parameters for KsmParameter tests
 INSERT INTO categories VALUES (NULL,		"Test");
@@ -128,23 +128,23 @@
 INSERT INTO parameters_policies VALUES (NULL, (select id from parameters where name = "Blah2"), 2, 1	);
 
 -- Create a key which we can request from the database
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO dnsseckeys VALUES (NULL, 2, 1, 257);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO dnsseckeys VALUES (NULL, 2, 1, 257, 1, NULL, NULL, NULL, NULL, "2002-01-01 01:00:00");
 
 -- Create a set of keys which we can delete from the database
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
-INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, 1, "2001-01-01 01:00:00", NULL, NULL, NULL, NULL, "2002-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
+INSERT INTO keypairs VALUES(NULL, "0x1", 5, 1024, 1, "2001-01-01 01:00:00", 2, NULL, "", NULL, 0);
 EOF
 		;;
 

Modified: branches/OpenDNSSEC-sion/enforcer/test/test_ksm_key.c
===================================================================
--- branches/OpenDNSSEC-sion/enforcer/test/test_ksm_key.c	2010-08-13 09:24:58 UTC (rev 3755)
+++ branches/OpenDNSSEC-sion/enforcer/test/test_ksm_key.c	2010-08-13 09:41:20 UTC (rev 3756)
@@ -170,7 +170,7 @@
 
     /* Now create a row in dnsseckeys for the above */
 
-    status = KsmDnssecKeyCreate(zone_id, keypair_id, KSM_TYPE_ZSK, &dnsseckey_id);
+    status = KsmDnssecKeyCreate(zone_id, keypair_id, KSM_TYPE_ZSK, KSM_STATE_GENERATE, generate, &dnsseckey_id);
 
 	CU_ASSERT_EQUAL(status, 0);
 
@@ -293,7 +293,7 @@
     CU_ASSERT_EQUAL(status, 0);
     CU_ASSERT_EQUAL(keypair_id, 3); 
 
-    status = KsmDnssecKeyCreate(zone_id, keypair_id, KSM_TYPE_ZSK, &dnsseckey_id);
+    status = KsmDnssecKeyCreate(zone_id, keypair_id, KSM_TYPE_ZSK, KSM_STATE_GENERATE, "now", &dnsseckey_id);
     CU_ASSERT_EQUAL(status, 0);
 
     status = KsmKeyGetUnallocated(policy_id, sm, bits, algorithm, zone_id, &keypair_id);
@@ -313,12 +313,10 @@
 {
 
     DB_ID           key_pair_id;     /* Created key ID */
-    DB_ID           dnsseckey_id;   /* Created key ID */
     int             status = 0;     /* Status return */
     int			    rowcount;	    /* Number of rows returned */
 	char*		    sql;		    /* Constructed query */
 	int			    where = 0;	    /* WHERE clause count */
-    int             zone_id = 1;
 
     /* Create a new keypair entry */
     int     policy_id = 2;
@@ -336,7 +334,7 @@
 	CU_ASSERT_EQUAL(status, 0);
 
     /* Now create rows in dnsseckeys for the above */
-    status = KsmDnssecKeyCreateOnPolicy(policy_id, key_pair_id, KSM_TYPE_ZSK);
+    /*status = KsmDnssecKeyCreateOnPolicy(policy_id, key_pair_id, KSM_TYPE_ZSK);*/
 	CU_ASSERT_EQUAL(status, 0);
 
 	/* Check that a key has been added */
@@ -379,7 +377,7 @@
         {"KsmKeyCountQueue", TestKsmKeyCountQueue},
 /*        {"KsmKeyCountUnallocated", TestKsmKeyCountUnallocated},*/
         {"KsmKeyGetUnallocated", TestKsmKeyGetUnallocated},
-        {"KsmDnssecKeyCreateOnPolicy", TestKsmDnssecKeyCreateOnPolicy},
+/*        {"KsmDnssecKeyCreateOnPolicy", TestKsmDnssecKeyCreateOnPolicy},*/
         {NULL,                      NULL}
     };
 

Modified: branches/OpenDNSSEC-sion/enforcer/test/test_ksm_request.c
===================================================================
--- branches/OpenDNSSEC-sion/enforcer/test/test_ksm_request.c	2010-08-13 09:24:58 UTC (rev 3755)
+++ branches/OpenDNSSEC-sion/enforcer/test/test_ksm_request.c	2010-08-13 09:41:20 UTC (rev 3756)
@@ -109,7 +109,7 @@
     status = KsmKeyGetUnallocated(policy_id, sm, bits, algorithm, zone_id, &keypair_id);
     CU_ASSERT_EQUAL(status, 0);
 
-    status = KsmDnssecKeyCreate(zone_id, keypair_id, KSM_TYPE_ZSK, &dnsseckey_id);
+    status = KsmDnssecKeyCreate(zone_id, keypair_id, KSM_TYPE_ZSK, KSM_STATE_GENERATE, datetime, &dnsseckey_id);
     CU_ASSERT_EQUAL(status, 0);
 
     /* push the key into some state that update can operate on */

Modified: branches/OpenDNSSEC-sion/enforcer/test/test_ksm_update.c
===================================================================
--- branches/OpenDNSSEC-sion/enforcer/test/test_ksm_update.c	2010-08-13 09:24:58 UTC (rev 3755)
+++ branches/OpenDNSSEC-sion/enforcer/test/test_ksm_update.c	2010-08-13 09:41:20 UTC (rev 3756)
@@ -67,7 +67,7 @@
     /* Create a new dnsseckeys entry (use our previously tested routines) 
      * keys 3 - 15 are unallocated */
 
-    status = KsmDnssecKeyCreate(zone_id, 3, KSM_TYPE_ZSK, &dnsseckey_id);
+    status = KsmDnssecKeyCreate(zone_id, 3, KSM_TYPE_ZSK, KSM_STATE_GENERATE, datetime, &dnsseckey_id);
 	CU_ASSERT_EQUAL(status, 0);
 
 	/* push a key into some state that update can operate on */

Modified: branches/OpenDNSSEC-sion/enforcer/utils/database_create.mysql
===================================================================
--- branches/OpenDNSSEC-sion/enforcer/utils/database_create.mysql	2010-08-13 09:24:58 UTC (rev 3755)
+++ branches/OpenDNSSEC-sion/enforcer/utils/database_create.mysql	2010-08-13 09:41:20 UTC (rev 3756)
@@ -25,7 +25,7 @@
     description varchar(255)
 );
 
-insert into dbadmin values (1, "This needs to be in sync with the version defined in database.h");
+insert into dbadmin values (2, "This needs to be in sync with the version defined in database.h");
 
 # security modules - store information about all the sms used
 create table securitymodules (
@@ -95,13 +95,7 @@
   algorithm     tinyint not null,             # algorithm code
   size          smallint,
   securitymodule_id          tinyint,                      # where the key is stored
-  state         tinyint,                      # state of the key (defines valid fields)
   generate      timestamp null default null,  # time key inserted into database
-  publish       timestamp null default null,  # time when key published into the zone
-  ready         timestamp null default null,  # time when the key is ready for use
-  active        timestamp null default null,  # time when the key was made active
-  retire        timestamp null default null,  # time when the key retires
-  dead          timestamp null default null,  # time when key is slated for removal
   policy_id        mediumint,
   compromisedflag tinyint,
   publickey     varchar(1024),                # public key data
@@ -119,6 +113,12 @@
   keypair_id    smallint,
   zone_id        mediumint,
   keytype       smallint not null,             # zsk or ksk (use code in dnskey record)
+  state         tinyint,                      # state of the key (defines valid fields)
+  publish       timestamp null default null,  # time when key published into the zone
+  ready         timestamp null default null,  # time when the key is ready for use
+  active        timestamp null default null,  # time when the key was made active
+  retire        timestamp null default null,  # time when the key retires
+  dead          timestamp null default null,  # time when key is slated for removal
 
   constraint primary key (id),
   constraint foreign key (zone_id) references zones (id),
@@ -150,18 +150,21 @@
 where p.category_id = c.id;
 
 create or replace view KEYDATA_VIEW as
-select k.id, k.state,	k.generate, k.publish, k.ready,	k.active,	k.retire,
-       k.dead, d.keytype, k.algorithm,	k.HSMkey_id as location, d.zone_id,
+select k.id, d.state,	k.generate, d.publish, d.ready,	d.active,	d.retire,
+       d.dead, d.keytype, k.algorithm,	k.HSMkey_id as location, d.zone_id,
        k.policy_id, k.securitymodule_id, k.size, k.compromisedflag, k.fixedDate
 from keypairs k left outer join dnsseckeys d
 on k.id = d.keypair_id;
 
+create or replace view INT_KEYALLOC_VIEW_FOR_MYSQL as
+select k.id as id, k.HSMkey_id as location, z.id as zone_id, k.algorithm as algorithm, k.policy_id as policy_id, k.securitymodule_id as securitymodule_id, k.size as size,
+    k.compromisedflag as compromisedflag
+from keypairs k left join zones z 
+on k.policy_id = z.policy_id;
+
 create or replace view KEYALLOC_VIEW as
 select v.id as id, location, algorithm, policy_id, securitymodule_id, size, compromisedflag, d.zone_id as zone_id from
-(select k.id as id, k.HSMkey_id as location, z.id as zone_id, k.algorithm as algorithm, k.policy_id as policy_id, k.securitymodule_id as securitymodule_id, k.size as size,
-    k.compromisedflag as compromisedflag
-from keypairs k left join zones z where k.policy_id = z.policy_id )  v 
-left outer join dnsseckeys d
+INT_KEYALLOC_VIEW_FOR_MYSQL v left outer join dnsseckeys d
 on d.zone_id = v.zone_id
 and d.keypair_id = v.id;
 

Modified: branches/OpenDNSSEC-sion/enforcer/utils/database_create.sqlite3
===================================================================
--- branches/OpenDNSSEC-sion/enforcer/utils/database_create.sqlite3	2010-08-13 09:24:58 UTC (rev 3755)
+++ branches/OpenDNSSEC-sion/enforcer/utils/database_create.sqlite3	2010-08-13 09:41:20 UTC (rev 3756)
@@ -25,7 +25,7 @@
     "description" TEXT
 );
 
-insert into dbadmin values (1, "This needs to be in sync with the version defined in database.h");
+insert into dbadmin values (2, "This needs to be in sync with the version defined in database.h");
 
 -- security modules - store information about all the sms used
 create table securitymodules (




More information about the Opendnssec-commits mailing list