diff options
author | priscilla <priscilla.huang@efrei.net> | 2023-03-03 05:26:52 -0500 |
---|---|---|
committer | priscilla <priscilla.huang@efrei.net> | 2023-03-22 10:23:06 -0400 |
commit | 702d2fc2346ea7d1829eac70928d6362235eea20 (patch) | |
tree | eccd774cba5c02252fdece680e5f953292c35d2d /src | |
parent | 3fa7d3bee0ba672ad3aac576e35bc037ebff5984 (diff) | |
download | merchant-702d2fc2346ea7d1829eac70928d6362235eea20.tar.gz merchant-702d2fc2346ea7d1829eac70928d6362235eea20.tar.bz2 merchant-702d2fc2346ea7d1829eac70928d6362235eea20.zip |
daily pull
Diffstat (limited to 'src')
-rw-r--r-- | src/testing/test_merchant_api.c | 33 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_get_template.c | 21 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_patch_template.c | 10 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_pay_order.c | 2 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_post_templates.c | 11 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_post_using_templates.c | 3 |
6 files changed, 75 insertions, 5 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 8509f6aa..c4853fd4 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -111,6 +111,13 @@ static char *merchant_url_i1a; static struct GNUNET_OS_Process *merchantd; /** + * total for totp + */ +static struct TALER_Amount *total; +enum GNUNET_Generic_ReturnValue TALER_string_to_amount ("EUR:10.0", + total); + +/** * Account number of the exchange at the bank. */ #define EXCHANGE_ACCOUNT_NAME "2" @@ -1327,6 +1334,13 @@ run (void *cls, merchant_url, MHD_HTTP_OK, NULL), + TALER_TESTING_cmd_merchant_post_orders ("create-proposal-10", + merchant_url, + MHD_HTTP_OK, + "100", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + "EUR:10.0"), TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1", merchant_url, "template-1", @@ -1362,7 +1376,8 @@ run (void *cls, merchant_url, "template-2", "another template", - "data:image/jpeg;base64,RAWDATA", + NULL, + TALER_MCA_WITH_PRICE, GNUNET_JSON_PACK ( GNUNET_JSON_pack_uint64 ("minimum_age", 0), GNUNET_JSON_pack_time_rel ("pay_duration", @@ -1383,7 +1398,8 @@ run (void *cls, merchant_url, "template-3", "updated template", - "data:image/jpeg;base64,RAWDATA", + NULL, + TALER_MCA_WITH_PRICE, GNUNET_JSON_PACK ( GNUNET_JSON_pack_uint64 ("minimum_age", 0), GNUNET_JSON_pack_time_rel ("pay_duration", @@ -1395,6 +1411,7 @@ run (void *cls, "template-amount", "a different template with an amount", NULL, + TALER_MCA_WITHOUT_PRICE, GNUNET_JSON_PACK ( GNUNET_JSON_pack_uint64 ("minimum_age", 0), GNUNET_JSON_pack_time_rel ("pay_duration", @@ -1437,6 +1454,18 @@ run (void *cls, "summary-1", "EUR:4", MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_merchant_pay_order ("pay-100", + merchant_url, + MHD_HTTP_OK, + "create-proposal-100", + "withdraw-coin-10a;withdraw-coin-10b", + "EUR:5", + "EUR:4.99", + NULL), + TALER_build_pos_confirmation ("pos1test", + TALER_MCA_WITH_PRICE, + total, + GNUNET_TIME_timestamp_get()), TALER_TESTING_cmd_merchant_delete_template ("get-templates-empty", merchant_url, "t1", diff --git a/src/testing/testing_api_cmd_get_template.c b/src/testing/testing_api_cmd_get_template.c index 8b32156d..412c52c0 100644 --- a/src/testing/testing_api_cmd_get_template.c +++ b/src/testing/testing_api_cmd_get_template.c @@ -136,6 +136,27 @@ get_template_cb (void *cls, } } { + const enum TALER_MerchantConfirmationAlgorithm *expected_pos_alg; + const enum TALER_MerchantConfirmationAlgorithm pos_alg = tgr->details.success.pos_alg; + + if (GNUNET_OK != + TALER_TESTING_get_trait_template_pos_alg (template_cmd, + &expected_pos_alg)) + TALER_TESTING_interpreter_fail (gis->is); + if ( ( (0 == pos_alg) && (0 != *expected_pos_alg)) || + ( (0 != pos_alg) && (0 == *expected_pos_alg)) || + ( (0 != pos_alg) && + (pos_alg != *expected_pos_alg)) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Template pos_alg `%d' does not match `%d'\n", + pos_alg, + *expected_pos_alg); + TALER_TESTING_interpreter_fail (gis->is); + return; + } + } + { const json_t *expected_template_contract; if (GNUNET_OK != diff --git a/src/testing/testing_api_cmd_patch_template.c b/src/testing/testing_api_cmd_patch_template.c index 81560fa7..bc260c00 100644 --- a/src/testing/testing_api_cmd_patch_template.c +++ b/src/testing/testing_api_cmd_patch_template.c @@ -65,6 +65,11 @@ struct PatchTemplateState char *pos_key; /** + * Option that add amount of the order + */ + enum TALER_MerchantConfirmationAlgorithm pos_alg; + + /** * Contract of the company */ json_t *template_contract; @@ -142,7 +147,7 @@ patch_template_run (void *cls, pis->template_id, pis->template_description, pis->pos_key, - TALER_MCA_NONE, + pis->pos_alg, pis->template_contract, &patch_template_cb, pis); @@ -171,6 +176,7 @@ patch_template_traits (void *cls, TALER_TESTING_make_trait_template_description (&pts->template_description), TALER_TESTING_make_trait_template_pos_key ( (const char **) &pts->pos_key), + TALER_TESTING_make_trait_template_pos_alg (&pts->pos_alg), TALER_TESTING_make_trait_template_contract (pts->template_contract), TALER_TESTING_make_trait_template_id (&pts->template_id), TALER_TESTING_trait_end (), @@ -215,6 +221,7 @@ TALER_TESTING_cmd_merchant_patch_template ( const char *template_id, const char *template_description, const char *pos_key, + const enum TALER_MerchantConfirmationAlgorithm pos_alg, json_t *template_contract, unsigned int http_status) { @@ -226,6 +233,7 @@ TALER_TESTING_cmd_merchant_patch_template ( pis->http_status = http_status; pis->template_description = template_description; pis->pos_key = (NULL == pos_key) ? NULL : GNUNET_strdup (pos_key); + pis->pos_alg = pos_alg; pis->template_contract = template_contract; /* ownership taken */ { struct TALER_TESTING_Command cmd = { diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c index cd589965..5ec9e46b 100644 --- a/src/testing/testing_api_cmd_pay_order.c +++ b/src/testing/testing_api_cmd_pay_order.c @@ -239,6 +239,8 @@ pay_cb (void *cls, if (MHD_HTTP_OK == pr->hr.http_status) { ps->merchant_sig = pr->details.success.merchant_sig; + // FIXME: check if pr->details.success.pos_confirmation; + // for that, get pos_secret from ps->proposal_reference CMD and amount from pay/order creation cmd using traits } TALER_TESTING_interpreter_next (ps->is); } diff --git a/src/testing/testing_api_cmd_post_templates.c b/src/testing/testing_api_cmd_post_templates.c index 39728792..2def21ea 100644 --- a/src/testing/testing_api_cmd_post_templates.c +++ b/src/testing/testing_api_cmd_post_templates.c @@ -65,6 +65,11 @@ struct PostTemplatesState char *pos_key; /** + * Option that add amount of the order + */ + enum TALER_MerchantConfirmationAlgorithm pos_alg; + + /** * Contract of the company */ json_t *template_contract; @@ -141,7 +146,7 @@ post_templates_run (void *cls, tis->template_id, tis->template_description, tis->pos_key, - TALER_MCA_NONE, + tis->pos_alg, tis->template_contract, &post_templates_cb, tis); @@ -175,6 +180,7 @@ post_templates_traits (void *cls, TALER_TESTING_make_trait_template_description (&pts->template_description), TALER_TESTING_make_trait_template_pos_key ( (const char **) &pts->pos_key), + TALER_TESTING_make_trait_template_pos_alg (&pts->pos_alg), TALER_TESTING_make_trait_template_contract (pts->template_contract), TALER_TESTING_make_trait_template_id (&pts->template_id), TALER_TESTING_trait_end (), @@ -219,6 +225,7 @@ TALER_TESTING_cmd_merchant_post_templates2 ( const char *template_id, const char *template_description, const char *pos_key, + const enum TALER_MerchantConfirmationAlgorithm pos_alg, json_t *template_contract, unsigned int http_status) { @@ -233,6 +240,7 @@ TALER_TESTING_cmd_merchant_post_templates2 ( tis->http_status = http_status; tis->template_description = template_description; tis->pos_key = (NULL == pos_key) ? NULL : GNUNET_strdup (pos_key); + tis->pos_alg = pos_alg; tis->template_contract = template_contract; { struct TALER_TESTING_Command cmd = { @@ -261,6 +269,7 @@ TALER_TESTING_cmd_merchant_post_templates (const char *label, template_id, template_description, NULL, + TALER_MCA_WITHOUT_PRICE, GNUNET_JSON_PACK ( GNUNET_JSON_pack_uint64 ("minimum_age", 0), GNUNET_JSON_pack_time_rel ("pay_duration", diff --git a/src/testing/testing_api_cmd_post_using_templates.c b/src/testing/testing_api_cmd_post_using_templates.c index 956a421a..137c7df1 100644 --- a/src/testing/testing_api_cmd_post_using_templates.c +++ b/src/testing/testing_api_cmd_post_using_templates.c @@ -209,7 +209,8 @@ TALER_TESTING_cmd_merchant_post_using_templates ( const char *template_ref, const char *merchant_url, const char *summary, - const char *amount, unsigned int http_status) + const char *amount, + unsigned int http_status) { struct PostUsingTemplatesState *tis; |