summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-29 23:57:51 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-29 23:57:51 +0100
commit03d8657d530be561b321fd93d586f188cb61384b (patch)
tree19a46a637e47ececa62c7d87de5d4b9e8e046f50 /src/lib
parent778c2228f8662d748b65e48104be357c162d51ca (diff)
downloadsync-03d8657d530be561b321fd93d586f188cb61384b.tar.gz
sync-03d8657d530be561b321fd93d586f188cb61384b.tar.bz2
sync-03d8657d530be561b321fd93d586f188cb61384b.zip
propper handling of URIs
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/sync_api_upload.c10
-rw-r--r--src/lib/test_sync_api.c13
-rw-r--r--src/lib/test_sync_api.conf6
-rw-r--r--src/lib/testing_api_cmd_backup_upload.c37
4 files changed, 65 insertions, 1 deletions
diff --git a/src/lib/sync_api_upload.c b/src/lib/sync_api_upload.c
index 33ff381..31a7d08 100644
--- a/src/lib/sync_api_upload.c
+++ b/src/lib/sync_api_upload.c
@@ -219,8 +219,18 @@ handle_header (char *buffer,
if (0 == strcasecmp (hdr_type,
"Taler"))
{
+ size_t len;
+
/* found payment URI we care about! */
uo->pay_uri = GNUNET_strdup (hdr_val);
+ len = strlen (uo->pay_uri);
+ while ( (len > 0) &&
+ ( ('\n' == uo->pay_uri[len - 1]) ||
+ ('\r' == uo->pay_uri[len - 1]) ) )
+ {
+ len--;
+ uo->pay_uri[len] = '\0';
+ }
}
GNUNET_free (ndup);
return total;
diff --git a/src/lib/test_sync_api.c b/src/lib/test_sync_api.c
index 6f6ac77..fbbe0b1 100644
--- a/src/lib/test_sync_api.c
+++ b/src/lib/test_sync_api.c
@@ -249,6 +249,19 @@ run (void *cls,
MHD_HTTP_PAYMENT_REQUIRED,
"Test-1",
strlen ("Test-1")),
+ TALER_TESTING_cmd_proposal_lookup ("fetch-proposal",
+ merchant_url,
+ MHD_HTTP_OK,
+ "backup-upload-1",
+ NULL),
+ TALER_TESTING_cmd_pay ("pay-account",
+ merchant_url,
+ MHD_HTTP_OK,
+ "fetch-proposal",
+ "withdraw-coin-1",
+ "EUR:5",
+ "EUR:4.99", /* must match ANNUAL_FEE in config! */
+ "EUR:0.01"),
TALER_TESTING_cmd_end ()
};
diff --git a/src/lib/test_sync_api.conf b/src/lib/test_sync_api.conf
index c767b72..eb9d7ca 100644
--- a/src/lib/test_sync_api.conf
+++ b/src/lib/test_sync_api.conf
@@ -18,6 +18,12 @@ PORT = 8084
# Where does our payment backend run? Must match PORT under [merchant]
PAYMENT_BACKEND_URL = http://localhost:8080/
+# Annual fee we charge.
+ANNUAL_FEE = EUR:4.99
+
+# Upload limit
+UPLOAD_LIMIT_MB = 1
+
[syncdb-postgres]
CONFIG = postgres:///synccheck
diff --git a/src/lib/testing_api_cmd_backup_upload.c b/src/lib/testing_api_cmd_backup_upload.c
index 02d66fb..6ed228a 100644
--- a/src/lib/testing_api_cmd_backup_upload.c
+++ b/src/lib/testing_api_cmd_backup_upload.c
@@ -151,7 +151,42 @@ backup_upload_cb (void *cls,
}
break;
case SYNC_US_PAYMENT_REQUIRED:
- bus->payment_order_id = GNUNET_strdup (ud->details.payment_request);
+ {
+ const char *m;
+
+ if (0 != strncmp (ud->details.payment_request,
+ "taler://pay/http",
+ strlen ("taler://pay/http")))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Did not find `%s' in `%s'\n",
+ "/-/-/",
+ ud->details.payment_request);
+ TALER_TESTING_interpreter_fail (bus->is);
+ return;
+ }
+ m = strstr (ud->details.payment_request, "/-/-/");
+ if (NULL == m)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Did not find `%s' in `%s'\n",
+ "/-/-/",
+ ud->details.payment_request);
+ TALER_TESTING_interpreter_fail (bus->is);
+ /* NOTE: The above is a simplifying assumption for the
+ test-logic, hitting this code merely means that
+ the assumptions for the test (i.e. no instance) are
+ not satisfied, it is not inherently the case that
+ the above token must appear in the payment request!
+
+ So if you hit this, you might just want to modify
+ the code here to handle this better! */return;
+ }
+ bus->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Order ID from Sync service is `%s'\n",
+ bus->payment_order_id);
+ }
break;
case SYNC_US_CONFLICTING_BACKUP:
{