harness: check idempotency of merchant account creation API
This commit is contained in:
parent
665c42f595
commit
da4f3900b4
@ -1825,6 +1825,7 @@ export class MerchantService implements MerchantServiceInterface {
|
|||||||
if (!this.proc) {
|
if (!this.proc) {
|
||||||
throw Error("merchant must be running to add instance");
|
throw Error("merchant must be running to add instance");
|
||||||
}
|
}
|
||||||
|
console.trace("here!");
|
||||||
logger.info("adding instance");
|
logger.info("adding instance");
|
||||||
const url = `http://localhost:${this.merchantConfig.httpPort}/management/instances`;
|
const url = `http://localhost:${this.merchantConfig.httpPort}/management/instances`;
|
||||||
const auth = instanceConfig.auth ?? { method: "external" };
|
const auth = instanceConfig.auth ?? { method: "external" };
|
||||||
|
@ -176,7 +176,10 @@ export interface LibeufinSandboxAddIncomingRequest {
|
|||||||
direction: string;
|
direction: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const libeufinHttpLib = createPlatformHttpLib();
|
const libeufinHarnessHttpLib = createPlatformHttpLib({
|
||||||
|
allowHttp: true,
|
||||||
|
enableThrottling: false,
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIs spread across Legacy and Access, it is therefore
|
* APIs spread across Legacy and Access, it is therefore
|
||||||
@ -192,7 +195,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
iban: string | null = null,
|
iban: string | null = null,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
let url = new URL("testing/register", libeufinSandboxService.baseUrl);
|
let url = new URL("testing/register", libeufinSandboxService.baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: {
|
body: {
|
||||||
username: username,
|
username: username,
|
||||||
@ -211,7 +214,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// baseUrl should already be pointed to one demobank.
|
// baseUrl should already be pointed to one demobank.
|
||||||
let url = new URL("ebics/subscribers", libeufinSandboxService.baseUrl);
|
let url = new URL("ebics/subscribers", libeufinSandboxService.baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: {
|
body: {
|
||||||
userID: req.userID,
|
userID: req.userID,
|
||||||
@ -228,7 +231,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinSandboxService.baseUrl;
|
const baseUrl = libeufinSandboxService.baseUrl;
|
||||||
let url = new URL(`admin/ebics/hosts/${hostID}/rotate-keys`, baseUrl);
|
let url = new URL(`admin/ebics/hosts/${hostID}/rotate-keys`, baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: {},
|
body: {},
|
||||||
});
|
});
|
||||||
@ -239,7 +242,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinSandboxService.baseUrl;
|
const baseUrl = libeufinSandboxService.baseUrl;
|
||||||
let url = new URL("admin/ebics/hosts", baseUrl);
|
let url = new URL("admin/ebics/hosts", baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: {
|
body: {
|
||||||
hostID,
|
hostID,
|
||||||
@ -255,7 +258,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinSandboxService.baseUrl;
|
const baseUrl = libeufinSandboxService.baseUrl;
|
||||||
let url = new URL(`admin/bank-accounts/${req.label}`, baseUrl);
|
let url = new URL(`admin/bank-accounts/${req.label}`, baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: req,
|
body: req,
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
@ -272,7 +275,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinSandboxService.baseUrl;
|
const baseUrl = libeufinSandboxService.baseUrl;
|
||||||
let url = new URL("admin/ebics/subscribers", baseUrl);
|
let url = new URL("admin/ebics/subscribers", baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: req,
|
body: req,
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
@ -289,7 +292,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinSandboxService.baseUrl;
|
const baseUrl = libeufinSandboxService.baseUrl;
|
||||||
let url = new URL("admin/ebics/bank-accounts", baseUrl);
|
let url = new URL("admin/ebics/bank-accounts", baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: req,
|
body: req,
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
@ -306,7 +309,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
`admin/bank-accounts/${accountLabel}/simulate-incoming-transaction`,
|
`admin/bank-accounts/${accountLabel}/simulate-incoming-transaction`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: req,
|
body: req,
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
@ -322,7 +325,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
`admin/bank-accounts/${accountLabel}/transactions`,
|
`admin/bank-accounts/${accountLabel}/transactions`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
const res = await libeufinHttpLib.fetch(url.href, {
|
const res = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return (await res.json()) as SandboxAccountTransactions;
|
return (await res.json()) as SandboxAccountTransactions;
|
||||||
@ -334,7 +337,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const baseUrl = libeufinSandboxService.baseUrl;
|
const baseUrl = libeufinSandboxService.baseUrl;
|
||||||
let url = new URL("admin/payments/camt", baseUrl);
|
let url = new URL("admin/payments/camt", baseUrl);
|
||||||
return await libeufinHttpLib.fetch(url.href, {
|
return await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {
|
body: {
|
||||||
@ -350,7 +353,7 @@ export namespace LibeufinSandboxApi {
|
|||||||
): Promise<LibeufinSandboxAdminBankAccountBalance> {
|
): Promise<LibeufinSandboxAdminBankAccountBalance> {
|
||||||
const baseUrl = libeufinSandboxService.baseUrl;
|
const baseUrl = libeufinSandboxService.baseUrl;
|
||||||
let url = new URL(`admin/bank-accounts/${accountLabel}`, baseUrl);
|
let url = new URL(`admin/bank-accounts/${accountLabel}`, baseUrl);
|
||||||
const res = await libeufinHttpLib.fetch(url.href, {
|
const res = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return res.json();
|
return res.json();
|
||||||
@ -362,7 +365,7 @@ export namespace LibeufinNexusApi {
|
|||||||
nexus: LibeufinNexusServiceInterface,
|
nexus: LibeufinNexusServiceInterface,
|
||||||
): Promise<NexusBankConnections> {
|
): Promise<NexusBankConnections> {
|
||||||
let url = new URL("bank-connections", nexus.baseUrl);
|
let url = new URL("bank-connections", nexus.baseUrl);
|
||||||
const res = await libeufinHttpLib.fetch(url.href, {
|
const res = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return res.json();
|
return res.json();
|
||||||
@ -374,7 +377,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL("bank-connections/delete-connection", baseUrl);
|
let url = new URL("bank-connections/delete-connection", baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: req,
|
body: req,
|
||||||
@ -387,7 +390,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL("bank-connections", baseUrl);
|
let url = new URL("bank-connections", baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {
|
body: {
|
||||||
@ -411,7 +414,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`bank-accounts/${accountName}`, baseUrl);
|
let url = new URL(`bank-accounts/${accountName}`, baseUrl);
|
||||||
const resp = await libeufinHttpLib.fetch(url.href, {
|
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return resp.json();
|
return resp.json();
|
||||||
@ -427,7 +430,7 @@ export namespace LibeufinNexusApi {
|
|||||||
`bank-accounts/${accountName}/payment-initiations/${paymentId}/submit`,
|
`bank-accounts/${accountName}/payment-initiations/${paymentId}/submit`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {},
|
body: {},
|
||||||
@ -443,7 +446,7 @@ export namespace LibeufinNexusApi {
|
|||||||
`bank-connections/${connectionName}/fetch-accounts`,
|
`bank-connections/${connectionName}/fetch-accounts`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {},
|
body: {},
|
||||||
@ -461,7 +464,7 @@ export namespace LibeufinNexusApi {
|
|||||||
`bank-connections/${connectionName}/import-account`,
|
`bank-connections/${connectionName}/import-account`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {
|
body: {
|
||||||
@ -477,7 +480,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`bank-connections/${connectionName}/connect`, baseUrl);
|
let url = new URL(`bank-connections/${connectionName}/connect`, baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {},
|
body: {},
|
||||||
@ -495,7 +498,7 @@ export namespace LibeufinNexusApi {
|
|||||||
`/bank-accounts/${accountName}/payment-initiations`,
|
`/bank-accounts/${accountName}/payment-initiations`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
let response = await libeufinHttpLib.fetch(url.href, {
|
let response = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
const respJson = await response.json();
|
const respJson = await response.json();
|
||||||
@ -518,7 +521,7 @@ export namespace LibeufinNexusApi {
|
|||||||
for (const [k, v] of Object.entries(params)) {
|
for (const [k, v] of Object.entries(params)) {
|
||||||
url.searchParams.set(k, String(v));
|
url.searchParams.set(k, String(v));
|
||||||
}
|
}
|
||||||
let response = await libeufinHttpLib.fetch(url.href, {
|
let response = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return response.json();
|
return response.json();
|
||||||
@ -534,7 +537,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<LibeufinNexusTransactions> {
|
): Promise<LibeufinNexusTransactions> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`/bank-accounts/${accountName}/transactions`, baseUrl);
|
let url = new URL(`/bank-accounts/${accountName}/transactions`, baseUrl);
|
||||||
let response = await libeufinHttpLib.fetch(url.href, {
|
let response = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return response.json();
|
return response.json();
|
||||||
@ -553,7 +556,7 @@ export namespace LibeufinNexusApi {
|
|||||||
`/bank-accounts/${accountName}/fetch-transactions`,
|
`/bank-accounts/${accountName}/fetch-transactions`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
const resp = await libeufinHttpLib.fetch(url.href, {
|
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {
|
body: {
|
||||||
@ -572,7 +575,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`/users/${username}/password`, baseUrl);
|
let url = new URL(`/users/${username}/password`, baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: req,
|
body: req,
|
||||||
@ -585,7 +588,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<NexusUserResponse> {
|
): Promise<NexusUserResponse> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`/user`, baseUrl);
|
let url = new URL(`/user`, baseUrl);
|
||||||
const resp = await libeufinHttpLib.fetch(url.href, {
|
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return resp.json();
|
return resp.json();
|
||||||
@ -597,7 +600,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`/users`, baseUrl);
|
let url = new URL(`/users`, baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: req,
|
body: req,
|
||||||
@ -609,7 +612,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<NexusGetPermissionsResponse> {
|
): Promise<NexusGetPermissionsResponse> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`/permissions`, baseUrl);
|
let url = new URL(`/permissions`, baseUrl);
|
||||||
const resp = await libeufinHttpLib.fetch(url.href, {
|
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return resp.json();
|
return resp.json();
|
||||||
@ -621,7 +624,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`/permissions`, baseUrl);
|
let url = new URL(`/permissions`, baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: req,
|
body: req,
|
||||||
@ -634,7 +637,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<NexusTaskCollection> {
|
): Promise<NexusTaskCollection> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl);
|
let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl);
|
||||||
const resp = await libeufinHttpLib.fetch(url.href, {
|
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return resp.json();
|
return resp.json();
|
||||||
@ -653,7 +656,7 @@ export namespace LibeufinNexusApi {
|
|||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
if (taskName) url = new URL(taskName, `${url.href}/`);
|
if (taskName) url = new URL(taskName, `${url.href}/`);
|
||||||
const resp = await libeufinHttpLib.fetch(url.href, {
|
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
return resp.json();
|
return resp.json();
|
||||||
@ -669,7 +672,7 @@ export namespace LibeufinNexusApi {
|
|||||||
`/bank-accounts/${bankAccountName}/schedule/${taskName}`,
|
`/bank-accounts/${bankAccountName}/schedule/${taskName}`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
@ -682,7 +685,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl);
|
let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: req,
|
body: req,
|
||||||
@ -695,7 +698,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL(`facades/${facadeName}`, baseUrl);
|
let url = new URL(`facades/${facadeName}`, baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
@ -706,7 +709,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<NexusFacadeListResponse> {
|
): Promise<NexusFacadeListResponse> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL("facades", baseUrl);
|
let url = new URL("facades", baseUrl);
|
||||||
const resp = await libeufinHttpLib.fetch(url.href, {
|
const resp = await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
});
|
});
|
||||||
// FIXME: Just return validated, typed response here!
|
// FIXME: Just return validated, typed response here!
|
||||||
@ -719,7 +722,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL("facades", baseUrl);
|
let url = new URL("facades", baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {
|
body: {
|
||||||
@ -741,7 +744,7 @@ export namespace LibeufinNexusApi {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const baseUrl = libeufinNexusService.baseUrl;
|
const baseUrl = libeufinNexusService.baseUrl;
|
||||||
let url = new URL("facades", baseUrl);
|
let url = new URL("facades", baseUrl);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {
|
body: {
|
||||||
@ -766,7 +769,7 @@ export namespace LibeufinNexusApi {
|
|||||||
`/bank-accounts/${accountId}/submit-all-payment-initiations`,
|
`/bank-accounts/${accountId}/submit-all-payment-initiations`,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
await libeufinHttpLib.fetch(url.href, {
|
await libeufinHarnessHttpLib.fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
headers: { Authorization: makeBasicAuthHeader("admin", "secret") },
|
||||||
body: {},
|
body: {},
|
||||||
|
@ -82,13 +82,14 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
|
|||||||
name: "w0",
|
name: "w0",
|
||||||
});
|
});
|
||||||
|
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient: walletClientZero,
|
walletClient: walletClientZero,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
amount: "TESTKUDOS:20",
|
amount: "TESTKUDOS:20",
|
||||||
restrictAge: 13,
|
restrictAge: 13,
|
||||||
});
|
});
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
const order = {
|
const order = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
@ -111,13 +112,14 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
|
|||||||
{
|
{
|
||||||
const walletClient = walletClientOne;
|
const walletClient = walletClientOne;
|
||||||
|
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient,
|
walletClient,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
amount: "TESTKUDOS:20",
|
amount: "TESTKUDOS:20",
|
||||||
restrictAge: 13,
|
restrictAge: 13,
|
||||||
});
|
});
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
const order = {
|
const order = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
@ -136,13 +138,14 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
|
|||||||
{
|
{
|
||||||
const walletClient = walletClientTwo;
|
const walletClient = walletClientTwo;
|
||||||
|
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient,
|
walletClient,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
amount: "TESTKUDOS:20",
|
amount: "TESTKUDOS:20",
|
||||||
restrictAge: 13,
|
restrictAge: 13,
|
||||||
});
|
});
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
const order = {
|
const order = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
@ -160,12 +163,13 @@ export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
|
|||||||
{
|
{
|
||||||
const walletClient = walletClientThree;
|
const walletClient = walletClientThree;
|
||||||
|
|
||||||
await withdrawViaBankV2(t, {
|
const wres = await withdrawViaBankV2(t, {
|
||||||
walletClient,
|
walletClient,
|
||||||
bank,
|
bank,
|
||||||
exchange,
|
exchange,
|
||||||
amount: "TESTKUDOS:20",
|
amount: "TESTKUDOS:20",
|
||||||
});
|
});
|
||||||
|
await wres.withdrawalFinishedCond;
|
||||||
|
|
||||||
const order = {
|
const order = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
|
@ -84,12 +84,6 @@ export async function runBankApiTest(t: GlobalTestState) {
|
|||||||
|
|
||||||
await merchant.start();
|
await merchant.start();
|
||||||
await merchant.pingUntilAvailable();
|
await merchant.pingUntilAvailable();
|
||||||
await merchant.addDefaultInstance();
|
|
||||||
await merchant.addInstanceWithWireAccount({
|
|
||||||
id: "minst1",
|
|
||||||
name: "minst1",
|
|
||||||
paytoUris: [getPayto("minst1")],
|
|
||||||
});
|
|
||||||
|
|
||||||
await merchant.addInstanceWithWireAccount({
|
await merchant.addInstanceWithWireAccount({
|
||||||
id: "default",
|
id: "default",
|
||||||
@ -97,6 +91,12 @@ export async function runBankApiTest(t: GlobalTestState) {
|
|||||||
paytoUris: [getPayto("merchant-default")],
|
paytoUris: [getPayto("merchant-default")],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await merchant.addInstanceWithWireAccount({
|
||||||
|
id: "minst1",
|
||||||
|
name: "minst1",
|
||||||
|
paytoUris: [getPayto("minst1")],
|
||||||
|
});
|
||||||
|
|
||||||
console.log("setup done!");
|
console.log("setup done!");
|
||||||
|
|
||||||
const bankUser = await BankApi.registerAccount(bank, "user1", "pw1", {});
|
const bankUser = await BankApi.registerAccount(bank, "user1", "pw1", {});
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
AbsoluteTime,
|
AbsoluteTime,
|
||||||
MerchantContractTerms,
|
|
||||||
Duration,
|
Duration,
|
||||||
|
MerchantContractTerms,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
WalletApiOperation,
|
|
||||||
HarnessExchangeBankAccount,
|
HarnessExchangeBankAccount,
|
||||||
|
WalletApiOperation,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
|
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
|
||||||
import {
|
import {
|
||||||
@ -32,20 +32,19 @@ import {
|
|||||||
ExchangeService,
|
ExchangeService,
|
||||||
GlobalTestState,
|
GlobalTestState,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
setupDb,
|
|
||||||
WalletCli,
|
|
||||||
WalletClient,
|
WalletClient,
|
||||||
|
setupDb,
|
||||||
} from "../harness/harness.js";
|
} from "../harness/harness.js";
|
||||||
|
import {
|
||||||
|
createWalletDaemonWithClient,
|
||||||
|
makeTestPaymentV2,
|
||||||
|
} from "../harness/helpers.js";
|
||||||
import {
|
import {
|
||||||
LibeufinNexusApi,
|
LibeufinNexusApi,
|
||||||
LibeufinNexusService,
|
LibeufinNexusService,
|
||||||
LibeufinSandboxApi,
|
LibeufinSandboxApi,
|
||||||
LibeufinSandboxService,
|
LibeufinSandboxService,
|
||||||
} from "../harness/libeufin.js";
|
} from "../harness/libeufin.js";
|
||||||
import {
|
|
||||||
createWalletDaemonWithClient,
|
|
||||||
makeTestPaymentV2,
|
|
||||||
} from "../harness/helpers.js";
|
|
||||||
|
|
||||||
const exchangeIban = "DE71500105179674997361";
|
const exchangeIban = "DE71500105179674997361";
|
||||||
const customerIban = "DE84500105176881385584";
|
const customerIban = "DE84500105176881385584";
|
||||||
@ -73,7 +72,7 @@ export async function createLibeufinTestEnvironment(
|
|||||||
|
|
||||||
const libeufinSandbox = await LibeufinSandboxService.create(t, {
|
const libeufinSandbox = await LibeufinSandboxService.create(t, {
|
||||||
httpPort: 5010,
|
httpPort: 5010,
|
||||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
databaseJdbcUri: db.connStr,
|
||||||
});
|
});
|
||||||
|
|
||||||
await libeufinSandbox.start();
|
await libeufinSandbox.start();
|
||||||
@ -81,7 +80,7 @@ export async function createLibeufinTestEnvironment(
|
|||||||
|
|
||||||
const libeufinNexus = await LibeufinNexusService.create(t, {
|
const libeufinNexus = await LibeufinNexusService.create(t, {
|
||||||
httpPort: 5011,
|
httpPort: 5011,
|
||||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-nexus.sqlite3`,
|
databaseJdbcUri: db.connStr,
|
||||||
});
|
});
|
||||||
|
|
||||||
await libeufinNexus.start();
|
await libeufinNexus.start();
|
||||||
@ -218,7 +217,7 @@ export async function createLibeufinTestEnvironment(
|
|||||||
console.log("setup done!");
|
console.log("setup done!");
|
||||||
|
|
||||||
const { walletClient } = await createWalletDaemonWithClient(t, {
|
const { walletClient } = await createWalletDaemonWithClient(t, {
|
||||||
name: "default ",
|
name: "default",
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -86,6 +86,16 @@ export async function runMerchantInstancesTest(t: GlobalTestState) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add it again, should be idempotent
|
||||||
|
await merchant.addInstanceWithWireAccount({
|
||||||
|
id: "default",
|
||||||
|
name: "Default Instance",
|
||||||
|
paytoUris: [getPayto("merchant-default")],
|
||||||
|
auth: {
|
||||||
|
method: "external",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Add an instance, no auth!
|
// Add an instance, no auth!
|
||||||
await merchant.addInstanceWithWireAccount({
|
await merchant.addInstanceWithWireAccount({
|
||||||
id: "myinst",
|
id: "myinst",
|
||||||
|
Loading…
Reference in New Issue
Block a user