aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness/src/index.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-10-26 11:15:45 -0300
committerSebastian <sebasjm@gmail.com>2023-10-26 11:15:45 -0300
commita4c7bc4b284fe7dc4c65ceaad96fc67c40c9a708 (patch)
treef407ad06733a3a82a7c5655d65a81fc3e5248cc1 /packages/taler-harness/src/index.ts
parente812eae32daddad372c7629867298ca28678a44c (diff)
downloadwallet-core-a4c7bc4b284fe7dc4c65ceaad96fc67c40c9a708.tar.xz
moving cli test to harness
Diffstat (limited to 'packages/taler-harness/src/index.ts')
-rw-r--r--packages/taler-harness/src/index.ts95
1 files changed, 55 insertions, 40 deletions
diff --git a/packages/taler-harness/src/index.ts b/packages/taler-harness/src/index.ts
index 0f93abdbe..c83457be4 100644
--- a/packages/taler-harness/src/index.ts
+++ b/packages/taler-harness/src/index.ts
@@ -31,6 +31,7 @@ import {
RegisterAccountRequest,
TalerCoreBankHttpClient,
TalerCorebankApiClient,
+ TalerError,
addPaytoQueryParams,
decodeCrock,
encodeCrock,
@@ -67,6 +68,7 @@ import {
} from "./harness/harness.js";
import { getTestInfo, runTests } from "./integrationtests/testrunner.js";
import { lintExchangeDeployment } from "./lint.js";
+import { BankCoreSmokeTest } from "http-client/bank-core.js";
const logger = new Logger("taler-harness:index.ts");
@@ -657,7 +659,7 @@ deploymentCli
process.exit(2);
});
- deploymentCli
+deploymentCli
.subcommand("testBankAPI", "test-bank-api", {
help: "test api compatibility.",
})
@@ -666,53 +668,66 @@ deploymentCli
.action(async (args) => {
const httpLib = createPlatformHttpLib();
const api = new TalerCoreBankHttpClient(args.testBankAPI.corebankApiBaseUrl, httpLib);
-
- {
- logger.info("compatibility")
- const resp = await api.getConfig()
- if (!LibtoolVersion.compare(resp.body.version, api.PROTOCOL_VERSION)?.compatible) {
- logger.error("The API client is not compatible with the server", api.PROTOCOL_VERSION, resp.body.version)
- process.exit(1)
+
+ const tester = new BankCoreSmokeTest(api)
+ try {
+ process.stdout.write("config: ");
+ const config = await tester.testConfig()
+ console.log("ok")
+ const admin = args.testBankAPI.adminPwd
+ process.stdout.write("account management: ");
+ const withAdmin = !!admin && admin !== "-"
+ if (withAdmin) {
+ await tester.testAccountManagement(admin)
+ console.log("ok")
+ } else {
+ console.log("skipped")
}
- }
- if (!args.testBankAPI.adminPwd) {
- logger.info("test completed")
- process.exit(0)
- }
- let token: AccessToken;
- {
- logger.info("login admin")
- const resp = await api.getAuthenticationAPI("admin").createAccessToken(args.testBankAPI.adminPwd, {
- scope: "readwrite"
- })
- if (resp.type === "fail") {
- logger.error("login failed", resp.detail)
- process.exit(1)
+ process.stdout.write("transactions: ");
+ if (withAdmin) {
+ await tester.testTransactions(admin)
+ console.log("ok")
+ } else {
+ console.log("skipped")
}
- token = resp.body.access_token;
- }
- logger.info("account management")
- const username = "user-" + encodeCrock(getRandomBytes(10)).toLowerCase();
- {
- const resp = await api.createAccount(token, { name: username, password: "123", username })
- if (resp.type === "fail") {
- logger.error("create account failed", resp.detail)
- process.exit(1)
+ process.stdout.write("withdrawals: ");
+ if (withAdmin) {
+ await tester.testWithdrawals(admin)
+ console.log("ok")
+ } else {
+ console.log("skipped")
}
- }
- {
- const resp = await api.updateAccount({username, token}, { challenge_contact_data: {email: "asd"} })
- if (resp.type === "fail") {
- logger.error("create account failed", resp.detail)
- process.exit(1)
+
+ process.stdout.write("monitor: ");
+ if (withAdmin && config.have_cashout) {
+ await tester.testMonitor(admin)
+ console.log("ok")
+ } else {
+ console.log("skipped")
}
- }
+ process.stdout.write("cashout: ");
+ if (withAdmin && config.have_cashout) {
+ await tester.testCashouts(admin)
+ console.log("ok")
+ } else {
+ console.log("skipped")
+ }
- logger.info("test completed")
-
+ } catch (e: any) {
+ console.log("")
+ if (e instanceof TalerError) {
+ console.error("FAILED", JSON.stringify(e.errorDetail, undefined, 2))
+ console.error(e.stack)
+ } else if (e instanceof Error) {
+ console.error(`FAILED: ${e.message}`)
+ console.error(e.stack)
+ } else {
+ console.error(`FAILED: ${e}`)
+ }
+ }
});