From: Schanzenbach, Martin Date: Mon, 9 Oct 2017 09:07:28 +0000 (+0200) Subject: -fixes X-Git-Tag: gnunet-0.11.0rc0~24^2~28 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=037bf3d5a227287e4b2e9c4dbb2583f39bd8fa20;p=oweals%2Fgnunet.git -fixes --- diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/identity-provider/plugin_rest_identity_provider.c index 0ba0666d0..f136901a0 100644 --- a/src/identity-provider/plugin_rest_identity_provider.c +++ b/src/identity-provider/plugin_rest_identity_provider.c @@ -239,11 +239,6 @@ struct RequestHandle */ struct GNUNET_JSONAPI_Document *resp_object; - /** - * Resource object - */ - struct GNUNET_JSONAPI_Resource *json_resource; - }; @@ -397,6 +392,7 @@ static void ticket_collect (void *cls, const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket) { + struct GNUNET_JSONAPI_Resource *json_resource; struct RequestHandle *handle = cls; json_t *value; char* tmp; @@ -404,15 +400,15 @@ ticket_collect (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n"); tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); - handle->json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_IDENTITY_TICKET, + json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_IDENTITY_TICKET, tmp); GNUNET_free (tmp); - GNUNET_JSONAPI_document_resource_add (handle->resp_object, handle->json_resource); + GNUNET_JSONAPI_document_resource_add (handle->resp_object, json_resource); tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->identity, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); value = json_string (tmp); - GNUNET_JSONAPI_resource_add_attr (handle->json_resource, + GNUNET_JSONAPI_resource_add_attr (json_resource, "issuer", value); GNUNET_free (tmp); @@ -420,7 +416,7 @@ ticket_collect (void *cls, tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->audience, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); value = json_string (tmp); - GNUNET_JSONAPI_resource_add_attr (handle->json_resource, + GNUNET_JSONAPI_resource_add_attr (json_resource, "audience", value); GNUNET_free (tmp); @@ -428,7 +424,7 @@ ticket_collect (void *cls, tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); value = json_string (tmp); - GNUNET_JSONAPI_resource_add_attr (handle->json_resource, + GNUNET_JSONAPI_resource_add_attr (json_resource, "rnd", value); GNUNET_free (tmp); @@ -535,7 +531,7 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, ego_entry = ego_entry->next) if (0 == strcmp (identity, ego_entry->identifier)) break; - + if (NULL == ego_entry) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -620,14 +616,19 @@ attr_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_IDENTITY_PROVIDER_Attribute *attr) { + struct GNUNET_JSONAPI_Resource *json_resource; struct RequestHandle *handle = cls; json_t *value; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); + json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE, + attr->name); + GNUNET_JSONAPI_document_resource_add (handle->resp_object, json_resource); + value = json_string (attr->data); - GNUNET_JSONAPI_resource_add_attr (handle->json_resource, - attr->name, + GNUNET_JSONAPI_resource_add_attr (json_resource, + "value", value); json_decref (value); GNUNET_IDENTITY_PROVIDER_get_attributes_next (handle->attr_it); @@ -670,9 +671,6 @@ list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, break; handle->resp_object = GNUNET_JSONAPI_document_new (); - handle->json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE, - identity); - GNUNET_JSONAPI_document_resource_add (handle->resp_object, handle->json_resource); if (NULL == ego_entry) { diff --git a/src/identity-provider/test_idp_attribute.sh b/src/identity-provider/test_idp_attribute.sh index 6c357128f..0b0436ede 100755 --- a/src/identity-provider/test_idp_attribute.sh +++ b/src/identity-provider/test_idp_attribute.sh @@ -24,10 +24,11 @@ which timeout &> /dev/null && DO_TIMEOUT="timeout 30" TEST_ATTR="test" gnunet-arm -s -c test_idp.conf +gnunet-arm -i rest -c test_idp.conf gnunet-identity -C testego -c test_idp.conf gnunet-identity -C rpego -c test_idp.conf TEST_KEY=$(gnunet-identity -d -c test_idp.conf | grep testego | awk '{print $3}') gnunet-idp -e testego -a email -V john@doe.gnu -c test_idp.conf gnunet-idp -e testego -a name -V John -c test_idp.conf -gnunet-namestore -D -z testego -D -c test_idp.conf +curl localhost:7776/idp/attributes/testego gnunet-arm -e -c test_idp.conf