diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2018-12-12 13:42:00 +0100 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2018-12-12 13:42:00 +0100 |
commit | 220e00696b268458ff2e011c172cff434a9553a3 (patch) | |
tree | ec1ee586527d7623503d23a0d6546da435c4e48c /src | |
parent | 81d1b39343d98f7f5e8bdc501d79a31d418a365c (diff) |
Traits.
Do not expose reserve priv trait if the user
created a reserve specifying the wire transfer
subject explicitly.
Diffstat (limited to 'src')
-rw-r--r-- | src/exchange-lib/test_exchange_api_new.c | 54 | ||||
-rw-r--r-- | src/exchange-lib/testing_api_cmd_fakebank_transfer.c | 22 |
2 files changed, 63 insertions, 13 deletions
diff --git a/src/exchange-lib/test_exchange_api_new.c b/src/exchange-lib/test_exchange_api_new.c index d2b4f91c1..b69258995 100644 --- a/src/exchange-lib/test_exchange_api_new.c +++ b/src/exchange-lib/test_exchange_api_new.c @@ -135,7 +135,6 @@ static char *auditor_url; EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ subject, exchange_url) - /** * Main function that will tell the interpreter what commands to * run. @@ -690,13 +689,17 @@ run (void *cls, "payback-create-reserve-1", "EUR:5", MHD_HTTP_OK), - - TALER_TESTING_cmd_revoke ("revoke-1", MHD_HTTP_OK, + /* Make coin invalid */ + TALER_TESTING_cmd_revoke ("revoke-1", + MHD_HTTP_OK, "payback-withdraw-coin-1", CONFIG_FILE), - TALER_TESTING_cmd_payback ("payback-1", MHD_HTTP_OK, - "payback-withdraw-coin-1", "EUR:5"), + /* Refund coin to bank account */ + TALER_TESTING_cmd_payback ("payback-1", + MHD_HTTP_OK, + "payback-withdraw-coin-1", + "EUR:5"), /* Check the money is back with the reserve */ TALER_TESTING_cmd_status ("payback-reserve-status-1", @@ -712,8 +715,9 @@ run (void *cls, "EUR:1", MHD_HTTP_OK), - /* This withdrawal will test the logic to create - * a "payback" element to insert into the reserve's history. + /** + * This withdrawal will test the logic to create a "payback" + * element to insert into the reserve's history. */ TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2-over", @@ -888,6 +892,37 @@ run (void *cls, TALER_TESTING_cmd_end () }; + struct TALER_TESTING_Command reserve_open_close[] = { + + #define CONSTANT_KEY \ + "09QGYPEKNHBACK135BNXZFHA0YTQXT1KJDRVXF4J822G99AYNQ8G" + + TALER_TESTING_cmd_check_bank_empty + ("reserve-open-close-empty"), + + CMD_TRANSFER_TO_EXCHANGE_SUBJECT + ("reserve-open-close-key", + "EUR:20", + CONSTANT_KEY), + + TALER_TESTING_cmd_exec_wirewatch + ("reserve-open-close-wirewatch", + CONFIG_FILE_EXPIRE_RESERVE_NOW), + + TALER_TESTING_cmd_status ("reserve-open-close-status", + is->exchange, + "reserve-open-close-key", + "EUR:0", + MHD_HTTP_OK), + + /* Wire back to the bank */ + TALER_TESTING_cmd_exec_aggregator + ("reserve-open-close-aggregation", + CONFIG_FILE_EXPIRE_RESERVE_NOW), + + TALER_TESTING_cmd_end () + }; + struct TALER_TESTING_Command commands[] = { TALER_TESTING_cmd_batch ("wire", @@ -914,6 +949,11 @@ run (void *cls, TALER_TESTING_cmd_batch ("payback", payback), + #if 0 + TALER_TESTING_cmd_batch ("reserve-open-close", + reserve_open_close), + #endif + /** * End the suite. Fixme: better to have a label for this * too, as it shows a "(null)" token on logs. diff --git a/src/exchange-lib/testing_api_cmd_fakebank_transfer.c b/src/exchange-lib/testing_api_cmd_fakebank_transfer.c index 6d826def1..3cf9aaeec 100644 --- a/src/exchange-lib/testing_api_cmd_fakebank_transfer.c +++ b/src/exchange-lib/testing_api_cmd_fakebank_transfer.c @@ -405,7 +405,6 @@ fakebank_transfer_cleanup (void *cls, GNUNET_free (fts); } - /** * Offer internal data from a "fakebank transfer" CMD to other * commands. @@ -423,20 +422,31 @@ fakebank_transfer_traits (void *cls, unsigned int index) { struct FakebankTransferState *fts = cls; - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_reserve_priv - (0, &fts->reserve_priv), + #define MANDATORY 6 + struct TALER_TESTING_Trait traits[MANDATORY + 1] = { TALER_TESTING_MAKE_TRAIT_DEBIT_ACCOUNT (&fts->debit_account_no), TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT (&fts->credit_account_no), TALER_TESTING_make_trait_url (0, fts->exchange_url), - TALER_TESTING_make_trait_transfer_subject (0, fts->subject), TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id), TALER_TESTING_make_trait_amount_obj (0, &fts->amount), - TALER_TESTING_trait_end () }; + /** + * The user gave explicit subject, + * there must be NO reserve priv. */ + if (NULL != fts->subject) + traits[MANDATORY - 1] = + TALER_TESTING_make_trait_transfer_subject (0, + fts->subject); + /* A reserve priv must exist if no subject was given. */ + else + traits[MANDATORY - 1] = TALER_TESTING_make_trait_reserve_priv + (0, &fts->reserve_priv), + + traits[MANDATORY] = TALER_TESTING_trait_end (); + return TALER_TESTING_get_trait (traits, ret, trait, |