gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated (041e7ec3 -> 050461f2)


From: gnunet
Subject: [taler-wallet-core] branch master updated (041e7ec3 -> 050461f2)
Date: Thu, 04 Mar 2021 13:42:11 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository wallet-core.

    from 041e7ec3 merchant test: instance management only possibly via plain 
base URL
     new 032c486e install source maps for better error reports
     new 050461f2 test merchant issue reported by MS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 build-system/Makefile                              |  1 +
 .../src/integrationtests/harness.ts                | 24 ++++++++++++---
 .../integrationtests/test-merchant-instances.ts    | 36 +++++++++++++++++++---
 3 files changed, 52 insertions(+), 9 deletions(-)

diff --git a/build-system/Makefile b/build-system/Makefile
index 98994ac8..7d44c184 100644
--- a/build-system/Makefile
+++ b/build-system/Makefile
@@ -88,6 +88,7 @@ install: compile
        install -d $(install_target)/node_modules/taler-wallet-cli/bin
        install -d $(install_target)/node_modules/taler-wallet-cli/dist
        install ./packages/taler-wallet-cli/dist/taler-wallet-cli.js 
$(install_target)/node_modules/taler-wallet-cli/dist/
+       install ./packages/taler-wallet-cli/dist/taler-wallet-cli.js.map 
$(install_target)/node_modules/taler-wallet-cli/dist/
        install ./packages/taler-wallet-cli/bin/taler-wallet-cli 
$(install_target)/node_modules/taler-wallet-cli/bin/
        ln -sft $(prefix)/bin 
$(install_target)/node_modules/taler-wallet-cli/bin/taler-wallet-cli
 endif
diff --git a/packages/taler-wallet-cli/src/integrationtests/harness.ts 
b/packages/taler-wallet-cli/src/integrationtests/harness.ts
index a2d2b8e1..169aa8aa 100644
--- a/packages/taler-wallet-cli/src/integrationtests/harness.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/harness.ts
@@ -277,7 +277,9 @@ export class GlobalTestState {
   }
 
   assertAxiosError(e: any): asserts e is AxiosError {
-    return e.isAxiosError;
+    if (!e.isAxiosError) {
+      throw Error("expected axios error");
+    }
   }
 
   assertTrue(b: boolean): asserts b {
@@ -1191,6 +1193,14 @@ export class MerchantApiClient {
     });
   }
 
+  async deleteInstance(instanceId: string) {
+    const baseUrl = this.baseUrl;
+    const url = new URL(`private/instances/${instanceId}`);
+    await axios.delete(url.href, {
+      headers: this.makeAuthHeader(),
+    });
+  }
+
   async createInstance(req: MerchantInstanceConfig): Promise<void> {
     const baseUrl = this.baseUrl;
     const url = new URL("private/instances", baseUrl);
@@ -1209,10 +1219,14 @@ export class MerchantApiClient {
 
   async getInstanceFullDetails(instanceId: string): Promise<any> {
     const url = new URL(`private/instances/${instanceId}`, this.baseUrl);
-    const resp = await axios.get(url.href, {
-      headers: this.makeAuthHeader(),
-    });
-    return resp.data;
+    try {
+      const resp = await axios.get(url.href, {
+        headers: this.makeAuthHeader(),
+      });
+      return resp.data;
+    } catch (e) {
+      throw e;
+    }
   }
 
   makeAuthHeader(): Record<string, string> {
diff --git 
a/packages/taler-wallet-cli/src/integrationtests/test-merchant-instances.ts 
b/packages/taler-wallet-cli/src/integrationtests/test-merchant-instances.ts
index 4691487d..5d1c06e1 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-merchant-instances.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-merchant-instances.ts
@@ -80,13 +80,23 @@ export async function runMerchantInstancesTest(t: 
GlobalTestState) {
     },
   });
 
+  // Add an instance, no auth!
+  await merchant.addInstance({
+    id: "myinst",
+    name: "Second Instance",
+    paytoUris: [`payto://x-taler-bank/merchant-default`],
+    auth: {
+      method: "external",
+    },
+  });
+
   let merchantClient = new MerchantApiClient(merchant.makeInstanceBaseUrl(), {
     method: "external",
   });
 
   {
     const r = await merchantClient.getInstances();
-    t.assertDeepEqual(r.instances.length, 1);
+    t.assertDeepEqual(r.instances.length, 2);
   }
 
   // Check that a "malformed" bearer Authorization header gets ignored
@@ -94,7 +104,7 @@ export async function runMerchantInstancesTest(t: 
GlobalTestState) {
     const url = merchant.makeInstanceBaseUrl();
     const resp = await axios.get(new URL("private/instances", url).href, {
       headers: {
-        "Authorization": "foo bar-baz",
+        Authorization: "foo bar-baz",
       },
     });
     t.assertDeepEqual(resp.status, 200);
@@ -133,8 +143,8 @@ export async function runMerchantInstancesTest(t: 
GlobalTestState) {
     const resp = await axios.get(new URL("private/instances", url).href, {
       headers: {
         // Note the spaces
-        "Authorization": "Bearer     secret-token:foobar",
-      }
+        Authorization: "Bearer     secret-token:foobar",
+      },
     });
     t.assertDeepEqual(resp.status, 200);
   }
@@ -146,6 +156,24 @@ export async function runMerchantInstancesTest(t: 
GlobalTestState) {
     // Token should *not* be reported back.
     t.assertDeepEqual(fullDetails.auth.token, undefined);
   }
+
+  // Check that deleting an instance checks the auth
+  // of the default instance.
+  {
+    const unauthMerchantClient = new MerchantApiClient(
+      merchant.makeInstanceBaseUrl(),
+      {
+        method: "external",
+      },
+    );
+
+    const exc = await t.assertThrowsAsync(async () => {
+      await unauthMerchantClient.deleteInstance("");
+    });
+    console.log(exc);
+    t.assertAxiosError(exc);
+    t.assertDeepEqual(exc.response?.status, 403);
+  }
 }
 
 runMerchantInstancesTest.suites = ["merchant"];

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]