const char *record_type;
const char *label;
int flag;
- void *rdata;
+ void *rdata = NULL;
size_t rdata_size;
GNUNET_assert(NULL != root);
GNUNET_JSON_GNSRECORD_EXPIRATION_TIME, &expiration_time,
GNUNET_JSON_GNSRECORD_FLAG, &flag,
GNUNET_JSON_GNSRECORD_LABEL, &label);
- if (GNUNET_SYSERR == unpack_state)
+ if (0 != unpack_state)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Error json object has a wrong format!\n");
gnsrecord_object->record_type = GNUNET_GNSRECORD_typename_to_number(record_type);
if (UINT32_MAX == gnsrecord_object->record_type)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,"Unsupported type");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,"Unsupported type\n");
+ GNUNET_free(gnsrecord_object);
return GNUNET_SYSERR;
}
if (GNUNET_OK
&rdata,
&rdata_size))
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,"Value invalid for record type");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,"Value invalid for record type\n");
+ GNUNET_free(gnsrecord_object);
return GNUNET_SYSERR;
}
}
else
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Expiration time invalid");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Expiration time invalid\n");
+ GNUNET_free_non_null(rdata);
+ GNUNET_free(gnsrecord_object);
return GNUNET_SYSERR;
}
// check if flag is a valid enum value
&& (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION != flag)
&& (GNUNET_GNSRECORD_RF_SHADOW_RECORD) != flag)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Flag invalid");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Flag invalid\n");
+ GNUNET_free_non_null(rdata);
+ GNUNET_free(gnsrecord_object);
return GNUNET_SYSERR;
}
gnsrecord_object->flags = (enum GNUNET_GNSRECORD_Flags)flag;
{
handle->emsg = GNUNET_strdup("Invalid data");
GNUNET_SCHEDULER_add_now (&do_error, handle);
- GNUNET_free_non_null(gns_record);
+ GNUNET_JSON_parse_free(gnsspec);
json_decref (data_js);
return;
}
+ handle->rd = gns_record;
+
name_json = json_object_get(data_js, "label");
if (!json_is_string(name_json))
{
handle->emsg = GNUNET_strdup("Missing name");
GNUNET_SCHEDULER_add_now (&do_error, handle);
- GNUNET_free_non_null(gns_record);
json_decref (data_js);
return;
}
{
handle->emsg = GNUNET_strdup("Missing name");
GNUNET_SCHEDULER_add_now (&do_error, handle);
- GNUNET_free_non_null(gns_record);
json_decref (data_js);
return;
}
{
handle->emsg = GNUNET_strdup("Missing name");
GNUNET_SCHEDULER_add_now (&do_error, handle);
- GNUNET_free_non_null(gns_record);
json_decref (data_js);
return;
}
json_decref (data_js);
- handle->rd = gns_record;
//change zone if pubkey or name specified
GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_PUBKEY,
{
handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego);
}
+ if (NULL == handle->zone_pkey)
+ {
+ handle->emsg = GNUNET_strdup("No default identity for namestore");
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle,
handle->zone_pkey,
handle->label_name,
}
handle->label_name = GNUNET_strdup(
GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key));
+
+ if (NULL == handle->zone_pkey)
+ {
+ handle->emsg = GNUNET_strdup("No default identity for namestore");
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+
handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle,
handle->zone_pkey,
handle->label_name,
#$1 is link
#$2 is grep
cache="$(curl -v "$1" 2>&1 | grep "$2")"
- echo $cache
+ #echo $cache
if [ "" == "$cache" ]
then
exit 1
#$2 is data
#$3 is grep
cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")"
- echo $cache
+ #echo $cache
if [ "" == "$cache" ]
then
exit 1
#$1 is link
#$2 is grep
cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")"
- echo $cache
+ #echo $cache
if [ "" == "$cache" ]
then
exit 1
curl_delete "${namestore_link}?label=test_entry&name=$name" "HTTP/1.1 204"
gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
curl_delete "${namestore_link}?label=test_entry&pubkey=$public" "HTTP/1.1 204"
+gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
+curl_delete "${namestore_link}?label=test_entry&pubkey=$name" "HTTP/1.1 404"
-exit 0;
-
-
-
-#pubkey zone
-#name zone
-curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 201 Created"
-curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 409"
-curl_post "${namestore_link}" '{"name":"Test_plugin_rest_identity"}' "HTTP/1.1 409"
-curl_post "${namestore_link}" '{}' "error"
-curl_post "${namestore_link}" '' "error"
-curl_post "${namestore_link}" '{"name":""}' "error"
-curl_post "${namestore_link}" '{"name":123}' "error"
-curl_post "${namestore_link}" '{"name":[]}' "error"
-curl_post "${namestore_link}" '{"name1":"test_plugin_rest_identity"}' "error"
-curl_post "${namestore_link}" '{"other":""}' "error"
-curl_post "${namestore_link}" '{"name":"test_plugin_rest_identity1", "other":"test_plugin_rest_identity2"}' "error"
-
-#Test PUT
-name="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $1}')"
-public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')"
-
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'"}' "HTTP/1.1 204"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'"}' "HTTP/1.1 409"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'xx"}' "HTTP/1.1 404"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubkey":""}' "HTTP/1.1 404"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":""}' "HTTP/1.1 404"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":"","other":"sdfdsf"}' "HTTP/1.1 404"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","pubke":"","name":"sdfdsf"}' "HTTP/1.1 404"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","pubke":"","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
-curl_put "${namestore_link}" '{"newnam":"test_plugin_rest_identity","pubkey":"'$public'"}' "error"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
-curl_put "${namestore_link}" '{"newname":"TEST_plugin_rest_identity1","name":"test_plugin_rest_identity1"}' "HTTP/1.1 409"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity1"}' "HTTP/1.1 409"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","name":"test_plugin_rest_identityxxx"}' "HTTP/1.1 404"
-curl_put "${namestore_link}" '{"newname":"test_plugin_rest_identity","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
-curl_put "${namestore_link}" '{"newnam":"test_plugin_rest_identityfail","name":"test_plugin_rest_identity"}' "error"
-
-
-#Test subsystem
-curl_put "${identity_link}" '{"subsystem":"namestore","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
-curl_put "${identity_link}" '{"subsystem":"namestore","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
-curl_get "${identity_link}?subsystem=namestore" "test_plugin_rest_identity"
-curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created"
-public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')"
-curl_put "${identity_link}" '{"subsystem":"namestore","pubkey":"'"$public"'"}' "HTTP/1.1 204"
-curl_get "${identity_link}?subsystem=namestore" "test_plugin_rest_identity1"
-curl_get "${identity_link}?subsystem=test_plugin_rest_identity_no_subsystem" "error"
-curl_put "${identity_link}" '{"subsystem":"test_plugin_rest_identity_no_subsystem","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
-curl_get "${identity_link}?subsystem=test_plugin_rest_identity_no_subsystem" "test_plugin_rest_identity1"
-
-curl_put "${identity_link}" '{"subsyste":"test_plugin_rest_identity_no_subsystem","name":"test_plugin_rest_identity1"}' "error"
-curl_put "${identity_link}" '{"subsystem":"test_plugin_rest_identity_no_subsystem","name":"Test_plugin_rest_identity1"}' "HTTP/1.1 204"
-
-#Test DELETE
-curl_delete "${identity_link}?name=test_plugin_rest_identity" "HTTP/1.1 204"
-curl_get "${identity_link}?name=test_plugin_rest_identity" "error"
-curl_delete "${identity_link}?name=TEST_plugin_rest_identity1" "HTTP/1.1 404"
-curl_delete "${identity_link}?name=test_plugin_rest_identity1" "HTTP/1.1 204"
-curl_get "${identity_link}?name=test_plugin_rest_identity1" "error"
-curl_delete "${identity_link}?name=test_plugin_rest_identity_not_found" "HTTP/1.1 404"
-curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created"
-public="$(gnunet-identity -d | grep "test_plugin_rest_identity1" | awk 'NR==1{print $3}')"
-curl_delete "${identity_link}?pubkey=$public" "HTTP/1.1 204"
-curl_delete "${identity_link}?pubke=$public" "error"
-curl_delete "${identity_link}?pubkey=$public&other=232" "HTTP/1.1 404"
-#test default subsystem
+#Test default identity
+#not possible without defining
exit 0;
+