add permissions to libeufin integration test

This commit is contained in:
Florian Dold 2021-01-20 20:31:32 +01:00
parent 5f3c02d31a
commit bd6972233d
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 87 additions and 2 deletions

View File

@ -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,

View File

@ -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/",