aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2020-11-10 16:28:23 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2020-11-10 16:28:23 +0900
commit10081ef560ef3e624d4dcadf5e19f0330b078d64 (patch)
tree96457f981278c76a10c95befb323bdc890b81a87
parent5306c3356854b535fe09654b270f06615bf94e94 (diff)
downloadgnunet-10081ef560ef3e624d4dcadf5e19f0330b078d64.tar.gz
gnunet-10081ef560ef3e624d4dcadf5e19f0330b078d64.zip
-fix tests
-rw-r--r--src/gnsrecord/gnsrecord_misc.c32
-rw-r--r--src/namestore/test_namestore_api_zone_to_name.c3
-rwxr-xr-xsrc/namestore/test_plugin_rest_namestore.sh21
3 files changed, 31 insertions, 25 deletions
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 2e00141a3..82c38f19a 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -107,8 +107,8 @@ GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a,
107 { 107 {
108 LOG (GNUNET_ERROR_TYPE_DEBUG, 108 LOG (GNUNET_ERROR_TYPE_DEBUG,
109 "Expiration time %llu != %llu\n", 109 "Expiration time %llu != %llu\n",
110 a->expiration_time, 110 (unsigned long long) a->expiration_time,
111 b->expiration_time); 111 (unsigned long long) b->expiration_time);
112 return GNUNET_NO; 112 return GNUNET_NO;
113 } 113 }
114 if ((a->flags & GNUNET_GNSRECORD_RF_RCMP_FLAGS) 114 if ((a->flags & GNUNET_GNSRECORD_RF_RCMP_FLAGS)
@@ -282,11 +282,13 @@ GNUNET_GNSRECORD_identity_from_data (const char *data,
282 return GNUNET_SYSERR; 282 return GNUNET_SYSERR;
283 if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey)) 283 if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey))
284 return GNUNET_SYSERR; 284 return GNUNET_SYSERR;
285 return (GNUNET_IDENTITY_read_key_from_buffer(key, data, data_size) == data_size? 285 return (GNUNET_IDENTITY_read_key_from_buffer (key, data, data_size) ==
286 GNUNET_OK : 286 data_size?
287 GNUNET_SYSERR); 287 GNUNET_OK :
288 GNUNET_SYSERR);
288} 289}
289 290
291
290enum GNUNET_GenericReturnValue 292enum GNUNET_GenericReturnValue
291GNUNET_GNSRECORD_data_from_identity (const struct 293GNUNET_GNSRECORD_data_from_identity (const struct
292 GNUNET_IDENTITY_PublicKey *key, 294 GNUNET_IDENTITY_PublicKey *key,
@@ -294,14 +296,15 @@ GNUNET_GNSRECORD_data_from_identity (const struct
294 size_t *data_size, 296 size_t *data_size,
295 uint32_t *type) 297 uint32_t *type)
296{ 298{
297 *type = key->type; 299 *type = ntohl (key->type);
298 *data_size = GNUNET_IDENTITY_key_get_length (key); 300 *data_size = GNUNET_IDENTITY_key_get_length (key);
299 if (0 == *data_size) 301 if (0 == *data_size)
300 return GNUNET_SYSERR; 302 return GNUNET_SYSERR;
301 *data = GNUNET_malloc (*data_size); 303 *data = GNUNET_malloc (*data_size);
302 return (GNUNET_IDENTITY_write_key_to_buffer(key, data, *data_size) == *data_size? 304 return (GNUNET_IDENTITY_write_key_to_buffer (key, *data, *data_size) ==
303 GNUNET_OK : 305 *data_size?
304 GNUNET_SYSERR); 306 GNUNET_OK :
307 GNUNET_SYSERR);
305} 308}
306 309
307 310
@@ -310,14 +313,15 @@ GNUNET_GNSRECORD_is_zonekey_type (uint32_t type)
310{ 313{
311 switch (type) 314 switch (type)
312 { 315 {
313 case GNUNET_GNSRECORD_TYPE_PKEY: 316 case GNUNET_GNSRECORD_TYPE_PKEY:
314 case GNUNET_GNSRECORD_TYPE_EDKEY: 317 case GNUNET_GNSRECORD_TYPE_EDKEY:
315 return GNUNET_YES; 318 return GNUNET_YES;
316 default: 319 default:
317 return GNUNET_NO; 320 return GNUNET_NO;
318 } 321 }
319} 322}
320 323
324
321size_t 325size_t
322GNUNET_GNSRECORD_block_get_size (const struct GNUNET_GNSRECORD_Block *block) 326GNUNET_GNSRECORD_block_get_size (const struct GNUNET_GNSRECORD_Block *block)
323{ 327{
diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c
index e5ede6bcd..3fd10e4a1 100644
--- a/src/namestore/test_namestore_api_zone_to_name.c
+++ b/src/namestore/test_namestore_api_zone_to_name.c
@@ -212,12 +212,13 @@ run (void *cls,
212 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, 212 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
213 &s_zone_value, 213 &s_zone_value,
214 sizeof(s_zone_value)); 214 sizeof(s_zone_value));
215 s_zone_value.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY);
215 { 216 {
216 struct GNUNET_GNSRECORD_Data rd; 217 struct GNUNET_GNSRECORD_Data rd;
217 218
218 rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us; 219 rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us;
219 rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; 220 rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY;
220 rd.data_size = sizeof(s_zone_value); 221 rd.data_size = GNUNET_IDENTITY_key_get_length (&s_zone_value);
221 rd.data = &s_zone_value; 222 rd.data = &s_zone_value;
222 rd.flags = 0; 223 rd.flags = 0;
223 224
diff --git a/src/namestore/test_plugin_rest_namestore.sh b/src/namestore/test_plugin_rest_namestore.sh
index 12a7fa50c..8a45cebf5 100755
--- a/src/namestore/test_plugin_rest_namestore.sh
+++ b/src/namestore/test_plugin_rest_namestore.sh
@@ -84,14 +84,15 @@ gnunet-identity -C $TEST_ID -c test_namestore_api.conf
84test="$(gnunet-namestore -D -z $TEST_ID -c test_namestore_api.conf)" 84test="$(gnunet-namestore -D -z $TEST_ID -c test_namestore_api.conf)"
85name=$TEST_ID 85name=$TEST_ID
86public="$(gnunet-identity -d -c test_namestore_api.conf | grep $TEST_ID | awk 'NR==1{print $3}')" 86public="$(gnunet-identity -d -c test_namestore_api.conf | grep $TEST_ID | awk 'NR==1{print $3}')"
87gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -c test_namestore_api.conf 87echo "$name $public"
88valgrind gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8" -t "PKEY" -c test_namestore_api.conf
88#curl_get "${namestore_link}" "HTTP/1.1 200 OK" 89#curl_get "${namestore_link}" "HTTP/1.1 200 OK"
89curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK" 90curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK"
90curl_get "${namestore_link}/$public" "error" 91curl_get "${namestore_link}/$public" "error"
91gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf 92gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf
92 93
93#Test POST with NAME 94#Test POST with NAME
94curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204 No Content" 95curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
95gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 96gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
96 97
97# invalid values 98# invalid values
@@ -106,29 +107,29 @@ curl_post "${namestore_link}/$name" '{"data": [{"record_type":"PKEY", "expiratio
106gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 107gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
107 108
108#expirations 109#expirations
109curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"0d","private": false, "relative_expiration": true, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204" 110curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"0d","private": false, "relative_expiration": true, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204"
110gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 111gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
111 112
112curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"10000d","private": false, "relative_expiration": true, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204" 113curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"10000d","private": false, "relative_expiration": true, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "HTTP/1.1 204"
113gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 114gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
114 115
115curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"now","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "error" 116curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"now","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "error"
116gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 117gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
117 118
118curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time_missing":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "error" 119curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time_missing":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":"test_entry"}' "error"
119gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 120gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
120 121
121#record_name 122#record_name
122curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":""}' "error" 123curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name":""}' "error"
123gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 124gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
124curl_post "${namestore_link}/$name" '{"data": [{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name_missing":"test_entry"}' "error" 125curl_post "${namestore_link}/$name" '{"data": [{"value":"000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8", "record_type":"PKEY", "expiration_time":"1d","private": false, "relative_expiration": false, "supplemental": false, "shadow": false}],"record_name_missing":"test_entry"}' "error"
125gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1 126gnunet-namestore -z $name -d -n "test_entry" -c test_namestore_api.conf > /dev/null 2>&1
126 127
127#Test DELETE 128#Test DELETE
128gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -c test_namestore_api.conf 129gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8" -t "PKEY" -c test_namestore_api.conf
129curl_delete "${namestore_link}/$name/test_entry" "HTTP/1.1 204" 130curl_delete "${namestore_link}/$name/test_entry" "HTTP/1.1 204"
130curl_delete "${namestore_link}/$name/test_entry" "error" 131curl_delete "${namestore_link}/$name/test_entry" "error"
131gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY" -c test_namestore_api.conf 132gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "000G006WVZ8HQ5YTVFNX09HK0VJVVQ9ZCBYDSCH3ERT04N5ZRBKEB82EP8" -t "PKEY" -c test_namestore_api.conf
132curl_delete "${namestore_link}/$public/test_entry" "error" 133curl_delete "${namestore_link}/$public/test_entry" "error"
133 134
134gnunet-arm -e -c test_namestore_api.conf 135gnunet-arm -e -c test_namestore_api.conf