From 5ac448738dfe213bf27d89abe253455ce0a38acf Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 May 2020 19:22:32 +0200 Subject: fix status code --- src/testing/test_exchange_api_twisted.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/testing/test_exchange_api_twisted.c') diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 9aac3d1e..05337219 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -173,12 +173,6 @@ run (void *cls, TALER_TESTING_cmd_refund ("refund-currency-mismatch", MHD_HTTP_BAD_REQUEST, "USD:5", - "USD:0.01", - "deposit-refund-1"), - TALER_TESTING_cmd_refund ("refund-fee-above-amount", - MHD_HTTP_BAD_REQUEST, - "EUR:5", - "EUR:10", "deposit-refund-1"), TALER_TESTING_cmd_flip_upload ("flip-upload", CONFIG_FILE, @@ -186,7 +180,6 @@ run (void *cls, TALER_TESTING_cmd_refund ("refund-bad-sig", MHD_HTTP_FORBIDDEN, "EUR:5", - "EUR:0.01", "deposit-refund-1"), /* This next deposit CMD is only used to provide a @@ -207,17 +200,14 @@ run (void *cls, TALER_TESTING_cmd_refund ("refund-deposit-not-found", MHD_HTTP_NOT_FOUND, "EUR:5", - "EUR:0.01", "deposit-refund-to-fail"), TALER_TESTING_cmd_refund ("refund-insufficient-funds", MHD_HTTP_PRECONDITION_FAILED, "EUR:50", - "EUR:0.01", "deposit-refund-1"), TALER_TESTING_cmd_refund ("refund-fee-too-low", MHD_HTTP_BAD_REQUEST, "EUR:5", - "EUR:0.000001", "deposit-refund-1"), TALER_TESTING_cmd_end () }; -- cgit v1.2.3 From c31048b05020420d1bb3a5cdf1c054648f11c214 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 May 2020 19:41:14 +0200 Subject: implement #6181 --- src/exchange/taler-exchange-httpd.c | 51 +++++++++++++++++++++++++++++++-- src/testing/test_exchange_api_twisted.c | 4 --- 2 files changed, 48 insertions(+), 7 deletions(-) (limited to 'src/testing/test_exchange_api_twisted.c') diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index a8e29d30..00932c0f 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -420,6 +420,45 @@ proceed_with_handler (const struct TEH_RequestHandler *rh, } +/** + * Handle a "/seed" request. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param args array of additional options (must be empty for this function) + * @return MHD result code + */ +static MHD_RESULT +handler_seed (const struct TEH_RequestHandler *rh, + struct MHD_Connection *connection, + const char *const args[]) +{ +#define SEED_SIZE 32 + char *body; + MHD_RESULT ret; + struct MHD_Response *resp; + + (void) rh; + body = malloc (SEED_SIZE); /* must use malloc(), because MHD will use free() */ + if (NULL == body) + return MHD_NO; + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, + body, + SEED_SIZE); + resp = MHD_create_response_from_buffer (SEED_SIZE, + body, + MHD_RESPMEM_MUST_FREE); + TALER_MHD_add_global_headers (resp); + ret = MHD_queue_response (connection, + MHD_HTTP_OK, + resp); + GNUNET_break (MHD_YES == ret); + MHD_destroy_response (resp); + return ret; +#undef SEED_SIZE +} + + /** * Handle incoming HTTP request. * @@ -472,6 +511,11 @@ handle_mhd_request (void *cls, .method = MHD_HTTP_METHOD_GET, .handler.get = &TEH_handler_agpl_redirect }, + { + .url = "seed", + .method = MHD_HTTP_METHOD_GET, + .handler.get = &handler_seed + }, /* Terms of service */ { .url = "terms", @@ -654,9 +698,10 @@ handle_mhd_request (void *cls, { struct TEH_RequestHandler *rh = &handlers[i]; - if (0 != strncmp (tok, - rh->url, - tok_size)) + if ( (0 != strncmp (tok, + rh->url, + tok_size)) || + (tok_size != strlen (rh->url) ) ) continue; found = GNUNET_YES; /* The URL is a match! What we now do depends on the method. */ diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 05337219..c99c7410 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -205,10 +205,6 @@ run (void *cls, MHD_HTTP_PRECONDITION_FAILED, "EUR:50", "deposit-refund-1"), - TALER_TESTING_cmd_refund ("refund-fee-too-low", - MHD_HTTP_BAD_REQUEST, - "EUR:5", - "deposit-refund-1"), TALER_TESTING_cmd_end () }; -- cgit v1.2.3 From 0985dfd18f4f99b87098b1d739068d111a4a67d2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 May 2020 19:22:32 +0200 Subject: fix status code --- src/testing/test_exchange_api_twisted.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/testing/test_exchange_api_twisted.c') diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index c99c7410..05337219 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -205,6 +205,10 @@ run (void *cls, MHD_HTTP_PRECONDITION_FAILED, "EUR:50", "deposit-refund-1"), + TALER_TESTING_cmd_refund ("refund-fee-too-low", + MHD_HTTP_BAD_REQUEST, + "EUR:5", + "deposit-refund-1"), TALER_TESTING_cmd_end () }; -- cgit v1.2.3 From 70a8aca668da17843a71b01806d07ece72a0ed0b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 May 2020 19:41:14 +0200 Subject: implement #6181 --- src/testing/test_exchange_api_twisted.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/testing/test_exchange_api_twisted.c') diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 05337219..c99c7410 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -205,10 +205,6 @@ run (void *cls, MHD_HTTP_PRECONDITION_FAILED, "EUR:50", "deposit-refund-1"), - TALER_TESTING_cmd_refund ("refund-fee-too-low", - MHD_HTTP_BAD_REQUEST, - "EUR:5", - "deposit-refund-1"), TALER_TESTING_cmd_end () }; -- cgit v1.2.3 From 78b13737bb83190be485f5bc5f3a4756100e60f3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 May 2020 19:22:32 +0200 Subject: fix status code --- src/testing/test_exchange_api_twisted.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/testing/test_exchange_api_twisted.c') diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index c99c7410..05337219 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -205,6 +205,10 @@ run (void *cls, MHD_HTTP_PRECONDITION_FAILED, "EUR:50", "deposit-refund-1"), + TALER_TESTING_cmd_refund ("refund-fee-too-low", + MHD_HTTP_BAD_REQUEST, + "EUR:5", + "deposit-refund-1"), TALER_TESTING_cmd_end () }; -- cgit v1.2.3 From 91e0debfbea8801b1f896bd6a08b27e19dc3bdf2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 May 2020 19:41:14 +0200 Subject: implement #6181 --- src/testing/test_exchange_api_twisted.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/testing/test_exchange_api_twisted.c') diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 05337219..c99c7410 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -205,10 +205,6 @@ run (void *cls, MHD_HTTP_PRECONDITION_FAILED, "EUR:50", "deposit-refund-1"), - TALER_TESTING_cmd_refund ("refund-fee-too-low", - MHD_HTTP_BAD_REQUEST, - "EUR:5", - "deposit-refund-1"), TALER_TESTING_cmd_end () }; -- cgit v1.2.3