fix tests
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>
Tue, 10 Apr 2018 12:32:03 +0000 (14:32 +0200)
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>
Tue, 10 Apr 2018 12:32:03 +0000 (14:32 +0200)
src/identity-provider/gnunet-idp.c
src/identity-provider/gnunet-service-identity-provider.c
src/identity-provider/identity_provider_api.c
src/identity-provider/test_idp_revoke.sh

index 1f1036d4408ce433f20b6b85beb48986e7aba0fd..4f17919b9597d4406b8535de615bbf044ea942fa 100644 (file)
@@ -131,9 +131,18 @@ static struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attr_list;
  */
 static struct GNUNET_TIME_Relative exp_interval;
 
+/**
+ * Timeout task
+ */
+static struct GNUNET_SCHEDULER_Task *timeout;
+
 static void
 do_cleanup(void *cls)
 {
+  if (NULL != timeout)
+    GNUNET_SCHEDULER_cancel (timeout);
+  if (NULL != idp_op)
+    GNUNET_IDENTITY_PROVIDER_cancel (idp_op);
   if (NULL != attr_iterator)
     GNUNET_IDENTITY_PROVIDER_get_attributes_stop (attr_iterator);
   if (NULL != idp_handle)
@@ -151,6 +160,7 @@ ticket_issue_cb (void* cls,
                  const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket)
 {
   char* ticket_str;
+  idp_op = NULL;
   if (NULL != ticket) {
     ticket_str = GNUNET_STRINGS_data_to_string_alloc (ticket,
                                                       sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket));
@@ -166,6 +176,7 @@ store_attr_cont (void *cls,
                  int32_t success,
                  const char*emsg)
 {
+  idp_op = NULL;
   if (GNUNET_SYSERR == success) {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "%s\n", emsg);
@@ -181,6 +192,7 @@ process_attrs (void *cls,
   char *value_str;
   if (NULL == identity)
   {
+    idp_op = NULL;
     GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
     return;
   }
@@ -206,9 +218,20 @@ iter_error (void *cls)
   GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
 }
 
+static void
+timeout_task (void *cls)
+{
+  timeout = NULL;
+  ret = 1;
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+              "Timeout\n");
+  GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
+}
+
 static void
 process_rvk (void *cls, int success, const char* msg)
 {
+  idp_op = NULL;
   if (GNUNET_OK != success)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
@@ -250,6 +273,9 @@ iter_finished (void *cls)
                                                       &ticket,
                                                       &process_attrs,
                                                       NULL);
+    timeout = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10),
+                                            &timeout_task,
+                                            NULL);
     return;
   }
   if (revoke_ticket)
@@ -445,10 +471,10 @@ main(int argc, char *const argv[])
 
     GNUNET_GETOPT_OPTION_END
   };
-  if (GNUNET_OK == GNUNET_PROGRAM_run (argc, argv, "ct",
+  if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "ct",
                       "ct", options,
                       &run, NULL))
-    return 0;
-  else
     return 1;
+  else
+    return ret;
 }
index b738ffc82ab192a87a50efcb83ab2fc63c4d2dcd..5fc9a11e2c06c907396b01eaa46bbd984d5729b2 100644 (file)
@@ -1565,6 +1565,22 @@ handle_revoke_ticket_message (void *cls,
 static void
 cleanup_consume_ticket_handle (struct ConsumeTicketHandle *handle)
 {
+  struct ParallelLookup *lu;  
+  struct ParallelLookup *tmp;
+  if (NULL != handle->lookup_request)
+    GNUNET_GNS_lookup_cancel (handle->lookup_request);
+  for (lu = handle->parallel_lookups_head;
+       NULL != lu;) {
+    GNUNET_GNS_lookup_cancel (lu->lookup_request);
+    GNUNET_free (lu->label);
+    tmp = lu->next;
+    GNUNET_CONTAINER_DLL_remove (handle->parallel_lookups_head,
+                                 handle->parallel_lookups_tail,
+                                 lu);
+    GNUNET_free (lu);
+    lu = tmp;
+  }
+
   if (NULL != handle->key)
     GNUNET_ABE_cpabe_delete_key (handle->key,
                                  GNUNET_YES);
@@ -1690,7 +1706,8 @@ abort_parallel_lookups2 (void *cls)
   struct ParallelLookup *tmp;
   struct AttributeResultMessage *arm;
   struct GNUNET_MQ_Envelope *env;
-
+  
+  handle->kill_task = NULL;
   for (lu = handle->parallel_lookups_head;
        NULL != lu;) {
     GNUNET_GNS_lookup_cancel (lu->lookup_request);
index 21ce6e3d67db26807166aff7c9ee942dd5f619cf..47217442a2db7c89ae4c3cda2708613df11ecc53 100644 (file)
@@ -873,7 +873,6 @@ GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op)
   GNUNET_CONTAINER_DLL_remove (h->op_head,
                                h->op_tail,
                                op);
-  GNUNET_MQ_discard (op->env);
   free_op (op);
 }
 
index 6943fcf4f727e2569d659079e0f628493565dd34..7a3f5d030107580f8815a878f6836638fbac2383 100755 (executable)
@@ -23,7 +23,7 @@ rm -rf `gnunet-config -c test_idp.conf -s PATHS -o GNUNET_HOME -f`
 which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
 
 TEST_ATTR="test"
-gnunet-arm -s -c test_idp.conf
+gnunet-arm -s -c test_idp.conf 2&>1 > /dev/null
 gnunet-identity -C alice -c test_idp.conf
 gnunet-identity -C bob -c test_idp.conf
 gnunet-identity -C eve -c test_idp.conf
@@ -31,8 +31,8 @@ ALICE_KEY=$(gnunet-identity -d -c test_idp.conf | grep alice | awk '{print $3}')
 BOB_KEY=$(gnunet-identity -d -c test_idp.conf | grep bob | awk '{print $3}')
 EVE_KEY=$(gnunet-identity -d -c test_idp.conf | grep eve | awk '{print $3}')
 
-gnunet-idp -e alice -E 1s -a email -V john@doe.gnu -c test_idp.conf 
-gnunet-idp -e alice -E 1s -a name -V John -c test_idp.conf
+gnunet-idp -e alice -E 15s -a email -V john@doe.gnu -c test_idp.conf 
+gnunet-idp -e alice -E 15s -a name -V John -c test_idp.conf
 TICKET_BOB=$(gnunet-idp -e alice -i "email,name" -r $BOB_KEY -c test_idp.conf | awk '{print $1}')
 #gnunet-idp -e bob -C $TICKET_BOB -c test_idp.conf
 TICKET_EVE=$(gnunet-idp -e alice -i "email" -r $EVE_KEY -c test_idp.conf | awk '{print $1}')
@@ -41,16 +41,20 @@ TICKET_EVE=$(gnunet-idp -e alice -i "email" -r $EVE_KEY -c test_idp.conf | awk '
 #gnunet-idp -e eve -C $TICKET_EVE -c test_idp.conf
 gnunet-idp -e alice -R $TICKET_EVE -c test_idp.conf
 
-sleep 2
+#sleep 6
 
-gnunet-idp -e eve -C $TICKET_EVE -c test_idp.conf  > /dev/null 2>&1
+gnunet-idp -e eve -C $TICKET_EVE -c test_idp.conf 2&>1 >/dev/null
 if test $? == 0
 then 
   echo "Eve can still resolve attributes..."
   gnunet-arm -e -c test_idp.conf
   exit 1
 fi
-gnunet-idp -e bob -C $TICKET_BOB -c test_idp.conf > /dev/null 2>&1
+
+gnunet-arm -e -c test_idp.conf
+gnunet-arm -s -c test_idp.conf 2&>1 > /dev/null
+
+gnunet-idp -e bob -C $TICKET_BOB -c test_idp.conf 2&>1 >/dev/null
 if test $? != 0
 then
   echo "Bob cannot resolve attributes..."