added name search
authorPhil <phil.buschmann@tum.de>
Wed, 25 Jul 2018 15:43:37 +0000 (17:43 +0200)
committerPhil <phil.buschmann@tum.de>
Wed, 25 Jul 2018 15:43:37 +0000 (17:43 +0200)
src/identity/plugin_rest_identity.c
src/identity/test_plugin_rest_identity.sh

index f1d33b0f3aa85a9fb78c4c3ec3c2c0b7b2b5177e..59dad66c7782dc36d5494c14408fbed850af8cc6 100644 (file)
@@ -346,7 +346,8 @@ ego_get (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
               handle->subsystem);
 
     handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
-                                     handle->subsystem, &ego_get_for_subsystem,
+                                     handle->subsystem,
+                                     &ego_get_for_subsystem,
                                      handle);
     if (NULL == handle->op)
     {
@@ -359,9 +360,10 @@ ego_get (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
   egoname = NULL;
   keystring = NULL;
 
-  //if only one identity requested
+  //if only one identity requested with key
   GNUNET_CRYPTO_hash (GNUNET_REST_PARAM_PUBKEY,
-                     strlen (GNUNET_REST_PARAM_PUBKEY), &key);
+                     strlen (GNUNET_REST_PARAM_PUBKEY),
+                     &key);
   if ( GNUNET_YES
       == GNUNET_CONTAINER_multihashmap_contains (
          handle->rest_handle->url_param_map, &key))
@@ -379,6 +381,21 @@ ego_get (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
     }
   }
 
+  //if only one identity requested with name
+  if (NULL == egoname)
+  {
+    GNUNET_CRYPTO_hash (GNUNET_REST_PARAM_NAME,
+                       strlen (GNUNET_REST_PARAM_NAME),
+                       &key);
+    if ( GNUNET_YES
+       == GNUNET_CONTAINER_multihashmap_contains (
+           handle->rest_handle->url_param_map, &key))
+    {
+      egoname = GNUNET_CONTAINER_multihashmap_get (
+         handle->rest_handle->url_param_map, &key);
+    }
+  }
+
   json_root = json_array ();
   //Return ego/egos
   for (ego_entry = handle->ego_head;
index b48becc4562c9e8c1571e05672e8d27e934ddf47..170f3e92829ac831b9816e0fd944c6e06e828246 100755 (executable)
@@ -84,6 +84,12 @@ fi
 
 id="$(gnunet-identity -d | grep "Test - " | sed  "s/Test - //g")"
 #Test GET (one identity) for success and error json
+cache="$(curl --silent "${link_to_api}?name=Test" | grep "error")"
+if [ "" != "$cache" ]
+then
+    exit 1
+fi
+#Test GET (one identity) for success and error json
 cache="$(curl --silent "${link_to_api}?pubkey=$id" | grep "error")"
 if [ "" != "$cache" ]
 then