add permissions to libeufin integration test
This commit is contained in:
parent
5f3c02d31a
commit
bd6972233d
@ -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,
|
||||
|
@ -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/",
|
||||
|
Loading…
Reference in New Issue
Block a user