aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-01-20 20:31:32 +0100
committerFlorian Dold <florian@dold.me>2021-01-20 20:31:32 +0100
commitbd6972233d7e149166512dc4b357112b413439ae (patch)
tree3319ff89d2bb0b5b6bc301c0d05e422193623343 /packages/taler-wallet-cli
parent5f3c02d31a223add55a32b20f4a289210cbb4f15 (diff)
add permissions to libeufin integration test
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/libeufin.ts58
-rw-r--r--packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts31
2 files changed, 87 insertions, 2 deletions
diff --git a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
index cb739f52d..703f1522e 100644
--- a/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/libeufin.ts
@@ -273,6 +273,22 @@ export interface CreateTalerWireGatewayFacadeRequest {
reserveTransferLevel: "report" | "statement" | "notification";
}
+export interface CreateNexusUserRequest {
+ username: string;
+ password: string;
+}
+
+export interface PostNexusPermissionRequest {
+ action: "revoke" | "grant";
+ permission: {
+ subjectType: string;
+ subjectId: string;
+ resourceType: string;
+ resourceId: string;
+ permissionName: string;
+ }
+}
+
export namespace LibeufinNexusApi {
export async function createEbicsBankConnection(
libeufinNexusService: LibeufinNexusServiceInterface,
@@ -392,6 +408,48 @@ export namespace LibeufinNexusApi {
);
}
+ export async function createUser(
+ libeufinNexusService: LibeufinNexusServiceInterface,
+ req: CreateNexusUserRequest,
+ ) {
+ const baseUrl = libeufinNexusService.baseUrl;
+ let url = new URL(
+ `/users`,
+ baseUrl,
+ );
+ await axios.post(
+ url.href,
+ req,
+ {
+ auth: {
+ username: "admin",
+ password: "test",
+ },
+ },
+ );
+ }
+
+ export async function postPermission(
+ libeufinNexusService: LibeufinNexusServiceInterface,
+ req: PostNexusPermissionRequest,
+ ) {
+ const baseUrl = libeufinNexusService.baseUrl;
+ let url = new URL(
+ `/permissions`,
+ baseUrl,
+ );
+ 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/test-libeufin-basic.ts b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
index 39980dac9..67ee513b2 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-basic.ts
@@ -142,6 +142,33 @@ export async function createLibeufinTestEnvironment(
reserveTransferLevel: "report",
});
+ await LibeufinNexusApi.createUser(libeufinNexus, {
+ username: "twguser",
+ password: "twgpw",
+ });
+
+ await LibeufinNexusApi.postPermission(libeufinNexus, {
+ action: "grant",
+ permission: {
+ subjectType: "user",
+ subjectId: "twguser",
+ resourceType: "facade",
+ resourceId: "twg1",
+ permissionName: "facade.talerWireGateway.history"
+ }
+ });
+
+ await LibeufinNexusApi.postPermission(libeufinNexus, {
+ action: "grant",
+ permission: {
+ subjectType: "user",
+ subjectId: "twguser",
+ resourceType: "facade",
+ resourceId: "twg1",
+ permissionName: "facade.talerWireGateway.transfer"
+ }
+ });
+
const exchange = ExchangeService.create(t, {
name: "testexchange-1",
currency: "EUR",
@@ -157,8 +184,8 @@ export async function createLibeufinTestEnvironment(
});
const exchangeBankAccount: ExchangeBankAccount = {
- accountName: "twg-user",
- accountPassword: "123",
+ accountName: "twguser",
+ accountPassword: "twgpw",
accountPaytoUri: `payto://iban/${exchangeIban}?receiver-name=Exchange`,
wireGatewayApiBaseUrl:
"http://localhost:5011/facades/twg1/taler-wire-gateway/",