summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-11-01 12:44:12 +0100
committerChristian Grothoff <christian@grothoff.org>2017-11-01 12:44:12 +0100
commit3f1cb92782e404d907e4337393d92d8157acd4e7 (patch)
treea9c7799e3d863587fd95c1d157585bb292efeff9 /src/lib
parent26f8dda0fe79159fcb47acb9706d8dad8a2426dc (diff)
downloadmerchant-3f1cb92782e404d907e4337393d92d8157acd4e7.tar.gz
merchant-3f1cb92782e404d907e4337393d92d8157acd4e7.tar.bz2
merchant-3f1cb92782e404d907e4337393d92d8157acd4e7.zip
tests and bugfixes for /tip-authorize
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/merchant_api_tip_authorize.c6
-rw-r--r--src/lib/reserve_dtip.priv1
-rw-r--r--src/lib/test_merchant_api.c47
-rw-r--r--src/lib/test_merchant_api.conf12
4 files changed, 62 insertions, 4 deletions
diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c
index e422197d..c2590b2b 100644
--- a/src/lib/merchant_api_tip_authorize.c
+++ b/src/lib/merchant_api_tip_authorize.c
@@ -139,6 +139,12 @@ handle_tip_authorize_finished (void *cls,
response_code = 0;
}
break;
+ case MHD_HTTP_NOT_FOUND:
+ /* Well-defined status code, pass on to application! */
+ break;
+ case MHD_HTTP_PRECONDITION_FAILED:
+ /* Well-defined status code, pass on to application! */
+ break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
diff --git a/src/lib/reserve_dtip.priv b/src/lib/reserve_dtip.priv
new file mode 100644
index 00000000..d7fae398
--- /dev/null
+++ b/src/lib/reserve_dtip.priv
@@ -0,0 +1 @@
+A?*K4K31b'uyD;ȃC \ No newline at end of file
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index b0b546e7..5ccc5658 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -2860,8 +2860,10 @@ interpreter_run (void *cls)
&reserve_priv,
sizeof (reserve_priv));
/* Simply picked long enough for the test (we do not test expiration
- behavior for now) */
- expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS);
+ behavior for now), should be short enough so that the reserve
+ expires before the test is run again, so that we avoid old
+ state messing up fresh runs. */
+ expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
if (NULL == (cmd->details.tip_enable.teo
= TALER_MERCHANT_tip_enable
@@ -3118,6 +3120,47 @@ run (void *cls)
.expected_response_code = MHD_HTTP_OK,
.details.tip_enable.admin_add_incoming_ref = "create-reserve-tip-1",
.details.tip_enable.amount = "EUR:5.01" },
+ { .oc = OC_TIP_AUTHORIZE,
+ .label = "authorize-tip-1",
+ .expected_response_code = MHD_HTTP_OK,
+ .details.tip_authorize.instance = "tip",
+ .details.tip_authorize.justification = "tip 1",
+ .details.tip_authorize.amount = "EUR:5.01" },
+ { .oc = OC_TIP_AUTHORIZE,
+ .label = "authorize-tip-2",
+ .expected_response_code = MHD_HTTP_OK,
+ .details.tip_authorize.instance = "tip",
+ .details.tip_authorize.justification = "tip 2",
+ .details.tip_authorize.amount = "EUR:5.01" },
+ { .oc = OC_TIP_AUTHORIZE,
+ .label = "authorize-tip-3-insufficient-funds",
+ .expected_response_code = MHD_HTTP_PRECONDITION_FAILED,
+ .details.tip_authorize.instance = "tip",
+ .details.tip_authorize.justification = "tip 3",
+ .details.tip_authorize.amount = "EUR:5.01",
+ .details.tip_authorize.expected_ec = TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS },
+ { .oc = OC_TIP_AUTHORIZE,
+ .label = "authorize-tip-4-unknown-instance",
+ .expected_response_code = MHD_HTTP_NOT_FOUND,
+ .details.tip_authorize.instance = "unknown",
+ .details.tip_authorize.justification = "tip 4",
+ .details.tip_authorize.amount = "EUR:5.01",
+ .details.tip_authorize.expected_ec = TALER_EC_TIP_AUTHORIZE_INSTANCE_UNKNOWN },
+ { .oc = OC_TIP_AUTHORIZE,
+ .label = "authorize-tip-5-notip-instance",
+ .expected_response_code = MHD_HTTP_NOT_FOUND,
+ .details.tip_authorize.instance = "default",
+ .details.tip_authorize.justification = "tip 5",
+ .details.tip_authorize.amount = "EUR:5.01",
+ .details.tip_authorize.expected_ec = TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP },
+ { .oc = OC_TIP_AUTHORIZE,
+ .label = "authorize-tip-6-not-enabled-instance",
+ .expected_response_code = MHD_HTTP_NOT_FOUND,
+ .details.tip_authorize.instance = "dtip",
+ .details.tip_authorize.justification = "tip 6",
+ .details.tip_authorize.amount = "EUR:5.01",
+ .details.tip_authorize.expected_ec = TALER_EC_TIP_AUTHORIZE_RESERVE_NOT_ENABLED },
+
/* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per
diff --git a/src/lib/test_merchant_api.conf b/src/lib/test_merchant_api.conf
index 9767a376..91325e9f 100644
--- a/src/lib/test_merchant_api.conf
+++ b/src/lib/test_merchant_api.conf
@@ -33,7 +33,7 @@ WIREFORMAT = test
# during the tests. 'default' instance should explicitly be given.
# The instance "token" X must match the corresponding substring in
# section like X-wireformat and merchant-instance-X
-INSTANCES = tor default tip
+INSTANCES = tor default tip dtip
# Default choice for maximum wire fee.
DEFAULT_MAX_WIRE_FEE = EUR:0.10
@@ -84,15 +84,23 @@ KEYFILE = tor_merchant.priv
[merchant-instance-tip]
KEYFILE = reserve_tip.priv
-TIP_EXCHANGE = http://127.0.0.1:8081/
+TIP_EXCHANGE = http://localhost:8081/
TIP_RESERVE_PRIV = RKEJM3J3K8D02V6WFHWY14WM2RKFVBW35ZJ0FHWTEJDPN0T7CPYG
+[merchant-instance-dtip]
+KEYFILE = reserve_dtip.priv
+TIP_EXCHANGE = http://localhost:8081/
+TIP_RESERVE_PRIV = ENK9E0GYJ5EJEEC0QN3GY7KJRMNXW3B2SSWQDNJ3F1CEMFGC0970
+
[merchant-instance-wireformat-tor]
TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/merchant/wire/test.json
[merchant-instance-wireformat-tip]
TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/merchant/wire/test.json
+[merchant-instance-wireformat-dtip]
+TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/merchant/wire/test.json
+
# Auditors must be in sections "auditor-", the rest of the section
# name could be anything.
[merchant-auditor-ezb]