summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-12-01 21:07:56 +0100
committerChristian Grothoff <christian@grothoff.org>2020-12-01 21:07:56 +0100
commit9572337aed3ebc5f0654db11c10babc88560c481 (patch)
treebd03657b4116cbbe53995e5db2c41cbd3be64ba6 /src
parentd3184e04e2a604673655899989707664736b3468 (diff)
downloadexchange-9572337aed3ebc5f0654db11c10babc88560c481.tar.gz
exchange-9572337aed3ebc5f0654db11c10babc88560c481.tar.bz2
exchange-9572337aed3ebc5f0654db11c10babc88560c481.zip
more management API tests and bugfixes
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-httpd.c4
-rw-r--r--src/exchange/taler-exchange-httpd_management_wire.c38
-rw-r--r--src/exchange/taler-exchange-httpd_management_wire_disable.c7
-rw-r--r--src/exchange/taler-exchange-httpd_management_wire_fees.c2
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c2
-rw-r--r--src/lib/exchange_api_management_set_wire_fee.c2
-rw-r--r--src/lib/exchange_api_management_wire_enable.c4
-rw-r--r--src/testing/test_exchange_management_api.c58
-rw-r--r--src/testing/testing_api_cmd_wire_add.c11
9 files changed, 83 insertions, 45 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 4896c8d46..fe00bf6d4 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 b684a107e..2ec42c3bc 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 d869d54d4..af5942a1b 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 3ec262cf4..58f2c41d7 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 1a591bb80..7918f540b 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 8d2966489..511f431d0 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 f841098e0..9be4dfb12 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 e44d5c8cd..232944094 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 698e02399..6f25a0f86 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,