Adapt tests to Sandbox' new access control.

This commit is contained in:
ms 2021-09-17 16:02:34 +02:00
parent 9f00987380
commit 490620ad04
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
2 changed files with 71 additions and 9 deletions

View File

@ -218,6 +218,17 @@ export class LibeufinSandboxService implements LibeufinSandboxServiceInterface {
LIBEUFIN_SANDBOX_DB_CONNECTION: this.sandboxConfig.databaseJdbcUri, LIBEUFIN_SANDBOX_DB_CONNECTION: this.sandboxConfig.databaseJdbcUri,
}, },
); );
await runCommand(
this.globalTestState,
"libeufin-sandbox-superuser",
"libeufin-sandbox",
["superuser", "admin", "--password", "test"],
{
...process.env,
LIBEUFIN_SANDBOX_DB_CONNECTION: this.sandboxConfig.databaseJdbcUri,
},
);
this.sandboxProc = this.globalTestState.spawnService( this.sandboxProc = this.globalTestState.spawnService(
"libeufin-sandbox", "libeufin-sandbox",
["serve", "--port", `${this.sandboxConfig.httpPort}`], ["serve", "--port", `${this.sandboxConfig.httpPort}`],
@ -817,7 +828,12 @@ export namespace LibeufinSandboxApi {
) { ) {
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 axios.post(url.href); await axios.post(url.href, {}, {
auth: {
username: "admin",
password: "test",
},
});
} }
export async function createEbicsHost( export async function createEbicsHost(
libeufinSandboxService: LibeufinSandboxServiceInterface, libeufinSandboxService: LibeufinSandboxServiceInterface,
@ -828,6 +844,12 @@ export namespace LibeufinSandboxApi {
await axios.post(url.href, { await axios.post(url.href, {
hostID, hostID,
ebicsVersion: "2.5", ebicsVersion: "2.5",
},
{
auth: {
username: "admin",
password: "test",
},
}); });
} }
@ -837,7 +859,12 @@ export namespace LibeufinSandboxApi {
) { ) {
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 axios.post(url.href, req); await axios.post(url.href, req, {
auth: {
username: "admin",
password: "test",
},
});
} }
export async function createEbicsSubscriber( export async function createEbicsSubscriber(
@ -846,7 +873,12 @@ export namespace LibeufinSandboxApi {
) { ) {
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 axios.post(url.href, req); await axios.post(url.href, req, {
auth: {
username: "admin",
password: "test",
},
});
} }
export async function createEbicsBankAccount( export async function createEbicsBankAccount(
@ -855,7 +887,12 @@ export namespace LibeufinSandboxApi {
) { ) {
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 axios.post(url.href, req); await axios.post(url.href, req, {
auth: {
username: "admin",
password: "test",
},
});
} }
export async function bookPayment2( export async function bookPayment2(
@ -864,7 +901,12 @@ export namespace LibeufinSandboxApi {
) { ) {
const baseUrl = libeufinSandboxService.baseUrl; const baseUrl = libeufinSandboxService.baseUrl;
let url = new URL("admin/payments", baseUrl); let url = new URL("admin/payments", baseUrl);
await axios.post(url.href, req); await axios.post(url.href, req, {
auth: {
username: "admin",
password: "test",
},
});
} }
export async function bookPayment( export async function bookPayment(
@ -901,7 +943,12 @@ export namespace LibeufinSandboxApi {
`admin/bank-accounts/${accountLabel}/simulate-incoming-transaction`, `admin/bank-accounts/${accountLabel}/simulate-incoming-transaction`,
baseUrl, baseUrl,
); );
await axios.post(url.href, req); await axios.post(url.href, req, {
auth: {
username: "admin",
password: "test",
},
});
} }
export async function getAccountTransactions( export async function getAccountTransactions(
@ -913,7 +960,12 @@ export namespace LibeufinSandboxApi {
`admin/bank-accounts/${accountLabel}/transactions`, `admin/bank-accounts/${accountLabel}/transactions`,
baseUrl, baseUrl,
); );
const res = await axios.get(url.href); const res = await axios.get(url.href, {
auth: {
username: "admin",
password: "test",
},
});
return res.data as SandboxAccountTransactions; return res.data as SandboxAccountTransactions;
} }
@ -926,6 +978,12 @@ export namespace LibeufinSandboxApi {
return await axios.post(url.href, { return await axios.post(url.href, {
bankaccount: accountLabel, bankaccount: accountLabel,
type: 53, type: 53,
},
{
auth: {
username: "admin",
password: "test",
},
}); });
} }
@ -938,7 +996,12 @@ export namespace LibeufinSandboxApi {
`admin/bank-accounts/${accountLabel}`, `admin/bank-accounts/${accountLabel}`,
baseUrl, baseUrl,
); );
return await axios.get(url.href); return await axios.get(url.href, {
auth: {
username: "admin",
password: "test",
},
});
} }
} }

View File

@ -751,7 +751,6 @@ async function processReserveImpl(
break; break;
} }
} }
export async function createTalerWithdrawReserve( export async function createTalerWithdrawReserve(
ws: InternalWalletState, ws: InternalWalletState,
talerWithdrawUri: string, talerWithdrawUri: string,