taler-exchange-helper-measure-test-forms (3312B)
1 #!/bin/bash 2 # 3 # This file is part of TALER 4 # Copyright (C) 2026 Taler Systems SA 5 # 6 # TALER is free software; you can redistribute it and/or modify it under the 7 # terms of the GNU General Public License as published by the Free Software 8 # Foundation; either version 3, or (at your option) any later version. 9 # 10 # TALER is distributed in the hope that it will be useful, but WITHOUT ANY 11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License along with 15 # TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/license> 16 # 17 18 # Hard error reporting on. 19 set -eu 20 21 # Exit, with error message (hard failure) 22 function exit_fail() { 23 echo " FAIL: " "$@" >&2 24 EXIT_STATUS=1 25 exit "$EXIT_STATUS" 26 } 27 28 CONF="$HOME/.config/taler-exchange.conf" 29 VERBOSE=0 30 31 while getopts 'ac:hirvV' OPTION; 32 do 33 case "$OPTION" in 34 a) 35 # This AML program expects the following inputs 36 echo "FULL_NAME" 37 echo "DATE_OF_BIRTH" 38 exit 0 39 ;; 40 c) 41 # shellcheck disable=SC2034 42 CONF="$OPTARG" 43 ;; 44 h) 45 echo "This is a KYC measure program for tests. It checks that the attribute sets a KYC process returned for its forms test-forms-primary and test-forms-second reached it: the primary set as the current attributes, both in the KYC history in their order. Then it does what taler-exchange-helper-measure-test-oauth does." 46 echo 'Supported options:' 47 echo ' -a -- show required attributes' 48 # shellcheck disable=SC2016 49 echo ' -c $CONF -- set configuration' 50 echo ' -h -- print this help' 51 echo ' -i -- show required inputs' 52 echo ' -r -- show required context' 53 echo ' -v -- show version' 54 echo ' -V -- be verbose' 55 exit 0 56 ;; 57 i) 58 echo "attributes" 59 echo "kyc_history" 60 exit 0 61 ;; 62 r) 63 # No context is required. 64 exit 0 65 ;; 66 v) 67 echo "$0 v0.0.0" 68 exit 0 69 ;; 70 V) 71 VERBOSE=1 72 ;; 73 ?) 74 exit_fail "Unrecognized command line option" 75 ;; 76 esac 77 done 78 79 if [ 1 = "$VERBOSE" ] 80 then 81 echo "Running $0" 1>&2 82 fi 83 84 # See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlProgramInput 85 # for the full JSON with possible inputs. 86 INPUT=$(cat) 87 88 # The current attributes are the primary set ... 89 echo "$INPUT" \ 90 | jq -e '.attributes.FORM_ID == "test-forms-primary"' > /dev/null \ 91 || exit_fail "the current attributes are not the primary set" 92 # ... and the KYC history, newest first, lists the sets of the process 93 # in the order the provider returned them. 94 echo "$INPUT" \ 95 | jq -e '[.kyc_history[0:2][].attributes.FORM_ID] 96 == ["test-forms-primary", "test-forms-second"]' > /dev/null \ 97 || exit_fail "the KYC history lacks the sets of the process in their order" 98 99 echo "$INPUT" | exec taler-exchange-helper-measure-test-oauth -c "$CONF"