gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: more management API tests and bu


From: gnunet
Subject: [taler-exchange] branch master updated: more management API tests and bugfixes
Date: Tue, 01 Dec 2020 21:08:01 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 9572337a more management API tests and bugfixes
9572337a is described below

commit 9572337aed3ebc5f0654db11c10babc88560c481
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Dec 1 21:07:56 2020 +0100

    more management API tests and bugfixes
---
 src/exchange/taler-exchange-httpd.c                |  4 +-
 .../taler-exchange-httpd_management_wire.c         | 38 +++++---------
 .../taler-exchange-httpd_management_wire_disable.c |  7 ++-
 .../taler-exchange-httpd_management_wire_fees.c    |  2 +-
 src/exchangedb/plugin_exchangedb_postgres.c        |  2 +-
 src/lib/exchange_api_management_set_wire_fee.c     |  2 +-
 src/lib/exchange_api_management_wire_enable.c      |  4 +-
 src/testing/test_exchange_management_api.c         | 58 ++++++++++++++++++++++
 src/testing/testing_api_cmd_wire_add.c             | 11 ++--
 9 files changed, 83 insertions(+), 45 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd.c 
b/src/exchange/taler-exchange-httpd.c
index 4896c8d4..fe00bf6d 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -631,12 +631,12 @@ handle_post_management (const struct TEH_RequestHandler 
*rh,
                                                               root);
   }
   if (0 == strcmp (args[0],
-                   "wire-fees"))
+                   "wire-fee"))
   {
     if (NULL != args[1])
     {
       GNUNET_break_op (0);
-      return r404 (connection, "/management/wire-fees/*");
+      return r404 (connection, "/management/wire-fee/*");
     }
     return TEH_handler_management_post_wire_fees (connection,
                                                   root);
diff --git a/src/exchange/taler-exchange-httpd_management_wire.c 
b/src/exchange/taler-exchange-httpd_management_wire.c
index b684a107..2ec42c3b 100644
--- a/src/exchange/taler-exchange-httpd_management_wire.c
+++ b/src/exchange/taler-exchange-httpd_management_wire.c
@@ -175,9 +175,8 @@ TEH_handler_management_denominations_wire (
       .start_date = GNUNET_TIME_absolute_hton (awc.validity_start),
     };
 
-    GNUNET_CRYPTO_hash (awc.payto_uri,
-                        strlen (awc.payto_uri) + 1,
-                        &aw.h_wire);
+    TALER_exchange_wire_signature_hash (awc.payto_uri,
+                                        &aw.h_wire);
     if (GNUNET_OK !=
         GNUNET_CRYPTO_eddsa_verify (
           TALER_SIGNATURE_MASTER_ADD_WIRE,
@@ -193,30 +192,17 @@ TEH_handler_management_denominations_wire (
         NULL);
     }
   }
+  if (GNUNET_OK !=
+      TALER_exchange_wire_signature_check (awc.payto_uri,
+                                           &TEH_master_public_key,
+                                           &awc.master_sig_wire))
   {
-    struct TALER_MasterWireDetailsPS wd = {
-      .purpose.purpose = htonl (
-        TALER_SIGNATURE_MASTER_ADD_WIRE),
-      .purpose.size = htonl (sizeof (wd)),
-    };
-
-    GNUNET_CRYPTO_hash (awc.payto_uri,
-                        strlen (awc.payto_uri) + 1,
-                        &wd.h_wire_details);
-    if (GNUNET_OK !=
-        GNUNET_CRYPTO_eddsa_verify (
-          TALER_SIGNATURE_MASTER_WIRE_DETAILS,
-          &wd,
-          &awc.master_sig_wire.eddsa_signature,
-          &TEH_master_public_key.eddsa_pub))
-    {
-      GNUNET_break_op (0);
-      return TALER_MHD_reply_with_error (
-        connection,
-        MHD_HTTP_FORBIDDEN,
-        TALER_EC_EXCHANGE_MANAGEMENT_WIRE_DETAILS_SIGNATURE_INVALID,
-        NULL);
-    }
+    GNUNET_break_op (0);
+    return TALER_MHD_reply_with_error (
+      connection,
+      MHD_HTTP_FORBIDDEN,
+      TALER_EC_EXCHANGE_MANAGEMENT_WIRE_DETAILS_SIGNATURE_INVALID,
+      NULL);
   }
 
   qs = TEH_DB_run_transaction (connection,
diff --git a/src/exchange/taler-exchange-httpd_management_wire_disable.c 
b/src/exchange/taler-exchange-httpd_management_wire_disable.c
index d869d54d..af5942a1 100644
--- a/src/exchange/taler-exchange-httpd_management_wire_disable.c
+++ b/src/exchange/taler-exchange-httpd_management_wire_disable.c
@@ -139,7 +139,7 @@ TEH_handler_management_denominations_wire_disable (
 {
   struct DelWireContext awc;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_fixed_auto ("master_sig",
+    GNUNET_JSON_spec_fixed_auto ("master_sig_del",
                                  &awc.master_sig),
     GNUNET_JSON_spec_string ("payto_uri",
                              &awc.payto_uri),
@@ -169,9 +169,8 @@ TEH_handler_management_denominations_wire_disable (
       .end_date = GNUNET_TIME_absolute_hton (awc.validity_end),
     };
 
-    GNUNET_CRYPTO_hash (awc.payto_uri,
-                        strlen (awc.payto_uri) + 1,
-                        &aw.h_wire);
+    TALER_exchange_wire_signature_hash (awc.payto_uri,
+                                        &aw.h_wire);
     if (GNUNET_OK !=
         GNUNET_CRYPTO_eddsa_verify (
           TALER_SIGNATURE_MASTER_DEL_WIRE,
diff --git a/src/exchange/taler-exchange-httpd_management_wire_fees.c 
b/src/exchange/taler-exchange-httpd_management_wire_fees.c
index 3ec262cf..58f2c41d 100644
--- a/src/exchange/taler-exchange-httpd_management_wire_fees.c
+++ b/src/exchange/taler-exchange-httpd_management_wire_fees.c
@@ -199,7 +199,7 @@ TEH_handler_management_post_wire_fees (
       return MHD_YES; /* failure */
   }
 
-  if (0 !=
+  if (GNUNET_OK !=
       TALER_amount_cmp_currency (&afc.closing_fee,
                                  &afc.wire_fee))
   {
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 1a591bb8..7918f540 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -7664,8 +7664,8 @@ postgres_insert_wire (void *cls,
 {
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_string (payto_uri),
-    GNUNET_PQ_query_param_absolute_time (&start_date),
     GNUNET_PQ_query_param_auto_from_type (master_sig),
+    GNUNET_PQ_query_param_absolute_time (&start_date),
     GNUNET_PQ_query_param_end
   };
 
diff --git a/src/lib/exchange_api_management_set_wire_fee.c 
b/src/lib/exchange_api_management_set_wire_fee.c
index 8d296648..511f431d 100644
--- a/src/lib/exchange_api_management_set_wire_fee.c
+++ b/src/lib/exchange_api_management_set_wire_fee.c
@@ -152,7 +152,7 @@ TALER_EXCHANGE_management_set_wire_fees (
     GNUNET_free (swfh);
     return NULL;
   }
-  body = json_pack ("{s:s, s:o, s:o, s:o, s:o}",
+  body = json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
                     "wire_method",
                     wire_method,
                     "master_sig",
diff --git a/src/lib/exchange_api_management_wire_enable.c 
b/src/lib/exchange_api_management_wire_enable.c
index f841098e..9be4dfb1 100644
--- a/src/lib/exchange_api_management_wire_enable.c
+++ b/src/lib/exchange_api_management_wire_enable.c
@@ -137,7 +137,7 @@ TALER_EXCHANGE_management_enable_wire (
   wh->cb_cls = cb_cls;
   wh->ctx = ctx;
   wh->url = TALER_url_join (url,
-                            "management/wire/enable",
+                            "management/wire",
                             NULL);
   if (NULL == wh->url)
   {
@@ -146,7 +146,7 @@ TALER_EXCHANGE_management_enable_wire (
     GNUNET_free (wh);
     return NULL;
   }
-  body = json_pack ("{s:s, s:s, s:o, s:o, s:o}",
+  body = json_pack ("{s:s, s:o, s:o, s:o}",
                     "payto_uri",
                     payto_uri,
                     "master_sig_add",
diff --git a/src/testing/test_exchange_management_api.c 
b/src/testing/test_exchange_management_api.c
index e44d5c8c..23294409 100644
--- a/src/testing/test_exchange_management_api.c
+++ b/src/testing/test_exchange_management_api.c
@@ -82,6 +82,64 @@ run (void *cls,
     TALER_TESTING_cmd_auditor_del ("del-auditor-IDEMPOTENT",
                                    MHD_HTTP_NO_CONTENT,
                                    false),
+    TALER_TESTING_cmd_set_wire_fee ("set-fee",
+                                    "foo-method",
+                                    "EUR:1",
+                                    "EUR:5",
+                                    MHD_HTTP_NO_CONTENT,
+                                    false),
+    TALER_TESTING_cmd_set_wire_fee ("set-fee-conflicting",
+                                    "foo-method",
+                                    "EUR:1",
+                                    "EUR:1",
+                                    MHD_HTTP_CONFLICT,
+                                    false),
+    TALER_TESTING_cmd_set_wire_fee ("set-fee-bad-signature",
+                                    "bar-method",
+                                    "EUR:1",
+                                    "EUR:1",
+                                    MHD_HTTP_FORBIDDEN,
+                                    true),
+    TALER_TESTING_cmd_set_wire_fee ("set-fee-other-method",
+                                    "bar-method",
+                                    "EUR:1",
+                                    "EUR:1",
+                                    MHD_HTTP_NO_CONTENT,
+                                    false),
+    TALER_TESTING_cmd_set_wire_fee ("set-fee-idempotent",
+                                    "bar-method",
+                                    "EUR:1",
+                                    "EUR:1",
+                                    MHD_HTTP_NO_CONTENT,
+                                    false),
+    TALER_TESTING_cmd_wire_add ("add-wire-account",
+                                "payto://x-taler-bank/localhost/42",
+                                MHD_HTTP_NO_CONTENT,
+                                false),
+    TALER_TESTING_cmd_wire_add ("add-wire-account-idempotent",
+                                "payto://x-taler-bank/localhost/42",
+                                MHD_HTTP_NO_CONTENT,
+                                false),
+    TALER_TESTING_cmd_wire_add ("add-wire-account-another",
+                                "payto://x-taler-bank/localhost/43",
+                                MHD_HTTP_NO_CONTENT,
+                                false),
+    TALER_TESTING_cmd_wire_add ("add-wire-account-bad-signature",
+                                "payto://x-taler-bank/localhost/44",
+                                MHD_HTTP_FORBIDDEN,
+                                true),
+    TALER_TESTING_cmd_wire_del ("del-wire-account-not-found",
+                                "payto://x-taler-bank/localhost/44",
+                                MHD_HTTP_NOT_FOUND,
+                                false),
+    TALER_TESTING_cmd_wire_del ("del-wire-account-bad-signature",
+                                "payto://x-taler-bank/localhost/43",
+                                MHD_HTTP_FORBIDDEN,
+                                true),
+    TALER_TESTING_cmd_wire_del ("del-wire-account-ok",
+                                "payto://x-taler-bank/localhost/43",
+                                MHD_HTTP_NO_CONTENT,
+                                false),
     TALER_TESTING_cmd_end ()
   };
 
diff --git a/src/testing/testing_api_cmd_wire_add.c 
b/src/testing/testing_api_cmd_wire_add.c
index 698e0239..6f25a0f8 100644
--- a/src/testing/testing_api_cmd_wire_add.c
+++ b/src/testing/testing_api_cmd_wire_add.c
@@ -131,20 +131,15 @@ wire_add_run (void *cls,
       .purpose.size = htonl (sizeof (kv)),
       .start_date = GNUNET_TIME_absolute_hton (now),
     };
-    struct TALER_MasterWireDetailsPS wd = {
-      .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_DETAILS),
-      .purpose.size = htonl (sizeof (wd)),
-    };
 
     TALER_exchange_wire_signature_hash (ds->payto_uri,
                                         &kv.h_wire);
-    wd.h_wire_details = kv.h_wire;
     GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
                               &kv,
                               &master_sig1.eddsa_signature);
-    GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
-                              &wd,
-                              &master_sig2.eddsa_signature);
+    TALER_exchange_wire_signature_make (ds->payto_uri,
+                                        &is->master_priv,
+                                        &master_sig2);
   }
   ds->dh = TALER_EXCHANGE_management_enable_wire (
     is->ctx,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]