summaryrefslogtreecommitdiff
path: root/packages/taler-util/src/taleruri.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src/taleruri.test.ts')
-rw-r--r--packages/taler-util/src/taleruri.test.ts63
1 files changed, 21 insertions, 42 deletions
diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts
index 7f10d21fd..b92366fb3 100644
--- a/packages/taler-util/src/taleruri.test.ts
+++ b/packages/taler-util/src/taleruri.test.ts
@@ -314,7 +314,7 @@ test("taler peer to peer pull URI (stringify)", (t) => {
test("taler pay template URI (parsing)", (t) => {
const url1 =
- "taler://pay-template/merchant.example.com/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY?amount=KUDOS:5";
+ "taler://pay-template/merchant.example.com/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY";
const r1 = parsePayTemplateUri(url1);
if (!r1) {
t.fail();
@@ -322,12 +322,11 @@ test("taler pay template URI (parsing)", (t) => {
}
t.deepEqual(r1.merchantBaseUrl, "https://merchant.example.com/");
t.deepEqual(r1.templateId, "FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY");
- t.deepEqual(r1.templateParams.amount, "KUDOS:5");
});
test("taler pay template URI (parsing, http with port)", (t) => {
const url1 =
- "taler+http://pay-template/merchant.example.com:1234/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY?amount=KUDOS:5";
+ "taler+http://pay-template/merchant.example.com:1234/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY";
const r1 = parsePayTemplateUri(url1);
if (!r1) {
t.fail();
@@ -335,20 +334,16 @@ test("taler pay template URI (parsing, http with port)", (t) => {
}
t.deepEqual(r1.merchantBaseUrl, "http://merchant.example.com:1234/");
t.deepEqual(r1.templateId, "FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY");
- t.deepEqual(r1.templateParams.amount, "KUDOS:5");
});
test("taler pay template URI (stringify)", (t) => {
const url1 = stringifyPayTemplateUri({
merchantBaseUrl: "http://merchant.example.com:1234/",
templateId: "FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY",
- templateParams: {
- amount: "KUDOS:5",
- },
});
t.deepEqual(
url1,
- "taler+http://pay-template/merchant.example.com:1234/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY?amount=KUDOS%3A5",
+ "taler+http://pay-template/merchant.example.com:1234/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY",
);
});
@@ -423,24 +418,27 @@ test("taler dev exp URI (stringify)", (t) => {
*/
test("taler withdraw exchange URI (parse)", (t) => {
+ // Pubkey has been phased out, may no longer be specified.
{
- const r1 = parseWithdrawExchangeUri(
+ const rx1 = parseWithdrawExchangeUri(
"taler://withdraw-exchange/exchange.demo.taler.net/someroot/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0?a=KUDOS%3A2",
);
- if (!r1) {
+ if (rx1) {
t.fail();
return;
}
- t.deepEqual(
- r1.exchangePub,
- "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0",
- );
- t.deepEqual(
- r1.exchangeBaseUrl,
- "https://exchange.demo.taler.net/someroot/",
+ }
+ {
+ const rx2 = parseWithdrawExchangeUri(
+ "taler://withdraw-exchange/exchange.demo.taler.net/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0",
);
- t.deepEqual(r1.amount, "KUDOS:2");
+ if (rx2) {
+ t.fail();
+ return;
+ }
}
+
+ // Now test well-formed URIs
{
const r2 = parseWithdrawExchangeUri(
"taler://withdraw-exchange/exchange.demo.taler.net/someroot/",
@@ -449,7 +447,6 @@ test("taler withdraw exchange URI (parse)", (t) => {
t.fail();
return;
}
- t.deepEqual(r2.exchangePub, undefined);
t.deepEqual(r2.amount, undefined);
t.deepEqual(
r2.exchangeBaseUrl,
@@ -465,7 +462,6 @@ test("taler withdraw exchange URI (parse)", (t) => {
t.fail();
return;
}
- t.deepEqual(r3.exchangePub, undefined);
t.deepEqual(r3.amount, undefined);
t.deepEqual(r3.exchangeBaseUrl, "https://exchange.demo.taler.net/");
}
@@ -479,7 +475,6 @@ test("taler withdraw exchange URI (parse)", (t) => {
t.fail();
return;
}
- t.deepEqual(r4.exchangePub, undefined);
t.deepEqual(r4.amount, undefined);
t.deepEqual(r4.exchangeBaseUrl, "https://exchange.demo.taler.net/");
}
@@ -488,27 +483,21 @@ test("taler withdraw exchange URI (parse)", (t) => {
test("taler withdraw exchange URI (stringify)", (t) => {
const url = stringifyWithdrawExchange({
exchangeBaseUrl: "https://exchange.demo.taler.net",
- exchangePub: "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0",
});
- t.deepEqual(
- url,
- "taler://withdraw-exchange/exchange.demo.taler.net/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0",
- );
+ t.deepEqual(url, "taler://withdraw-exchange/exchange.demo.taler.net/");
});
test("taler withdraw exchange URI with amount (stringify)", (t) => {
const url = stringifyWithdrawExchange({
exchangeBaseUrl: "https://exchange.demo.taler.net",
- exchangePub: "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0",
amount: "KUDOS:19" as AmountString,
});
t.deepEqual(
url,
- "taler://withdraw-exchange/exchange.demo.taler.net/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0?a=KUDOS%3A19",
+ "taler://withdraw-exchange/exchange.demo.taler.net/?a=KUDOS%3A19",
);
});
-
/**
* 5.13 action: add-exchange https://lsd.gnunet.org/lsd0006/#name-action-add-exchange
*/
@@ -522,10 +511,7 @@ test("taler add exchange URI (parse)", (t) => {
t.fail();
return;
}
- t.deepEqual(
- r1.exchangeBaseUrl,
- "https://exchange.example.com/",
- );
+ t.deepEqual(r1.exchangeBaseUrl, "https://exchange.example.com/");
}
{
const r2 = parseAddExchangeUri(
@@ -535,22 +521,15 @@ test("taler add exchange URI (parse)", (t) => {
t.fail();
return;
}
- t.deepEqual(
- r2.exchangeBaseUrl,
- "https://exchanges.example.com/api/",
- );
+ t.deepEqual(r2.exchangeBaseUrl, "https://exchanges.example.com/api/");
}
-
});
test("taler add exchange URI (stringify)", (t) => {
const url = stringifyAddExchange({
exchangeBaseUrl: "https://exchange.demo.taler.net",
});
- t.deepEqual(
- url,
- "taler://add-exchange/exchange.demo.taler.net/",
- );
+ t.deepEqual(url, "taler://add-exchange/exchange.demo.taler.net/");
});
/**