From dcef82d677f8b79b0a7b78f485f08fcd0f7d8c96 Mon Sep 17 00:00:00 2001 From: MS Date: Fri, 14 May 2021 12:50:44 +0200 Subject: Libeufin, testing scheduling API --- .../src/integrationtests/libeufin.ts | 60 ++++++++++++++++++++++ .../src/integrationtests/testrunner.ts | 2 + 2 files changed, 62 insertions(+) diff --git a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts index 709148817..7dd0b98f0 100644 --- a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts +++ b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts @@ -828,6 +828,16 @@ export interface CreateNexusUserRequest { password: string; } +export interface PostNexusTaskRequest { + name: string; + cronspec: string; + type: string; // fetch | submit + params: { + level: string; // report | statement | all + rangeType: string; // all | since-last | previous-days | latest + } | {} +} + export interface PostNexusPermissionRequest { action: "revoke" | "grant"; permission: { @@ -1138,6 +1148,56 @@ export namespace LibeufinNexusApi { }); } + export async function getTasks( + libeufinNexusService: LibeufinNexusServiceInterface, + bankAccountName: string, + // When void, the request returns the list of all the + // tasks under this bank account. + taskName: string | void, + ): Promise { + const baseUrl = libeufinNexusService.baseUrl; + let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl); + if (taskName) url = new URL(taskName, `${url}/`); + + // It's caller's responsibility to interpret the response. + return await axios.get(url.href, { + auth: { + username: "admin", + password: "test", + }, + }); + } + + export async function deleteTask( + libeufinNexusService: LibeufinNexusServiceInterface, + bankAccountName: string, + taskName: string, + ) { + const baseUrl = libeufinNexusService.baseUrl; + let url = new URL(`/bank-accounts/${bankAccountName}/schedule/${taskName}`, baseUrl); + await axios.delete(url.href, { + auth: { + username: "admin", + password: "test", + }, + }); + } + + export async function postTask( + libeufinNexusService: LibeufinNexusServiceInterface, + bankAccountName: string, + req: PostNexusTaskRequest, + ): Promise { + const baseUrl = libeufinNexusService.baseUrl; + let url = new URL(`/bank-accounts/${bankAccountName}/schedule`, baseUrl); + return await axios.post(url.href, req, { + auth: { + username: "admin", + password: "test", + }, + }); + } + export async function createTwgFacade( libeufinNexusService: LibeufinNexusServiceInterface, req: CreateTalerWireGatewayFacadeRequest, diff --git a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts index 173ca2442..9d4fb5575 100644 --- a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts +++ b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts @@ -59,6 +59,7 @@ import { runLibeufinRefundTest } from "./test-libeufin-refund"; import { runLibeufinRefundMultipleUsersTest } from "./test-libeufin-refund-multiple-users"; import { runLibeufinTutorialTest } from "./test-libeufin-tutorial"; import { runLibeufinApiPermissionsTest } from "./test-libeufin-api-permissions"; +import { runLibeufinApiSchedulingTest } from "./test-libeufin-api-scheduling"; import { runLibeufinApiBankconnectionTest } from "./test-libeufin-api-bankconnection"; import { runLibeufinApiUsersTest } from "./test-libeufin-api-users"; import { runLibeufinApiBankaccountTest } from "./test-libeufin-api-bankaccount"; @@ -94,6 +95,7 @@ const allTests: TestMainFunction[] = [ runLibeufinRefundTest, runLibeufinRefundMultipleUsersTest, runLibeufinApiPermissionsTest, + runLibeufinApiSchedulingTest, runLibeufinApiUsersTest, runLibeufinApiBankaccountTest, runLibeufinApiBankconnectionTest, -- cgit v1.2.3