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);
|
root);
|
||||||
}
|
}
|
||||||
if (0 == strcmp (args[0],
|
if (0 == strcmp (args[0],
|
||||||
"wire-fees"))
|
"wire-fee"))
|
||||||
{
|
{
|
||||||
if (NULL != args[1])
|
if (NULL != args[1])
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
return r404 (connection, "/management/wire-fees/*");
|
return r404 (connection, "/management/wire-fee/*");
|
||||||
}
|
}
|
||||||
return TEH_handler_management_post_wire_fees (connection,
|
return TEH_handler_management_post_wire_fees (connection,
|
||||||
root);
|
root);
|
||||||
|
@ -175,9 +175,8 @@ TEH_handler_management_denominations_wire (
|
|||||||
.start_date = GNUNET_TIME_absolute_hton (awc.validity_start),
|
.start_date = GNUNET_TIME_absolute_hton (awc.validity_start),
|
||||||
};
|
};
|
||||||
|
|
||||||
GNUNET_CRYPTO_hash (awc.payto_uri,
|
TALER_exchange_wire_signature_hash (awc.payto_uri,
|
||||||
strlen (awc.payto_uri) + 1,
|
&aw.h_wire);
|
||||||
&aw.h_wire);
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_verify (
|
GNUNET_CRYPTO_eddsa_verify (
|
||||||
TALER_SIGNATURE_MASTER_ADD_WIRE,
|
TALER_SIGNATURE_MASTER_ADD_WIRE,
|
||||||
@ -193,30 +192,17 @@ TEH_handler_management_denominations_wire (
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_exchange_wire_signature_check (awc.payto_uri,
|
||||||
|
&TEH_master_public_key,
|
||||||
|
&awc.master_sig_wire))
|
||||||
{
|
{
|
||||||
struct TALER_MasterWireDetailsPS wd = {
|
GNUNET_break_op (0);
|
||||||
.purpose.purpose = htonl (
|
return TALER_MHD_reply_with_error (
|
||||||
TALER_SIGNATURE_MASTER_ADD_WIRE),
|
connection,
|
||||||
.purpose.size = htonl (sizeof (wd)),
|
MHD_HTTP_FORBIDDEN,
|
||||||
};
|
TALER_EC_EXCHANGE_MANAGEMENT_WIRE_DETAILS_SIGNATURE_INVALID,
|
||||||
|
NULL);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qs = TEH_DB_run_transaction (connection,
|
qs = TEH_DB_run_transaction (connection,
|
||||||
|
@ -139,7 +139,7 @@ TEH_handler_management_denominations_wire_disable (
|
|||||||
{
|
{
|
||||||
struct DelWireContext awc;
|
struct DelWireContext awc;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("master_sig",
|
GNUNET_JSON_spec_fixed_auto ("master_sig_del",
|
||||||
&awc.master_sig),
|
&awc.master_sig),
|
||||||
GNUNET_JSON_spec_string ("payto_uri",
|
GNUNET_JSON_spec_string ("payto_uri",
|
||||||
&awc.payto_uri),
|
&awc.payto_uri),
|
||||||
@ -169,9 +169,8 @@ TEH_handler_management_denominations_wire_disable (
|
|||||||
.end_date = GNUNET_TIME_absolute_hton (awc.validity_end),
|
.end_date = GNUNET_TIME_absolute_hton (awc.validity_end),
|
||||||
};
|
};
|
||||||
|
|
||||||
GNUNET_CRYPTO_hash (awc.payto_uri,
|
TALER_exchange_wire_signature_hash (awc.payto_uri,
|
||||||
strlen (awc.payto_uri) + 1,
|
&aw.h_wire);
|
||||||
&aw.h_wire);
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_verify (
|
GNUNET_CRYPTO_eddsa_verify (
|
||||||
TALER_SIGNATURE_MASTER_DEL_WIRE,
|
TALER_SIGNATURE_MASTER_DEL_WIRE,
|
||||||
|
@ -199,7 +199,7 @@ TEH_handler_management_post_wire_fees (
|
|||||||
return MHD_YES; /* failure */
|
return MHD_YES; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 !=
|
if (GNUNET_OK !=
|
||||||
TALER_amount_cmp_currency (&afc.closing_fee,
|
TALER_amount_cmp_currency (&afc.closing_fee,
|
||||||
&afc.wire_fee))
|
&afc.wire_fee))
|
||||||
{
|
{
|
||||||
|
@ -7664,8 +7664,8 @@ postgres_insert_wire (void *cls,
|
|||||||
{
|
{
|
||||||
struct GNUNET_PQ_QueryParam params[] = {
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
GNUNET_PQ_query_param_string (payto_uri),
|
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_auto_from_type (master_sig),
|
||||||
|
GNUNET_PQ_query_param_absolute_time (&start_date),
|
||||||
GNUNET_PQ_query_param_end
|
GNUNET_PQ_query_param_end
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ TALER_EXCHANGE_management_set_wire_fees (
|
|||||||
GNUNET_free (swfh);
|
GNUNET_free (swfh);
|
||||||
return NULL;
|
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",
|
||||||
wire_method,
|
wire_method,
|
||||||
"master_sig",
|
"master_sig",
|
||||||
|
@ -137,7 +137,7 @@ TALER_EXCHANGE_management_enable_wire (
|
|||||||
wh->cb_cls = cb_cls;
|
wh->cb_cls = cb_cls;
|
||||||
wh->ctx = ctx;
|
wh->ctx = ctx;
|
||||||
wh->url = TALER_url_join (url,
|
wh->url = TALER_url_join (url,
|
||||||
"management/wire/enable",
|
"management/wire",
|
||||||
NULL);
|
NULL);
|
||||||
if (NULL == wh->url)
|
if (NULL == wh->url)
|
||||||
{
|
{
|
||||||
@ -146,7 +146,7 @@ TALER_EXCHANGE_management_enable_wire (
|
|||||||
GNUNET_free (wh);
|
GNUNET_free (wh);
|
||||||
return NULL;
|
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",
|
||||||
payto_uri,
|
payto_uri,
|
||||||
"master_sig_add",
|
"master_sig_add",
|
||||||
|
@ -82,6 +82,64 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_auditor_del ("del-auditor-IDEMPOTENT",
|
TALER_TESTING_cmd_auditor_del ("del-auditor-IDEMPOTENT",
|
||||||
MHD_HTTP_NO_CONTENT,
|
MHD_HTTP_NO_CONTENT,
|
||||||
false),
|
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 ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -131,20 +131,15 @@ wire_add_run (void *cls,
|
|||||||
.purpose.size = htonl (sizeof (kv)),
|
.purpose.size = htonl (sizeof (kv)),
|
||||||
.start_date = GNUNET_TIME_absolute_hton (now),
|
.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,
|
TALER_exchange_wire_signature_hash (ds->payto_uri,
|
||||||
&kv.h_wire);
|
&kv.h_wire);
|
||||||
wd.h_wire_details = kv.h_wire;
|
|
||||||
GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
|
GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
|
||||||
&kv,
|
&kv,
|
||||||
&master_sig1.eddsa_signature);
|
&master_sig1.eddsa_signature);
|
||||||
GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
|
TALER_exchange_wire_signature_make (ds->payto_uri,
|
||||||
&wd,
|
&is->master_priv,
|
||||||
&master_sig2.eddsa_signature);
|
&master_sig2);
|
||||||
}
|
}
|
||||||
ds->dh = TALER_EXCHANGE_management_enable_wire (
|
ds->dh = TALER_EXCHANGE_management_enable_wire (
|
||||||
is->ctx,
|
is->ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user