30 #include "CUnit/Basic.h" 32 #include "../db_configuration.h" 33 #include "../db_connection.h" 42 static zone_t*
object = NULL;
47 static int db_sqlite = 0;
48 static int db_mysql = 0;
50 #if defined(ENFORCER_DATABASE_SQLITE3) 51 int test_zone_init_suite_sqlite(
void) {
52 if (configuration_list) {
76 configuration_list = NULL;
88 configuration_list = NULL;
102 configuration_list = NULL;
105 configuration_list = NULL;
122 #if defined(ENFORCER_DATABASE_MYSQL) 123 int test_zone_init_suite_mysql(
void) {
124 if (configuration_list) {
146 configuration = NULL;
148 configuration_list = NULL;
151 configuration = NULL;
158 configuration = NULL;
160 configuration_list = NULL;
163 configuration = NULL;
170 configuration = NULL;
172 configuration_list = NULL;
175 configuration = NULL;
182 configuration = NULL;
184 configuration_list = NULL;
187 configuration = NULL;
194 configuration = NULL;
196 configuration_list = NULL;
199 configuration = NULL;
206 configuration = NULL;
208 configuration_list = NULL;
211 configuration = NULL;
222 configuration_list = NULL;
225 configuration_list = NULL;
242 static int test_zone_clean_suite(
void) {
246 configuration = NULL;
248 configuration_list = NULL;
255 static void test_zone_new(
void) {
256 CU_ASSERT_PTR_NOT_NULL_FATAL((
object =
zone_new(connection)));
257 CU_ASSERT_PTR_NOT_NULL_FATAL((object_list =
zone_list_new(connection)));
260 static void test_zone_set(
void) {
289 static void test_zone_get(
void) {
300 CU_ASSERT_PTR_NOT_NULL_FATAL(
zone_name(
object));
301 CU_ASSERT(!strcmp(
zone_name(
object),
"name 1"));
326 static void test_zone_create(
void) {
330 static void test_zone_clauses(
void) {
441 static void test_zone_count(
void) {
445 CU_ASSERT(count == 1);
449 CU_ASSERT(!
zone_count(
object, clause_list, &count));
450 CU_ASSERT(count == 1);
455 CU_ASSERT(!
zone_count(
object, clause_list, &count));
456 CU_ASSERT(count == 1);
461 CU_ASSERT(!
zone_count(
object, clause_list, &count));
462 CU_ASSERT(count == 1);
467 CU_ASSERT(!
zone_count(
object, clause_list, &count));
468 CU_ASSERT(count == 1);
473 CU_ASSERT(!
zone_count(
object, clause_list, &count));
474 CU_ASSERT(count == 1);
479 CU_ASSERT(!
zone_count(
object, clause_list, &count));
480 CU_ASSERT(count == 1);
485 CU_ASSERT(!
zone_count(
object, clause_list, &count));
486 CU_ASSERT(count == 1);
491 CU_ASSERT(!
zone_count(
object, clause_list, &count));
492 CU_ASSERT(count == 1);
497 CU_ASSERT(!
zone_count(
object, clause_list, &count));
498 CU_ASSERT(count == 1);
503 CU_ASSERT(!
zone_count(
object, clause_list, &count));
504 CU_ASSERT(count == 1);
509 CU_ASSERT(!
zone_count(
object, clause_list, &count));
510 CU_ASSERT(count == 1);
515 CU_ASSERT(!
zone_count(
object, clause_list, &count));
516 CU_ASSERT(count == 1);
521 CU_ASSERT(!
zone_count(
object, clause_list, &count));
522 CU_ASSERT(count == 1);
527 CU_ASSERT(!
zone_count(
object, clause_list, &count));
528 CU_ASSERT(count == 1);
533 CU_ASSERT(!
zone_count(
object, clause_list, &count));
534 CU_ASSERT(count == 1);
539 CU_ASSERT(!
zone_count(
object, clause_list, &count));
540 CU_ASSERT(count == 1);
545 CU_ASSERT(!
zone_count(
object, clause_list, &count));
546 CU_ASSERT(count == 1);
551 CU_ASSERT(!
zone_count(
object, clause_list, &count));
552 CU_ASSERT(count == 1);
557 static void test_zone_list(
void) {
563 CU_ASSERT_PTR_NOT_NULL_FATAL((item =
zone_list_next(object_list)));
570 CU_PASS(
"zone_free");
577 static void test_zone_list_store(
void) {
580 CU_ASSERT_PTR_NOT_NULL((new_list =
zone_list_new(connection)));
587 CU_PASS(
"zone_free");
592 static void test_zone_list_associated(
void) {
595 CU_ASSERT_PTR_NOT_NULL((new_list =
zone_list_new(connection)));
601 CU_PASS(
"zone_free");
606 static void test_zone_read(
void) {
610 static void test_zone_verify(
void) {
621 CU_ASSERT_PTR_NOT_NULL_FATAL(
zone_name(
object));
622 CU_ASSERT(!strcmp(
zone_name(
object),
"name 1"));
647 static void test_zone_read_by_name(
void) {
651 static void test_zone_verify_name(
void) {
662 CU_ASSERT_PTR_NOT_NULL_FATAL(
zone_name(
object));
663 CU_ASSERT(!strcmp(
zone_name(
object),
"name 1"));
688 static void test_zone_change(
void) {
717 static void test_zone_update(
void) {
721 static void test_zone_read2(
void) {
725 static void test_zone_verify2(
void) {
736 CU_ASSERT_PTR_NOT_NULL_FATAL(
zone_name(
object));
737 CU_ASSERT(!strcmp(
zone_name(
object),
"name 2"));
762 static void test_zone_read_by_name2(
void) {
766 static void test_zone_verify_name2(
void) {
777 CU_ASSERT_PTR_NOT_NULL_FATAL(
zone_name(
object));
778 CU_ASSERT(!strcmp(
zone_name(
object),
"name 2"));
803 static void test_zone_delete(
void) {
807 static void test_zone_list2(
void) {
812 static void test_zone_end(
void) {
815 CU_PASS(
"zone_free");
819 CU_PASS(
"zone_list_free");
823 static int test_zone_add_tests(CU_pSuite pSuite) {
824 if (!CU_add_test(pSuite,
"new object", test_zone_new)
825 || !CU_add_test(pSuite,
"set fields", test_zone_set)
826 || !CU_add_test(pSuite,
"get fields", test_zone_get)
827 || !CU_add_test(pSuite,
"create object", test_zone_create)
828 || !CU_add_test(pSuite,
"object clauses", test_zone_clauses)
829 || !CU_add_test(pSuite,
"object count", test_zone_count)
830 || !CU_add_test(pSuite,
"list objects", test_zone_list)
831 || !CU_add_test(pSuite,
"list objects (store)", test_zone_list_store)
832 || !CU_add_test(pSuite,
"list objects (associated)", test_zone_list_associated)
833 || !CU_add_test(pSuite,
"read object by id", test_zone_read)
834 || !CU_add_test(pSuite,
"verify fields", test_zone_verify)
835 || !CU_add_test(pSuite,
"read object by name", test_zone_read_by_name)
836 || !CU_add_test(pSuite,
"verify fields (name)", test_zone_verify_name)
837 || !CU_add_test(pSuite,
"change object", test_zone_change)
838 || !CU_add_test(pSuite,
"update object", test_zone_update)
839 || !CU_add_test(pSuite,
"reread object by id", test_zone_read2)
840 || !CU_add_test(pSuite,
"verify fields after update", test_zone_verify2)
841 || !CU_add_test(pSuite,
"reread object by name", test_zone_read_by_name2)
842 || !CU_add_test(pSuite,
"verify fields after update (name)", test_zone_verify_name2)
843 || !CU_add_test(pSuite,
"delete object", test_zone_delete)
844 || !CU_add_test(pSuite,
"list objects to verify delete", test_zone_list2)
845 || !CU_add_test(pSuite,
"end test", test_zone_end))
847 return CU_get_error();
853 CU_pSuite pSuite = NULL;
856 #if defined(ENFORCER_DATABASE_SQLITE3) 857 pSuite = CU_add_suite(
"Test of zone (SQLite)", test_zone_init_suite_sqlite, test_zone_clean_suite);
859 return CU_get_error();
861 ret = test_zone_add_tests(pSuite);
866 #if defined(ENFORCER_DATABASE_MYSQL) 867 pSuite = CU_add_suite(
"Test of zone (MySQL)", test_zone_init_suite_mysql, test_zone_clean_suite);
869 return CU_get_error();
871 ret = test_zone_add_tests(pSuite);
int zone_set_next_zsk_roll(zone_t *zone, unsigned int next_zsk_roll)
const char * zone_input_adapter_type(const zone_t *zone)
const char * zone_output_adapter_uri(const zone_t *zone)
const char * zone_signconf_path(const zone_t *zone)
const db_value_t * zone_policy_id(const zone_t *zone)
const zone_t * zone_list_next(zone_list_t *zone_list)
int zone_set_roll_csk_now(zone_t *zone, unsigned int roll_csk_now)
int zone_set_next_csk_roll(zone_t *zone, unsigned int next_csk_roll)
int zone_set_ttl_end_dk(zone_t *zone, unsigned int ttl_end_dk)
int db_connection_setup(db_connection_t *connection)
unsigned int zone_roll_zsk_now(const zone_t *zone)
db_configuration_t * db_configuration_new(void)
int db_value_copy(db_value_t *value, const db_value_t *from_value)
db_clause_list_t * db_clause_list_new(void)
int db_value_from_uint64(db_value_t *value, db_type_uint64_t from_uint64)
unsigned int zone_next_zsk_roll(const zone_t *zone)
int zone_set_roll_zsk_now(zone_t *zone, unsigned int roll_zsk_now)
int zone_set_signconf_path(zone_t *zone, const char *signconf_path_text)
int zone_update(zone_t *zone)
int zone_set_ttl_end_ds(zone_t *zone, unsigned int ttl_end_ds)
int zone_get_by_id(zone_t *zone, const db_value_t *id)
int db_configuration_set_name(db_configuration_t *configuration, const char *name)
void zone_list_free(zone_list_t *zone_list)
int zone_set_output_adapter_uri(zone_t *zone, const char *output_adapter_uri_text)
int zone_set_policy_id(zone_t *zone, const db_value_t *policy_id)
const char * zone_output_adapter_type(const zone_t *zone)
int zone_next_change(const zone_t *zone)
unsigned int zone_ttl_end_rs(const zone_t *zone)
int zone_set_input_adapter_uri(zone_t *zone, const char *input_adapter_uri_text)
int zone_get_by_name(zone_t *zone, const char *name)
int zone_list_object_store(zone_list_t *zone_list)
int zone_set_signconf_needs_writing(zone_t *zone, unsigned int signconf_needs_writing)
unsigned int zone_roll_csk_now(const zone_t *zone)
void zone_free(zone_t *zone)
void db_clause_list_free(db_clause_list_t *clause_list)
int db_configuration_list_add(db_configuration_list_t *configuration_list, db_configuration_t *configuration)
int db_value_cmp(const db_value_t *value_a, const db_value_t *value_b, int *result)
unsigned int zone_ttl_end_dk(const zone_t *zone)
int zone_set_next_ksk_roll(zone_t *zone, unsigned int next_ksk_roll)
zone_list_t * zone_list_new(const db_connection_t *connection)
unsigned int zone_roll_ksk_now(const zone_t *zone)
void db_configuration_free(db_configuration_t *configuration)
int zone_set_ttl_end_rs(zone_t *zone, unsigned int ttl_end_rs)
int zone_count(zone_t *zone, db_clause_list_t *clause_list, size_t *count)
zone_t * zone_new(const db_connection_t *connection)
void db_value_reset(db_value_t *value)
int zone_set_name(zone_t *zone, const char *name_text)
int zone_set_next_change(zone_t *zone, int next_change)
int zone_set_roll_ksk_now(zone_t *zone, unsigned int roll_ksk_now)
unsigned int zone_signconf_needs_writing(const zone_t *zone)
int zone_list_get_by_clauses(zone_list_t *zone_list, const db_clause_list_t *clause_list)
const zone_t * zone_list_begin(zone_list_t *zone_list)
const char * zone_name(const zone_t *zone)
int zone_set_output_adapter_type(zone_t *zone, const char *output_adapter_type_text)
zone_t * zone_list_get_next(zone_list_t *zone_list)
db_configuration_list_t * db_configuration_list_new(void)
unsigned int zone_next_csk_roll(const zone_t *zone)
int zone_list_get(zone_list_t *zone_list)
int test_zone_add_suite(void)
const db_value_t * zone_id(const zone_t *zone)
unsigned int zone_next_ksk_roll(const zone_t *zone)
int db_connection_set_configuration_list(db_connection_t *connection, const db_configuration_list_t *configuration_list)
zone_list_t * zone_list_new_get(const db_connection_t *connection)
int db_value_from_int32(db_value_t *value, db_type_int32_t from_int32)
void db_connection_free(db_connection_t *connection)
const char * zone_input_adapter_uri(const zone_t *zone)
int db_configuration_set_value(db_configuration_t *configuration, const char *value)
db_clause_t * zone_policy_id_clause(db_clause_list_t *clause_list, const db_value_t *policy_id)
const db_value_t * policy_id(const policy_t *policy)
int zone_create(zone_t *zone)
int zone_delete(zone_t *zone)
int db_connection_connect(const db_connection_t *connection)
db_connection_t * db_connection_new(void)
unsigned int zone_ttl_end_ds(const zone_t *zone)
int zone_set_input_adapter_type(zone_t *zone, const char *input_adapter_type_text)
void db_configuration_list_free(db_configuration_list_t *configuration_list)