diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-08-21 09:53:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-08-21 09:53:53 +0000 |
commit | 35093e17511203a0924a1c64017e3abd1e72fc91 (patch) | |
tree | 25d45962fac712855c10fd3a9ca47ef7268d3fe9 /src/namestore | |
parent | 8414aa3d3a3eb463f3cadda5fb31dfc24c01f53b (diff) | |
download | gnunet-35093e17511203a0924a1c64017e3abd1e72fc91.tar.gz gnunet-35093e17511203a0924a1c64017e3abd1e72fc91.zip |
reorder tests: namestore_common -> plugins -> api
block test
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/Makefile.am | 37 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_blocks.c (renamed from src/namestore/test_namestore_api_sign_verify.c) | 66 |
2 files changed, 54 insertions, 49 deletions
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 2413005ab..8a5fa70a6 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -41,28 +41,27 @@ if HAVE_EXPERIMENTAL | |||
41 | 41 | ||
42 | if HAVE_TESTING | 42 | if HAVE_TESTING |
43 | TESTING_TESTS = \ | 43 | TESTING_TESTS = \ |
44 | test_namestore_api \ | 44 | test_namestore_api |
45 | test_namestore_api_put \ | 45 | #test_namestore_api_lookup \ |
46 | test_namestore_api_lookup \ | 46 | #test_namestore_api_lookup_specific_type \ |
47 | test_namestore_api_lookup_specific_type \ | 47 | #test_namestore_api_create \ |
48 | test_namestore_api_create \ | 48 | #test_namestore_api_create_update \ |
49 | test_namestore_api_create_update \ | 49 | #test_namestore_api_remove \ |
50 | test_namestore_api_remove \ | 50 | #test_namestore_api_remove_not_existing_record \ |
51 | test_namestore_api_remove_not_existing_record \ | 51 | #test_namestore_api_zone_to_name \ |
52 | test_namestore_api_zone_to_name \ | 52 | #test_namestore_api_monitoring \ |
53 | test_namestore_api_monitoring \ | 53 | #test_namestore_api_zone_iteration \ |
54 | test_namestore_api_zone_iteration \ | 54 | #test_namestore_api_zone_iteration_specific_zone \ |
55 | test_namestore_api_zone_iteration_specific_zone \ | 55 | #test_namestore_api_zone_iteration_stop |
56 | test_namestore_api_zone_iteration_stop | ||
57 | endif | 56 | endif |
58 | 57 | ||
59 | if HAVE_SQLITE | 58 | if HAVE_SQLITE |
60 | check_PROGRAMS = \ | 59 | check_PROGRAMS = \ |
60 | test_namestore_record_serialization \ | ||
61 | test_namestore_api_blocks \ | ||
61 | $(SQLITE_TESTS) \ | 62 | $(SQLITE_TESTS) \ |
62 | $(POSTGRES_TESTS) \ | 63 | $(POSTGRES_TESTS) \ |
63 | $(TESTING_TESTS) \ | 64 | $(TESTING_TESTS) |
64 | test_namestore_record_serialization \ | ||
65 | test_namestore_api_sign_verify | ||
66 | endif | 65 | endif |
67 | 66 | ||
68 | # end of 'HAVE_EXPERIMENTAL' for testcases | 67 | # end of 'HAVE_EXPERIMENTAL' for testcases |
@@ -173,9 +172,9 @@ libgnunet_plugin_namestore_postgres_la_DEPENDENCIES = \ | |||
173 | $(top_builddir)/src/util/libgnunetutil.la \ | 172 | $(top_builddir)/src/util/libgnunetutil.la \ |
174 | libgnunetnamestore.la | 173 | libgnunetnamestore.la |
175 | 174 | ||
176 | test_namestore_api_sign_verify_SOURCES = \ | 175 | test_namestore_api_blocks_SOURCES = \ |
177 | test_namestore_api_sign_verify.c | 176 | test_namestore_api_blocks.c |
178 | test_namestore_api_sign_verify_LDADD = \ | 177 | test_namestore_api_blocks_LDADD = \ |
179 | $(top_builddir)/src/util/libgnunetutil.la \ | 178 | $(top_builddir)/src/util/libgnunetutil.la \ |
180 | $(top_builddir)/src/testing/libgnunettesting.la \ | 179 | $(top_builddir)/src/testing/libgnunettesting.la \ |
181 | $(top_builddir)/src/namestore/libgnunetnamestore.la | 180 | $(top_builddir)/src/namestore/libgnunetnamestore.la |
diff --git a/src/namestore/test_namestore_api_sign_verify.c b/src/namestore/test_namestore_api_blocks.c index 41b9407e4..446a28c18 100644 --- a/src/namestore/test_namestore_api_sign_verify.c +++ b/src/namestore/test_namestore_api_blocks.c | |||
@@ -18,8 +18,8 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file namestore/test_namestore_api_sign_verify.c | 21 | * @file namestore/test_namestore_api_blocks.c |
22 | * @brief testcase for signing and verifying | 22 | * @brief testcase for block creation, verification and decryption |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
@@ -44,8 +44,6 @@ | |||
44 | 44 | ||
45 | static struct GNUNET_CRYPTO_EccPrivateKey * privkey; | 45 | static struct GNUNET_CRYPTO_EccPrivateKey * privkey; |
46 | 46 | ||
47 | static struct GNUNET_CRYPTO_EccPublicKey pubkey; | ||
48 | |||
49 | static struct GNUNET_NAMESTORE_RecordData *s_rd; | 47 | static struct GNUNET_NAMESTORE_RecordData *s_rd; |
50 | 48 | ||
51 | static char *s_name; | 49 | static char *s_name; |
@@ -73,10 +71,37 @@ create_record (int count) | |||
73 | 71 | ||
74 | 72 | ||
75 | static void | 73 | static void |
74 | rd_decrypt_cb (void *cls, | ||
75 | unsigned int rd_count, | ||
76 | const struct GNUNET_NAMESTORE_RecordData *rd) | ||
77 | { | ||
78 | char rd_cmp_data[TEST_RECORD_DATALEN]; | ||
79 | |||
80 | int c; | ||
81 | |||
82 | GNUNET_assert (RECORDS == rd_count); | ||
83 | GNUNET_assert (NULL != rd); | ||
84 | |||
85 | memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN); | ||
86 | |||
87 | for (c = 0; c < rd_count; c++) | ||
88 | { | ||
89 | GNUNET_assert (TEST_RECORD_TYPE == rd[c].record_type); | ||
90 | GNUNET_assert (TEST_RECORD_DATALEN == rd[c].data_size); | ||
91 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[c].data, TEST_RECORD_DATALEN)); | ||
92 | } | ||
93 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
94 | "Block was decrypted successfully \n"); | ||
95 | res = 0; | ||
96 | |||
97 | } | ||
98 | |||
99 | static void | ||
76 | run (void *cls, char *const *args, const char *cfgfile, | 100 | run (void *cls, char *const *args, const char *cfgfile, |
77 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 101 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
78 | { | 102 | { |
79 | struct GNUNET_CRYPTO_EccSignature * signature; | 103 | struct GNUNET_NAMESTORE_Block *block; |
104 | struct GNUNET_CRYPTO_EccPublicKey pubkey; | ||
80 | 105 | ||
81 | /* load privat key */ | 106 | /* load privat key */ |
82 | char *hostkey_file; | 107 | char *hostkey_file; |
@@ -90,35 +115,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
90 | /* get public key */ | 115 | /* get public key */ |
91 | GNUNET_CRYPTO_ecc_key_get_public(privkey, &pubkey); | 116 | GNUNET_CRYPTO_ecc_key_get_public(privkey, &pubkey); |
92 | 117 | ||
93 | int res_c; | ||
94 | int res_w; | ||
95 | |||
96 | /* create record */ | 118 | /* create record */ |
97 | s_name = "DUMMY.dummy.gnunet"; | 119 | s_name = "DUMMY.dummy.gnunet"; |
98 | s_rd = create_record (RECORDS); | 120 | s_rd = create_record (RECORDS); |
99 | 121 | ||
100 | signature = GNUNET_NAMESTORE_create_signature (privkey, expire, s_name, s_rd, RECORDS); | 122 | /* Create block */ |
101 | GNUNET_assert (signature != NULL); | 123 | GNUNET_assert (NULL != (block = GNUNET_NAMESTORE_block_create (privkey, expire,s_name, s_rd, RECORDS))); |
102 | 124 | GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_block_verify (block)); | |
103 | res_c = GNUNET_NAMESTORE_verify_signature(&pubkey, expire, s_name, RECORDS, s_rd, signature); | 125 | GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_block_decrypt (block, &pubkey, s_name, &rd_decrypt_cb, s_name)); |
104 | GNUNET_break (res == GNUNET_OK); | ||
105 | |||
106 | GNUNET_free (signature); | ||
107 | |||
108 | signature = GNUNET_NAMESTORE_create_signature (privkey, expire, s_name, s_rd, RECORDS); | ||
109 | GNUNET_break (signature != NULL); | ||
110 | |||
111 | GNUNET_log_skip(1, GNUNET_NO); | ||
112 | res_w = GNUNET_NAMESTORE_verify_signature(&pubkey, expire, s_name, RECORDS - 1, s_rd, signature); | ||
113 | GNUNET_break (res_w == GNUNET_SYSERR); | ||
114 | |||
115 | GNUNET_free (signature); | ||
116 | |||
117 | if ((res_c == GNUNET_OK) && (res_w == GNUNET_SYSERR)) | ||
118 | res = 0; | ||
119 | else | ||
120 | res = 1; | ||
121 | 126 | ||
127 | GNUNET_free (block); | ||
122 | } | 128 | } |
123 | 129 | ||
124 | 130 | ||
@@ -140,4 +146,4 @@ main (int argc, char *argv[]) | |||
140 | return res; | 146 | return res; |
141 | } | 147 | } |
142 | 148 | ||
143 | /* end of test_namestore_api_sign_verify.c */ | 149 | /* end of test_namestore_api_blocks.c */ |