more management API tests and bugfixes
This commit is contained in:
parent
d3184e04e2
commit
9572337aed
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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 ()
|
||||
};
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user