aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-08-04 12:51:36 +0200
committerChristian Grothoff <christian@grothoff.org>2024-08-04 12:51:36 +0200
commit94da34ede8fb25c5d23829bd290de27d94c9971d (patch)
tree7e9b79412a0820f8823621fe63ac7696a132da02
parenta462d86ee8edfa8c3dd770b3cfded6562de5a520 (diff)
more clear naming of variables
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-info.c14
-rwxr-xr-xsrc/kyclogic/taler-exchange-helper-measure-test-form122
2 files changed, 129 insertions, 7 deletions
diff --git a/src/exchange/taler-exchange-httpd_kyc-info.c b/src/exchange/taler-exchange-httpd_kyc-info.c
index 1d9804d30..768703690 100644
--- a/src/exchange/taler-exchange-httpd_kyc-info.c
+++ b/src/exchange/taler-exchange-httpd_kyc-info.c
@@ -180,13 +180,13 @@ db_event_cb (void *cls,
* the LegitimizationMeasures.
*
* @param[in,out] kyp request to reply on
- * @param row_id etag to set for the response
+ * @param legitimization_measure_row_id etag to set for the response
* @param jmeasures measures to encode
* @return MHD status code
*/
static MHD_RESULT
generate_reply (struct KycPoller *kyp,
- uint64_t row_id,
+ uint64_t legitimization_measure_row_id,
const json_t *jmeasures)
{
const json_t *measures;
@@ -255,7 +255,7 @@ generate_reply (struct KycPoller *kyp,
prog_name,
&kyp->access_token,
i,
- row_id);
+ legitimization_measure_row_id);
if (NULL == kri)
{
GNUNET_break (0);
@@ -278,7 +278,7 @@ generate_reply (struct KycPoller *kyp,
GNUNET_snprintf (etags,
sizeof (etags),
"%llu",
- (unsigned long long) row_id);
+ (unsigned long long) legitimization_measure_row_id);
resp = TALER_MHD_MAKE_JSON_PACK (
GNUNET_JSON_pack_array_steal ("requirements",
kris),
@@ -310,7 +310,7 @@ TEH_handler_kyc_info (
struct KycPoller *kyp = rc->rh_ctx;
MHD_RESULT res;
enum GNUNET_DB_QueryStatus qs;
- uint64_t last_row;
+ uint64_t legitimization_measure_last_row;
json_t *jmeasures;
if (NULL == kyp)
@@ -402,7 +402,7 @@ TEH_handler_kyc_info (
qs = TEH_plugin->lookup_kyc_status_by_token (
TEH_plugin->cls,
&kyp->access_token,
- &last_row,
+ &legitimization_measure_last_row,
&jmeasures);
if (qs < 0)
{
@@ -443,7 +443,7 @@ TEH_handler_kyc_info (
}
res = generate_reply (kyp,
- last_row,
+ legitimization_measure_last_row,
jmeasures);
json_decref (jmeasures);
return res;
diff --git a/src/kyclogic/taler-exchange-helper-measure-test-form b/src/kyclogic/taler-exchange-helper-measure-test-form
new file mode 100755
index 000000000..d231e6244
--- /dev/null
+++ b/src/kyclogic/taler-exchange-helper-measure-test-form
@@ -0,0 +1,122 @@
+#!/bin/bash
+#
+# This file is part of TALER
+# Copyright (C) 2014-2024 Taler Systems SA
+#
+# TALER is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3, or (at your option) any later version.
+#
+# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/license>
+#
+
+# Hard error reporting on.
+set -eu
+
+echo "Running $0" 1>&2
+
+# This is a KYC measure program that checks the output
+# of a simple FORM submission, and if it passed,
+# increases all limits to EUR:1000.
+# (and doesn't impose any other limits)
+
+if [ "${1:-no}" = "--required-context" ]
+then
+ # No context is required.
+ exit 0
+fi
+
+if [ "${1:-no}" = "--required-attributes" ]
+then
+ # This AML program expects as inputs a full_name
+ # and a birthdate.
+ echo "full_name"
+ echo "birthdate"
+ exit 0
+fi
+
+# First, check everything we expect is in stdin.
+A=$(jq -r .attributes)
+J=$(echo $A | jq -r 'def get($k):
+ if has($k)
+ then .[$k]
+ else error("attribute missing")
+ end;
+ {"full_name":get("full_name"),
+ "birthdate":get("birthdate")}')
+
+# Here we could use those values...
+echo "$J" >> /dev/null
+
+# See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlProgramInput
+# for the full JSON with possible inputs.
+
+# New rules apply for 30 days.
+EXPIRATION=$((3600 * 30 + $(date +%s)))
+
+# Finally, output the new rules.
+# See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlOutcome
+# for the required output format.
+
+jq -n \
+ --argjson expiration "$EXPIRATION" \
+ '{ "to_investigate": false,
+ "new_rules" : {
+ "new_check" : "info-oauth-test-passed",
+ "expiration_time" : { "t_s": $expiration },
+ "rules" : [
+ {
+ "operation_type": "WITHDRAW",
+ "threshold" : "EUR:1000",
+ "timeframe" : { "d_us" : 3600000000 },
+ "measures" : [ "verboten" ],
+ "display_priority" : 1,
+ "exposed" : true,
+ "is_and_combinator" : true
+ },
+ {
+ "operation_type": "DEPOSIT",
+ "threshold" : "EUR:1000",
+ "timeframe" : { "d_us" : 3600000000 },
+ "measures" : [ "verboten" ],
+ "display_priority" : 1,
+ "exposed" : true,
+ "is_and_combinator" : true
+ },
+ {
+ "operation_type": "MERGE",
+ "threshold" : "EUR:1000",
+ "timeframe" : { "d_us" : 3600000000 },
+ "measures" : [ "verboten" ],
+ "display_priority" : 1,
+ "exposed" : true,
+ "is_and_combinator" : true
+ },
+ {
+ "operation_type": "BALANCE",
+ "threshold" : "EUR:1000",
+ "timeframe" : { "d_us" : 3600000000 },
+ "measures" : [ "verboten" ],
+ "display_priority" : 1,
+ "exposed" : true,
+ "is_and_combinator" : true
+ },
+ {
+ "operation_type": "CLOSE",
+ "threshold" : "EUR:1000",
+ "timeframe" : { "d_us" : 3600000000 },
+ "measures" : [ "verboten" ],
+ "display_priority" : 1,
+ "exposed" : true,
+ "is_and_combinator" : true
+ }
+ ]
+ }
+ }' < /dev/null
+
+exit 0