aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/taleruri.test.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-04-04 15:11:08 -0300
committerSebastian <sebasjm@gmail.com>2023-04-04 15:11:27 -0300
commit7090807fcbb2e7345ad0566c0057540e34bfb9f5 (patch)
tree90dfcee47491c4514134755f52298d2c962ab536 /packages/taler-util/src/taleruri.test.ts
parent68d711b2e7f096369c922a2fa340dd39bf2cb711 (diff)
downloadwallet-core-7090807fcbb2e7345ad0566c0057540e34bfb9f5.tar.xz
fix broken tests
Diffstat (limited to 'packages/taler-util/src/taleruri.test.ts')
-rw-r--r--packages/taler-util/src/taleruri.test.ts90
1 files changed, 79 insertions, 11 deletions
diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts
index a6c4d89fc..ffc56a723 100644
--- a/packages/taler-util/src/taleruri.test.ts
+++ b/packages/taler-util/src/taleruri.test.ts
@@ -16,14 +16,16 @@
import test from "ava";
import {
+ parsePayPushUri,
+ parsePayTemplateUri,
parsePayUri,
- parseWithdrawUri,
parseRefundUri,
+ parseRestoreUri,
parseTipUri,
- parsePayPushUri,
- constructPayPushUri,
- parsePayTemplateUri,
- constructPayUri,
+ parseWithdrawUri,
+ stringifyPayPushUri,
+ stringifyPayUri,
+ stringifyRestoreUri,
} from "./taleruri.js";
test("taler pay url parsing: wrong scheme", (t) => {
@@ -220,22 +222,46 @@ test("taler peer to peer push URI (http)", (t) => {
t.is(r1.contractPriv, "foo");
});
-test("taler peer to peer push URI (construction)", (t) => {
- const url = constructPayPushUri({
+test("taler peer to peer push URI (stringify)", (t) => {
+ const url = stringifyPayPushUri({
exchangeBaseUrl: "https://foo.example.com/bla/",
contractPriv: "123",
});
t.deepEqual(url, "taler://pay-push/foo.example.com/bla/123");
});
-
-test("taler pay URI (construction)", (t) => {
- const url1 = constructPayUri("http://localhost:123/", "foo", "");
+test("taler pay URI (stringify)", (t) => {
+ const url1 = stringifyPayUri({
+ merchantBaseUrl: "http://localhost:123/",
+ orderId: "foo",
+ sessionId: "",
+ });
t.deepEqual(url1, "taler+http://pay/localhost:123/foo/");
- const url2 = constructPayUri("http://localhost:123/", "foo", "bla");
+ const url2 = stringifyPayUri({
+ merchantBaseUrl: "http://localhost:123/",
+ orderId: "foo",
+ sessionId: "bla",
+ });
t.deepEqual(url2, "taler+http://pay/localhost:123/foo/bla");
});
+test("taler pay URI (stringify with https)", (t) => {
+ const url1 = stringifyPayUri({
+ merchantBaseUrl: "https://localhost:123/",
+ orderId: "foo",
+ sessionId: "",
+ });
+ t.deepEqual(url1, "taler://pay/localhost:123/foo/");
+
+ const url2 = stringifyPayUri({
+ merchantBaseUrl: "https://localhost/",
+ orderId: "foo",
+ sessionId: "bla",
+ noncePriv: "123",
+ });
+ t.deepEqual(url2, "taler://pay/localhost/foo/bla?n=123");
+});
+
test("taler pay template URI (parsing)", (t) => {
const url1 =
"taler://pay-template/merchant.example.com/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY?amount=KUDOS:5";
@@ -261,3 +287,45 @@ test("taler pay template URI (parsing, http with port)", (t) => {
t.deepEqual(r1.templateId, "FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY");
t.deepEqual(r1.templateParams.amount, "KUDOS:5");
});
+
+test("taler restore URI (parsing, http with port)", (t) => {
+ const r1 = parseRestoreUri(
+ "taler+http://restore/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0/prov1.example.com,prov2.example.com:123",
+ );
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.deepEqual(
+ r1.walletRootPriv,
+ "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0",
+ );
+ t.deepEqual(r1.providers[0], "http://prov1.example.com/");
+ t.deepEqual(r1.providers[1], "http://prov2.example.com:123/");
+});
+test("taler restore URI (parsing, https with port)", (t) => {
+ const r1 = parseRestoreUri(
+ "taler://restore/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0/prov1.example.com,prov2.example.com:234,https%3A%2F%2Fprov1.example.com%2F",
+ );
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.deepEqual(
+ r1.walletRootPriv,
+ "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0",
+ );
+ t.deepEqual(r1.providers[0], "https://prov1.example.com/");
+ t.deepEqual(r1.providers[1], "https://prov2.example.com:234/");
+});
+
+test("taler restore URI (stringify)", (t) => {
+ const url = stringifyRestoreUri({
+ walletRootPriv: "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0",
+ providers: ["http://prov1.example.com", "https://prov2.example.com:234/"],
+ });
+ t.deepEqual(
+ url,
+ "taler://restore/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0/http%3A%2F%2Fprov1.example.com%2F,https%3A%2F%2Fprov2.example.com%3A234%2F",
+ );
+});