gnunet-svn
[Top][All Lists]
Advanced

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

[taler-typescript-core] branch master updated: harness: test for new_mea


From: gnunet
Subject: [taler-typescript-core] branch master updated: harness: test for new_measures
Date: Tue, 21 Jan 2025 15:36:20 +0100

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

dold pushed a commit to branch master
in repository taler-typescript-core.

The following commit(s) were added to refs/heads/master by this push:
     new 64e63d508 harness: test for new_measures
64e63d508 is described below

commit 64e63d5089f5ab4049dfd466bcb64bb194e69aeb
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Jan 21 15:36:08 2025 +0100

    harness: test for new_measures
---
 packages/taler-harness/src/harness/environments.ts |  4 +--
 packages/taler-harness/src/index.ts                |  2 ++
 .../src/integrationtests/test-kyc-decisions.ts     |  5 +--
 .../src/integrationtests/test-kyc-new-measure.ts   |  2 +-
 ...expiration.ts => test-kyc-new-measures-prog.ts} | 36 ++++++++++++++++------
 .../integrationtests/test-kyc-skip-expiration.ts   |  7 ++---
 .../test-kyc-withdrawal-verboten.ts                |  3 +-
 .../src/integrationtests/testrunner.ts             |  2 ++
 packages/taler-util/src/types-taler-exchange.ts    |  2 ++
 packages/taler-util/src/types-taler-kyc-aml.ts     | 10 ++++++
 10 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/packages/taler-harness/src/harness/environments.ts 
b/packages/taler-harness/src/harness/environments.ts
index 17af401b4..7dddcf3ff 100644
--- a/packages/taler-harness/src/harness/environments.ts
+++ b/packages/taler-harness/src/harness/environments.ts
@@ -1031,7 +1031,7 @@ export async function postAmlDecision(
     amlPriv: string;
     amlPub: string;
     newRules: LegitimizationRuleSet;
-    newMeasure?: string | undefined;
+    newMeasures?: string;
     properties?: AccountProperties;
   },
 ) {
@@ -1043,7 +1043,7 @@ export async function postAmlDecision(
     justification: "Bla",
     keep_investigating: false,
     new_rules: req.newRules,
-    new_measures: req.newMeasure,
+    new_measures: req.newMeasures,
     properties: req.properties ?? {},
   };
 
diff --git a/packages/taler-harness/src/index.ts 
b/packages/taler-harness/src/index.ts
index 2c9a0e83c..4ae4e4562 100644
--- a/packages/taler-harness/src/index.ts
+++ b/packages/taler-harness/src/index.ts
@@ -86,6 +86,7 @@ import {
   runTestWithState,
   waitMs,
 } from "./harness/harness.js";
+import { AML_PROGRAM_TEST_KYC_NEW_MEASURES_PROG } from 
"./integrationtests/test-kyc-new-measures-prog.js";
 import { getTestInfo, runTests } from "./integrationtests/testrunner.js";
 import { lintExchangeDeployment } from "./lint.js";
 
@@ -1550,6 +1551,7 @@ const allAmlPrograms: TalerKycAml.AmlProgramDefinition[] 
= [
   },
   AML_PROGRAM_FROM_ATTRIBUTES_TO_CONTEXT,
   AML_PROGRAM_NEXT_MEASURE_FORM,
+  AML_PROGRAM_TEST_KYC_NEW_MEASURES_PROG,
 ];
 
 amlProgramCli
diff --git a/packages/taler-harness/src/integrationtests/test-kyc-decisions.ts 
b/packages/taler-harness/src/integrationtests/test-kyc-decisions.ts
index 2df591cb8..933d8f1c9 100644
--- a/packages/taler-harness/src/integrationtests/test-kyc-decisions.ts
+++ b/packages/taler-harness/src/integrationtests/test-kyc-decisions.ts
@@ -26,6 +26,7 @@ import {
   encodeCrock,
   hashNormalizedPaytoUri,
   j2s,
+  LimitOperationType,
   TalerProtocolTimestamp,
   TransactionMajorState,
   TransactionMinorState,
@@ -123,7 +124,7 @@ export async function runKycDecisionsTest(t: 
GlobalTestState) {
       // Strict rules for this particular merchant!
       rules: [
         {
-          operation_type: "DEPOSIT",
+          operation_type: LimitOperationType.deposit,
           display_priority: 1,
           exposed: true,
           measures: ["verboten"],
@@ -135,7 +136,7 @@ export async function runKycDecisionsTest(t: 
GlobalTestState) {
           ),
         },
         {
-          operation_type: "WITHDRAW",
+          operation_type: LimitOperationType.withdraw,
           display_priority: 1,
           exposed: true,
           measures: ["verboten"],
diff --git 
a/packages/taler-harness/src/integrationtests/test-kyc-new-measure.ts 
b/packages/taler-harness/src/integrationtests/test-kyc-new-measure.ts
index 117245315..808821107 100644
--- a/packages/taler-harness/src/integrationtests/test-kyc-new-measure.ts
+++ b/packages/taler-harness/src/integrationtests/test-kyc-new-measure.ts
@@ -209,7 +209,7 @@ export async function runKycNewMeasureTest(t: 
GlobalTestState) {
     amlPub: amlKeypair.pub,
     exchangeBaseUrl: exchange.baseUrl,
     paytoHash: kycPaytoHash,
-    newMeasure: "m3",
+    newMeasures: "m3",
     newRules: {
       expiration_time: TalerProtocolTimestamp.never(),
       custom_measures: {},
diff --git 
a/packages/taler-harness/src/integrationtests/test-kyc-skip-expiration.ts 
b/packages/taler-harness/src/integrationtests/test-kyc-new-measures-prog.ts
similarity index 89%
copy from 
packages/taler-harness/src/integrationtests/test-kyc-skip-expiration.ts
copy to 
packages/taler-harness/src/integrationtests/test-kyc-new-measures-prog.ts
index fda61396c..8cc4df4b3 100644
--- a/packages/taler-harness/src/integrationtests/test-kyc-skip-expiration.ts
+++ b/packages/taler-harness/src/integrationtests/test-kyc-new-measures-prog.ts
@@ -42,10 +42,12 @@ import {
 } from "../harness/environments.js";
 import { GlobalTestState, harnessHttpLib, waitMs } from 
"../harness/harness.js";
 
-export const AML_PROGRAM_FROM_ATTRIBUTES_TO_CONTEXT: 
TalerKycAml.AmlProgramDefinition =
+export const AML_PROGRAM_TEST_KYC_NEW_MEASURES_PROG: 
TalerKycAml.AmlProgramDefinition =
   {
-    name: "from-attr-to-context",
+    name: "test-kyc-new-measures-prog",
     logic: async (_input, config) => {
+      // Artificially delay the AML program.
+      await waitMs(500);
       const outcome: TalerKycAml.AmlOutcome = {
         to_investigate: false,
         // pushing to info into properties for testing purposes
@@ -55,11 +57,19 @@ export const AML_PROGRAM_FROM_ATTRIBUTES_TO_CONTEXT: 
TalerKycAml.AmlProgramDefin
           config,
         },
         events: [],
+        new_measures: "ask_more_info ask_basic_info",
         new_rules: {
-          expiration_time: TalerProtocolTimestamp.zero(),
+          expiration_time: TalerProtocolTimestamp.never(),
           rules: [],
-          successor_measure: "ask_more_info",
           custom_measures: {
+            ask_basic_info: {
+              context: {
+                // this is the context info that the KYC-SPA will see
+                infotype: "basic",
+              },
+              check_name: "C2",
+              prog_name: "P2",
+            },
             ask_more_info: {
               context: {
                 // this is the context info that the KYC-SPA will see
@@ -104,7 +114,7 @@ function adjustExchangeConfig(config: Configuration) {
   config.setString(
     "AML-PROGRAM-P1",
     "command",
-    "taler-harness aml-program run-program --name from-attr-to-context",
+    `taler-harness aml-program run-program --name 
${AML_PROGRAM_TEST_KYC_NEW_MEASURES_PROG.name}`,
   );
   config.setString("AML-PROGRAM-P1", "enabled", "true");
   config.setString("AML-PROGRAM-P1", "description", "remove all rules");
@@ -138,9 +148,10 @@ function adjustExchangeConfig(config: Configuration) {
 }
 
 /**
- * Test setting a `new_measure` as the AML officer.
+ * Test the usage of new_measures as the return
+ * value of an AML measure program.
  */
-export async function runKycSkipExpirationTest(t: GlobalTestState) {
+export async function runKycNewMeasuresProgTest(t: GlobalTestState) {
   // Set up test environment
 
   const { walletClient, bankClient, exchange, amlKeypair } =
@@ -219,7 +230,8 @@ export async function runKycSkipExpirationTest(t: 
GlobalTestState) {
       amlPub: amlKeypair.pub,
       exchangeBaseUrl: exchange.baseUrl,
       paytoHash: kycPaytoHash,
-      newMeasure: "M3",
+      // Immediately run M3
+      newMeasures: "M3",
       properties: {
         form: { name: "string" },
       },
@@ -285,6 +297,12 @@ export async function runKycSkipExpirationTest(t: 
GlobalTestState) {
       codecOptional(codecForKycProcessClientInformation()),
     );
 
+    if (clientInfo?.requirements.length == 0) {
+      console.log("requirements empty, waiting ...");
+      await waitMs(1000);
+      continue;
+    }
+
     console.log(j2s(clientInfo));
 
     // Finally here we must see the officer defined form
@@ -297,4 +315,4 @@ export async function runKycSkipExpirationTest(t: 
GlobalTestState) {
   }
 }
 
-runKycSkipExpirationTest.suites = ["wallet"];
+runKycNewMeasuresProgTest.suites = ["wallet"];
diff --git 
a/packages/taler-harness/src/integrationtests/test-kyc-skip-expiration.ts 
b/packages/taler-harness/src/integrationtests/test-kyc-skip-expiration.ts
index fda61396c..d1f63a0dc 100644
--- a/packages/taler-harness/src/integrationtests/test-kyc-skip-expiration.ts
+++ b/packages/taler-harness/src/integrationtests/test-kyc-skip-expiration.ts
@@ -46,6 +46,8 @@ export const AML_PROGRAM_FROM_ATTRIBUTES_TO_CONTEXT: 
TalerKycAml.AmlProgramDefin
   {
     name: "from-attr-to-context",
     logic: async (_input, config) => {
+      // Artificially delay the AML program.
+      await waitMs(500);
       const outcome: TalerKycAml.AmlOutcome = {
         to_investigate: false,
         // pushing to info into properties for testing purposes
@@ -137,9 +139,6 @@ function adjustExchangeConfig(config: Configuration) {
   config.setString("KYC-CHECK-C3", "fallback", "FREEZE");
 }
 
-/**
- * Test setting a `new_measure` as the AML officer.
- */
 export async function runKycSkipExpirationTest(t: GlobalTestState) {
   // Set up test environment
 
@@ -219,7 +218,7 @@ export async function runKycSkipExpirationTest(t: 
GlobalTestState) {
       amlPub: amlKeypair.pub,
       exchangeBaseUrl: exchange.baseUrl,
       paytoHash: kycPaytoHash,
-      newMeasure: "M3",
+      newMeasures: "M3",
       properties: {
         form: { name: "string" },
       },
diff --git 
a/packages/taler-harness/src/integrationtests/test-kyc-withdrawal-verboten.ts 
b/packages/taler-harness/src/integrationtests/test-kyc-withdrawal-verboten.ts
index df71c5f08..d11f6f139 100644
--- 
a/packages/taler-harness/src/integrationtests/test-kyc-withdrawal-verboten.ts
+++ 
b/packages/taler-harness/src/integrationtests/test-kyc-withdrawal-verboten.ts
@@ -19,6 +19,7 @@
  */
 import {
   Duration,
+  LimitOperationType,
   NotificationType,
   TalerProtocolTimestamp,
   TransactionMajorState,
@@ -186,7 +187,7 @@ export async function runKycWithdrawalVerbotenTest(t: 
GlobalTestState) {
       expiration_time: TalerProtocolTimestamp.never(),
       rules: [
         {
-          operation_type: "WITHDRAW",
+          operation_type: LimitOperationType.withdraw,
           display_priority: 1,
           measures: ["verboten"],
           threshold: "TESTKUDOS:0",
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts 
b/packages/taler-harness/src/integrationtests/testrunner.ts
index eea077935..75e2b7cdd 100644
--- a/packages/taler-harness/src/integrationtests/testrunner.ts
+++ b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -64,6 +64,7 @@ import { runKycMerchantActivateBankAccountTest } from 
"./test-kyc-merchant-activ
 import { runKycMerchantAggregateTest } from "./test-kyc-merchant-aggregate.js";
 import { runKycMerchantDepositTest } from "./test-kyc-merchant-deposit.js";
 import { runKycNewMeasureTest } from "./test-kyc-new-measure.js";
+import { runKycNewMeasuresProgTest } from "./test-kyc-new-measures-prog.js";
 import { runKycPeerPullTest } from "./test-kyc-peer-pull.js";
 import { runKycPeerPushTest } from "./test-kyc-peer-push.js";
 import { runKycSkipExpirationTest } from "./test-kyc-skip-expiration.js";
@@ -302,6 +303,7 @@ const allTests: TestMainFunction[] = [
   runWithdrawalCashacceptorTest,
   runWithdrawalConflictTest,
   runBankWopTest,
+  runKycNewMeasuresProgTest,
 ];
 
 export interface TestRunSpec {
diff --git a/packages/taler-util/src/types-taler-exchange.ts 
b/packages/taler-util/src/types-taler-exchange.ts
index ee3519655..c8d0c925a 100644
--- a/packages/taler-util/src/types-taler-exchange.ts
+++ b/packages/taler-util/src/types-taler-exchange.ts
@@ -1789,6 +1789,7 @@ export type LimitOperationType2 =
   | "REFUND"
   | "CLOSE"
   | "TRANSACTION";
+
 export enum LimitOperationType {
   withdraw = "WITHDRAW",
   deposit = "DEPOSIT",
@@ -1799,6 +1800,7 @@ export enum LimitOperationType {
   close = "CLOSE",
   transaction = "TRANSACTION",
 }
+
 export interface AccountLimit {
   // Operation that is limited.
   operation_type: LimitOperationType;
diff --git a/packages/taler-util/src/types-taler-kyc-aml.ts 
b/packages/taler-util/src/types-taler-kyc-aml.ts
index 11a8cf5a9..9c8f988cd 100644
--- a/packages/taler-util/src/types-taler-kyc-aml.ts
+++ b/packages/taler-util/src/types-taler-kyc-aml.ts
@@ -203,6 +203,16 @@ export interface AmlOutcome {
   // the successor measure to apply after the
   // expiration time.
   new_rules: LegitimizationRuleSet;
+
+  // Space-separated list of measures to trigger
+  // immediately on the account.
+  // Prefixed with a "+" to indicate that the
+  // measures should be ANDed.
+  // Should typically be used to give the user some
+  // information or request additional information.
+  //
+  // At most one measure with a SKIP check may be specified.
+  new_measures?: string;
 }
 
 // All fields in this object are optional. The actual

-- 
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]