commit 981d66ed066ab0dae4e432b05637899155d071dd
parent 59c9ff665fe605baa8d7ca7ead09940e43c9bf2c
Author: Florian Dold <florian@dold.me>
Date: Wed, 19 Feb 2025 23:15:40 +0100
fix tests
Diffstat:
3 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances-delete.ts
@@ -19,8 +19,8 @@
*/
import {
AccessToken,
+ HttpStatusCode,
MerchantAuthMethod,
- TalerError,
TalerMerchantManagementHttpClient,
URL,
} from "@gnu-taler/taler-util";
@@ -113,15 +113,12 @@ export async function runMerchantInstancesDeleteTest(t: GlobalTestState) {
// Check that deleting an instance checks the auth
// of the default instance.
{
- const exc = await t.assertThrowsAsync(async () => {
- await merchantManagementClient.deleteInstance(
- "secret-token:bla" as AccessToken,
- "myinst",
- );
- });
- console.log("Got expected exception", exc);
- t.assertTrue(exc instanceof TalerError);
- t.assertDeepEqual(exc.errorDetail.httpStatusCode, 401);
+ const res = await merchantManagementClient.deleteInstance(
+ "secret-token:bla" as AccessToken,
+ "myinst",
+ );
+ t.assertTrue(res.type === "fail");
+ t.assertTrue(res.case === HttpStatusCode.Unauthorized);
}
}
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances-urls.ts
@@ -81,23 +81,28 @@ export async function runMerchantInstancesUrlsTest(t: GlobalTestState) {
}),
);
- await clientForDefault.createInstance(undefined, {
- id: "myinst",
- address: {},
- default_pay_delay: Duration.toTalerProtocolDuration(
- Duration.fromSpec({ seconds: 60 }),
- ),
- use_stefan: true,
- default_wire_transfer_delay: Duration.toTalerProtocolDuration(
- Duration.fromSpec({ seconds: 60 }),
+ succeedOrThrow(
+ await clientForDefault.createInstance(
+ "secret-token:i-am-default" as AccessToken,
+ {
+ id: "myinst",
+ address: {},
+ default_pay_delay: Duration.toTalerProtocolDuration(
+ Duration.fromSpec({ seconds: 60 }),
+ ),
+ use_stefan: true,
+ default_wire_transfer_delay: Duration.toTalerProtocolDuration(
+ Duration.fromSpec({ seconds: 60 }),
+ ),
+ jurisdiction: {},
+ name: "My Second Instance",
+ auth: {
+ method: MerchantAuthMethod.TOKEN,
+ token: "secret-token:i-am-myinst" as AccessToken,
+ },
+ },
),
- jurisdiction: {},
- name: "My Second Instance",
- auth: {
- method: MerchantAuthMethod.TOKEN,
- token: "secret-token:i-am-myinst" as AccessToken,
- },
- });
+ );
async function check(url: string, token: string, expectedStatus: number) {
const resp = await harnessHttpLib.fetch(url, {
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-instances.ts b/packages/taler-harness/src/integrationtests/test-merchant-instances.ts
@@ -19,6 +19,7 @@
*/
import {
AccessToken,
+ HttpStatusCode,
MerchantAuthMethod,
succeedOrThrow,
TalerMerchantManagementHttpClient,
@@ -144,15 +145,10 @@ export async function runMerchantInstancesTest(t: GlobalTestState) {
token: "secret-token:foobar" as AccessToken,
});
- // Now this should fail, as we didn't change the auth of the client yet.
- const exc = await t.assertThrowsAsync(async () => {
- console.log("requesting instances with no auth");
- const resp = await merchantClient.listInstances(undefined);
- console.log("instances result:", resp);
- });
-
- console.log(exc);
- t.assertTrue(exc.errorDetail.httpStatusCode === 401);
+ console.log("requesting instances with no auth");
+ const exc = await merchantClient.listInstances(undefined);
+ t.assertTrue(exc.type === "fail");
+ t.assertTrue(exc.case === HttpStatusCode.Unauthorized);
const auth = "secret-token:foobar" as AccessToken;
@@ -187,11 +183,9 @@ export async function runMerchantInstancesTest(t: GlobalTestState) {
// Check that deleting an instance checks the auth
// of the default instance.
{
- const exc = await t.assertThrowsAsync(async () => {
- await merchantClient.deleteInstance(undefined, "myinst");
- });
- console.log(exc);
- t.assertTrue(exc.errorDetail.httpStatusCode === 401);
+ const res = await merchantClient.deleteInstance(undefined, "myinst");
+ t.assertTrue(res.type === "fail");
+ t.assertTrue(res.case === HttpStatusCode.Unauthorized);
}
}