commit 7ada0ceb3ad58915ea677c75ba835cbb31f66828
parent 16d26b2b4c34ff3a8227f37845b3433af9b78e33
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Tue, 22 May 2018 11:10:19 +0200
Tip pick up on a non existent tip id. (Closes #5307)
Diffstat:
3 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
@@ -527,6 +527,9 @@ TALER_TESTING_cmd_tip_authorize_with_ec
const char *amount,
enum TALER_ErrorCode ec);
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_authorize_fake
+ (const char *label);
/**
* FIXME
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
@@ -732,7 +732,6 @@ run (void *cls,
"EUR:5.01",
TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP),
-
TALER_TESTING_cmd_tip_pickup_with_ec
("pickup-tip-3-too-much",
merchant_url,
@@ -743,6 +742,19 @@ run (void *cls,
is->exchange,
TALER_EC_TIP_PICKUP_NO_FUNDS),
+ TALER_TESTING_cmd_tip_authorize_fake
+ ("fake-tip-authorization"),
+
+ TALER_TESTING_cmd_tip_pickup_with_ec
+ ("pickup-non-existent-id",
+ merchant_url,
+ is->ctx,
+ MHD_HTTP_NOT_FOUND,
+ "fake-tip-authorization",
+ pickup_amounts_1,
+ is->exchange,
+ TALER_EC_TIP_PICKUP_TIP_ID_UNKNOWN),
+
TALER_TESTING_cmd_proposal
("create-proposal-tip-1",
merchant_url,
diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c
@@ -278,6 +278,21 @@ tip_authorize_run (void *cls,
}
+static void
+tip_authorize_fake_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct TipAuthorizeState *tas = cls;
+
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+ &tas->tip_id,
+ sizeof (struct GNUNET_HashCode));
+
+ TALER_TESTING_interpreter_next (is);
+}
+
+
/**
* FIXME
*/
@@ -957,5 +972,27 @@ TALER_TESTING_cmd_tip_pickup
return cmd;
}
+/**
+ * This commands does not query the backend at all,
+ * but just makes up a fake authorization id that will
+ * be subsequently used by the "pick up" CMD in order
+ * to test against such a case.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_tip_authorize_fake (const char *label)
+{
+ struct TipAuthorizeState *tas;
+ struct TALER_TESTING_Command cmd;
+
+ tas = GNUNET_new (struct TipAuthorizeState);
+
+ cmd.label = label;
+ cmd.cls = tas;
+ cmd.run = &tip_authorize_fake_run;
+ cmd.cleanup = &tip_authorize_cleanup;
+ cmd.traits = &tip_authorize_traits;
+
+ return cmd;
+}
/* end of testing_api_cmd_tip.c */