aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-08-29 13:44:50 +0200
committerFlorian Dold <florian@dold.me>2023-08-29 13:44:50 +0200
commitebb1c58e7a2be01e42f35dfe6d890a08cf992c79 (patch)
tree7ecb9a2d082d499854502114924351329c7c1bf9 /packages/taler-harness
parent9402aeef5b111c3a9bf51a7b204044ba19de8607 (diff)
downloadwallet-core-ebb1c58e7a2be01e42f35dfe6d890a08cf992c79.tar.xz
wallet-core: remove usage of /wire
Diffstat (limited to 'packages/taler-harness')
-rw-r--r--packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts86
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts74
-rw-r--r--packages/taler-harness/src/lint.ts6
3 files changed, 104 insertions, 62 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
index dee00d1ff..d8f8767e6 100644
--- a/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
+++ b/packages/taler-harness/src/integrationtests/test-exchange-timetravel.ts
@@ -19,10 +19,16 @@
*/
import {
AbsoluteTime,
+ Amounts,
codecForExchangeKeysJson,
DenominationPubKey,
+ DenomKeyType,
Duration,
durationFromSpec,
+ encodeCrock,
+ ExchangeKeysJson,
+ hashDenomPub,
+ Logger,
} from "@gnu-taler/taler-util";
import {
createPlatformHttpLib,
@@ -40,6 +46,52 @@ import {
} from "../harness/harness.js";
import { withdrawViaBank } from "../harness/helpers.js";
+const logger = new Logger("test-exchange-timetravel.ts");
+
+interface DenomInfo {
+ denomPub: DenominationPubKey;
+ expireDeposit: string;
+}
+
+function getDenomInfoFromKeys(ek: ExchangeKeysJson): DenomInfo[] {
+ const denomInfos: DenomInfo[] = [];
+ for (const denomGroup of ek.denominations) {
+ switch (denomGroup.cipher) {
+ case "RSA":
+ case "RSA+age_restricted": {
+ let ageMask = 0;
+ if (denomGroup.cipher === "RSA+age_restricted") {
+ ageMask = denomGroup.age_mask;
+ }
+ for (const denomIn of denomGroup.denoms) {
+ const denomPub: DenominationPubKey = {
+ age_mask: ageMask,
+ cipher: DenomKeyType.Rsa,
+ rsa_public_key: denomIn.rsa_pub,
+ };
+ denomInfos.push({
+ denomPub,
+ expireDeposit: AbsoluteTime.stringify(
+ AbsoluteTime.fromProtocolTimestamp(denomIn.stamp_expire_deposit),
+ ),
+ });
+ }
+ break;
+ }
+ case "CS+age_restricted":
+ case "CS":
+ logger.warn("Clause-Schnorr denominations not supported");
+ continue;
+ default:
+ logger.warn(
+ `denomination type ${(denomGroup as any).cipher} not supported`,
+ );
+ continue;
+ }
+ }
+ return denomInfos;
+}
+
async function applyTimeTravel(
timetravelDuration: Duration,
s: {
@@ -144,7 +196,7 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) {
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:15" });
- const keysResp1 = await http.get(exchange.baseUrl + "keys");
+ const keysResp1 = await http.fetch(exchange.baseUrl + "keys");
const keys1 = await readSuccessResponseJsonOrThrow(
keysResp1,
codecForExchangeKeysJson(),
@@ -163,7 +215,7 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) {
merchant,
});
- const keysResp2 = await http.get(exchange.baseUrl + "keys");
+ const keysResp2 = await http.fetch(exchange.baseUrl + "keys");
const keys2 = await readSuccessResponseJsonOrThrow(
keysResp2,
codecForExchangeKeysJson(),
@@ -173,41 +225,31 @@ export async function runExchangeTimetravelTest(t: GlobalTestState) {
JSON.stringify(keys2, undefined, 2),
);
- const denomPubs1 = keys1.denoms.map((x) => {
- return {
- denomPub: x.denom_pub,
- expireDeposit: AbsoluteTime.stringify(
- AbsoluteTime.fromProtocolTimestamp(x.stamp_expire_deposit),
- ),
- };
- });
+ const denomPubs1 = getDenomInfoFromKeys(keys1);
+ const denomPubs2 = getDenomInfoFromKeys(keys2);
- const denomPubs2 = keys2.denoms.map((x) => {
- return {
- denomPub: x.denom_pub,
- expireDeposit: AbsoluteTime.stringify(
- AbsoluteTime.fromProtocolTimestamp(x.stamp_expire_deposit),
- ),
- };
- });
const dps2 = new Set(denomPubs2.map((x) => x.denomPub));
console.log("=== KEYS RESPONSE 1 ===");
console.log(
"list issue date",
- AbsoluteTime.stringify(AbsoluteTime.fromProtocolTimestamp(keys1.list_issue_date)),
+ AbsoluteTime.stringify(
+ AbsoluteTime.fromProtocolTimestamp(keys1.list_issue_date),
+ ),
);
- console.log("num denoms", keys1.denoms.length);
+ console.log("num denoms", denomPubs1.length);
console.log("denoms", JSON.stringify(denomPubs1, undefined, 2));
console.log("=== KEYS RESPONSE 2 ===");
console.log(
"list issue date",
- AbsoluteTime.stringify(AbsoluteTime.fromProtocolTimestamp(keys2.list_issue_date)),
+ AbsoluteTime.stringify(
+ AbsoluteTime.fromProtocolTimestamp(keys2.list_issue_date),
+ ),
);
- console.log("num denoms", keys2.denoms.length);
+ console.log("num denoms", denomPubs2.length);
console.log("denoms", JSON.stringify(denomPubs2, undefined, 2));
for (const da of denomPubs1) {
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts b/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts
index fca368dad..e959e813b 100644
--- a/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts
+++ b/packages/taler-harness/src/integrationtests/test-merchant-spec-public-orders.ts
@@ -72,7 +72,7 @@ async function testWithClaimToken(
let talerPayUri: string;
{
- const httpResp = await httpLib.get(
+ const httpResp = await httpLib.fetch(
new URL(`orders/${orderId}`, merchantBaseUrl).href,
);
const r = await httpResp.json();
@@ -83,7 +83,7 @@ async function testWithClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("token", claimToken);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
t.assertDeepEqual(httpResp.status, 402);
console.log(r);
@@ -94,7 +94,7 @@ async function testWithClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("token", claimToken);
- const httpResp = await httpLib.get(url.href, {
+ const httpResp = await httpLib.fetch(url.href, {
headers: {
Accept: "text/html",
},
@@ -120,7 +120,7 @@ async function testWithClaimToken(
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
const hcWrong = encodeCrock(getRandomBytes(64));
url.searchParams.set("h_contract", hcWrong);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 403);
@@ -131,7 +131,7 @@ async function testWithClaimToken(
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
const ctWrong = encodeCrock(getRandomBytes(16));
url.searchParams.set("token", ctWrong);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 403);
@@ -141,7 +141,7 @@ async function testWithClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("token", claimToken);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 402);
@@ -151,7 +151,7 @@ async function testWithClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("h_contract", contractTermsHash);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 402);
@@ -160,7 +160,7 @@ async function testWithClaimToken(
// claimed, unpaid, access without credentials
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 202);
@@ -178,7 +178,7 @@ async function testWithClaimToken(
// paid, access without credentials
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 202);
@@ -189,7 +189,7 @@ async function testWithClaimToken(
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
const hcWrong = encodeCrock(getRandomBytes(64));
url.searchParams.set("h_contract", hcWrong);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 403);
@@ -200,7 +200,7 @@ async function testWithClaimToken(
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
const ctWrong = encodeCrock(getRandomBytes(16));
url.searchParams.set("token", ctWrong);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 403);
@@ -210,7 +210,7 @@ async function testWithClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("h_contract", contractTermsHash);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 200);
@@ -220,7 +220,7 @@ async function testWithClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("token", claimToken);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 200);
@@ -232,7 +232,7 @@ async function testWithClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("token", claimToken);
- const httpResp = await httpLib.get(url.href, {
+ const httpResp = await httpLib.fetch(url.href, {
headers: { Accept: "text/html" },
});
t.assertDeepEqual(httpResp.status, 200);
@@ -269,7 +269,7 @@ async function testWithClaimToken(
{
const url = new URL(`orders/${apOrderId}`, merchantBaseUrl);
url.searchParams.set("token", apToken);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 402);
@@ -280,7 +280,7 @@ async function testWithClaimToken(
const url = new URL(`orders/${apOrderId}`, merchantBaseUrl);
url.searchParams.set("token", apToken);
url.searchParams.set("session_id", sessionId);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 402);
@@ -293,7 +293,7 @@ async function testWithClaimToken(
const url = new URL(`orders/${apOrderId}`, merchantBaseUrl);
url.searchParams.set("token", apToken);
url.searchParams.set("session_id", sessionId);
- const httpResp = await httpLib.get(url.href, {
+ const httpResp = await httpLib.fetch(url.href, {
headers: { Accept: "text/html" },
});
t.assertDeepEqual(httpResp.status, 302);
@@ -326,7 +326,7 @@ async function testWithoutClaimToken(
let talerPayUri: string;
{
- const httpResp = await httpLib.get(
+ const httpResp = await httpLib.fetch(
new URL(`orders/${orderId}`, merchantBaseUrl).href,
);
const r = await httpResp.json();
@@ -336,7 +336,7 @@ async function testWithoutClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
t.assertDeepEqual(httpResp.status, 402);
console.log(r);
@@ -346,7 +346,7 @@ async function testWithoutClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href, {
+ const httpResp = await httpLib.fetch(url.href, {
headers: {
Accept: "text/html",
},
@@ -374,7 +374,7 @@ async function testWithoutClaimToken(
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
const hcWrong = encodeCrock(getRandomBytes(64));
url.searchParams.set("h_contract", hcWrong);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 403);
@@ -385,7 +385,7 @@ async function testWithoutClaimToken(
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
const ctWrong = encodeCrock(getRandomBytes(16));
url.searchParams.set("token", ctWrong);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 403);
@@ -394,7 +394,7 @@ async function testWithoutClaimToken(
// claimed, unpaid, no claim token
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 402);
@@ -404,7 +404,7 @@ async function testWithoutClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("h_contract", contractTermsHash);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 402);
@@ -413,7 +413,7 @@ async function testWithoutClaimToken(
// claimed, unpaid, access without credentials
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
// No credentials, but the order doesn't require a claim token.
@@ -434,7 +434,7 @@ async function testWithoutClaimToken(
// paid, access without credentials
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 200);
@@ -445,7 +445,7 @@ async function testWithoutClaimToken(
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
const hcWrong = encodeCrock(getRandomBytes(64));
url.searchParams.set("h_contract", hcWrong);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 403);
@@ -456,7 +456,7 @@ async function testWithoutClaimToken(
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
const ctWrong = encodeCrock(getRandomBytes(16));
url.searchParams.set("token", ctWrong);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 403);
@@ -466,7 +466,7 @@ async function testWithoutClaimToken(
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
url.searchParams.set("h_contract", contractTermsHash);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 200);
@@ -475,7 +475,7 @@ async function testWithoutClaimToken(
// paid, JSON
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 200);
@@ -486,7 +486,7 @@ async function testWithoutClaimToken(
// paid, HTML
{
const url = new URL(`orders/${orderId}`, merchantBaseUrl);
- const httpResp = await httpLib.get(url.href, {
+ const httpResp = await httpLib.fetch(url.href, {
headers: { Accept: "text/html" },
});
t.assertDeepEqual(httpResp.status, 200);
@@ -523,7 +523,7 @@ async function testWithoutClaimToken(
{
const url = new URL(`orders/${apOrderId}`, merchantBaseUrl);
url.searchParams.set("token", apToken);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 402);
@@ -534,7 +534,7 @@ async function testWithoutClaimToken(
const url = new URL(`orders/${apOrderId}`, merchantBaseUrl);
url.searchParams.set("token", apToken);
url.searchParams.set("session_id", sessionId);
- const httpResp = await httpLib.get(url.href);
+ const httpResp = await httpLib.fetch(url.href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(httpResp.status, 402);
@@ -547,7 +547,7 @@ async function testWithoutClaimToken(
const url = new URL(`orders/${apOrderId}`, merchantBaseUrl);
url.searchParams.set("token", apToken);
url.searchParams.set("session_id", sessionId);
- const httpResp = await httpLib.get(url.href, {
+ const httpResp = await httpLib.fetch(url.href, {
headers: { Accept: "text/html" },
});
t.assertDeepEqual(httpResp.status, 302);
@@ -572,14 +572,14 @@ export async function runMerchantSpecPublicOrdersTest(t: GlobalTestState) {
const merchantBaseUrl = merchant.makeInstanceBaseUrl();
{
- const httpResp = await httpLib.get(new URL("config", merchantBaseUrl).href);
+ const httpResp = await httpLib.fetch(new URL("config", merchantBaseUrl).href);
const r = await httpResp.json();
console.log(r);
t.assertDeepEqual(r.currency, "TESTKUDOS");
}
{
- const httpResp = await httpLib.get(
+ const httpResp = await httpLib.fetch(
new URL("orders/foo", merchantBaseUrl).href,
);
const r = await httpResp.json();
@@ -589,7 +589,7 @@ export async function runMerchantSpecPublicOrdersTest(t: GlobalTestState) {
}
{
- const httpResp = await httpLib.get(
+ const httpResp = await httpLib.fetch(
new URL("orders/foo", merchantBaseUrl).href,
{
headers: {
diff --git a/packages/taler-harness/src/lint.ts b/packages/taler-harness/src/lint.ts
index f13049710..6d8e679db 100644
--- a/packages/taler-harness/src/lint.ts
+++ b/packages/taler-harness/src/lint.ts
@@ -407,7 +407,7 @@ export async function checkExchangeHttpd(
{
const mgmtUrl = new URL("management/keys", baseUrl);
- const resp = await httpLib.get(mgmtUrl.href);
+ const resp = await httpLib.fetch(mgmtUrl.href);
const futureKeys = await readSuccessResponseJsonOrThrow(
resp,
@@ -431,7 +431,7 @@ export async function checkExchangeHttpd(
{
const keysUrl = new URL("keys", baseUrl);
- const resp = await Promise.race([httpLib.get(keysUrl.href), delayMs(2000)]);
+ const resp = await Promise.race([httpLib.fetch(keysUrl.href), delayMs(2000)]);
if (!resp) {
context.numErr++;
@@ -467,7 +467,7 @@ export async function checkExchangeHttpd(
{
const keysUrl = new URL("wire", baseUrl);
- const resp = await Promise.race([httpLib.get(keysUrl.href), delayMs(2000)]);
+ const resp = await Promise.race([httpLib.fetch(keysUrl.href), delayMs(2000)]);
if (!resp) {
context.numErr++;