commit cebac2a50cd319c670b51eeddb7787ecb5459a00
parent f1c492db84cd60c40cab79f55d0d6c592c7d0cae
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 23 Mar 2026 20:04:14 +0100
add minimal test for /kycauth endpoint
Diffstat:
2 files changed, 93 insertions(+), 40 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_dispatcher.c b/src/backend/taler-merchant-httpd_dispatcher.c
@@ -813,7 +813,7 @@ determine_handler_group (const char **urlp,
.method = MHD_HTTP_METHOD_POST,
.have_id_segment = true,
.permission = "accounts-read",
- .handler = &TMH_private_post_account,
+ .handler = &TMH_private_post_accounts_H_WIRE_kycauth,
/* allow exchange URL up to 4 kb, that should be plenty */
.max_upload = 1024 * 4
},
diff --git a/src/testing/test_merchant_kyc.sh b/src/testing/test_merchant_kyc.sh
@@ -31,11 +31,14 @@ LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX)
echo -n "Configuring a merchant admin instance ..."
-STATUS=$(curl -H "Content-Type: application/json" -X POST \
- -H 'Authorization: Bearer secret-token:super_secret' \
- http://localhost:9966/management/instances \
- -d '{"auth":{"method":"external"},"id":"admin","name":"default","user_type":"business","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
- -w "%{http_code}" -s -o /dev/null)
+STATUS=$(curl -H "Content-Type: application/json" \
+ -X POST \
+ -H 'Authorization: Bearer secret-token:super_secret' \
+ http://localhost:9966/management/instances \
+ -d '{"auth":{"method":"external"},"id":"admin","name":"default","user_type":"business","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
+ -w "%{http_code}" \
+ -s \
+ -o /dev/null)
if [ "$STATUS" != "204" ]
then
@@ -46,12 +49,14 @@ echo " OK"
echo -n "Creating account ..."
-STATUS=$(curl -H "Content-Type: application/json" -X POST \
- -H 'Authorization: Bearer secret-token:super_secret' \
- http://localhost:9966/private/accounts \
- -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/43?receiver-name=user43"}' \
- -w "%{http_code}" -s -o /dev/null)
-
+STATUS=$(curl -H "Content-Type: application/json" \
+ -X POST \
+ -H 'Authorization: Bearer secret-token:super_secret' \
+ http://localhost:9966/private/accounts \
+ -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/43?receiver-name=user43"}' \
+ -w "%{http_code}" \
+ -s \
+ -o /dev/null)
if [ "$STATUS" != "200" ]
then
@@ -62,12 +67,14 @@ echo " OK"
echo -n "Creating conflicting account with different receiver name ..."
-STATUS=$(curl -H "Content-Type: application/json" -X POST \
- -H 'Authorization: Bearer secret-token:super_secret' \
- http://localhost:9966/private/accounts \
- -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/43?receiver-name=user44"}' \
- -w "%{http_code}" -s -o /dev/null)
-
+STATUS=$(curl -H "Content-Type: application/json" \
+ -X POST \
+ -H 'Authorization: Bearer secret-token:super_secret' \
+ http://localhost:9966/private/accounts \
+ -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/43?receiver-name=user44"}' \
+ -w "%{http_code}" \
+ -s \
+ -o /dev/null)
if [ "$STATUS" != "409" ]
then
@@ -78,12 +85,14 @@ echo " OK"
echo -n "Creating a second account ..."
-STATUS=$(curl -H "Content-Type: application/json" -X POST \
- -H 'Authorization: Bearer secret-token:super_secret' \
- http://localhost:9966/private/accounts \
- -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/44?receiver-name=user44"}' \
- -w "%{http_code}" -s -o /dev/null)
-
+STATUS=$(curl -H "Content-Type: application/json" \
+ -X POST \
+ -H 'Authorization: Bearer secret-token:super_secret' \
+ http://localhost:9966/private/accounts \
+ -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/44?receiver-name=user44"}' \
+ -w "%{http_code}" \
+ -s \
+ -o /dev/null)
if [ "$STATUS" != "200" ]
then
@@ -94,9 +103,12 @@ echo " OK"
echo -n "Check the instance exists ..."
-STATUS=$(curl -H "Content-Type: application/json" -X GET \
- http://localhost:9966/private/ \
- -w "%{http_code}" -s -o /dev/null)
+STATUS=$(curl -H "Content-Type: application/json" \
+ -X GET \
+ http://localhost:9966/private/ \
+ -w "%{http_code}" \
+ -s \
+ -o /dev/null)
if [ "$STATUS" != "200" ]
then
@@ -113,8 +125,10 @@ RANDOM_IMG='data:image/png;base64,abcdefg'
echo -n "Creating order without TOKEN..."
STATUS=$(curl 'http://localhost:9966/private/orders' \
- -d '{"create_token":false,"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'"$RANDOM_IMG"'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
- -w "%{http_code}" -s -o "$LAST_RESPONSE")
+ -d '{"create_token":false,"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'"$RANDOM_IMG"'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
+ -w "%{http_code}" \
+ -s \
+ -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
@@ -136,7 +150,9 @@ echo "OK"
echo -n "Checking created order without TOKEN..."
STATUS=$(curl http://localhost:9966/orders/$ORDER_ID \
- -w "%{http_code}" -s -o "$LAST_RESPONSE")
+ -w "%{http_code}" \
+ -s \
+ -o "$LAST_RESPONSE")
PAY_URI=$(jq -r .taler_pay_uri < "$LAST_RESPONSE")
@@ -150,22 +166,28 @@ echo "OK"
echo -n "Getting information about KYC ..."
-STATUS=$(curl -H "Accept: application/json" -X GET \
- http://localhost:9966/private/kyc \
- -w "%{http_code}" -s -o "$LAST_RESPONSE")
+STATUS=$(curl -H "Accept: application/json" \
+ -X GET \
+ http://localhost:9966/private/kyc \
+ -w "%{http_code}" \
+ -s \
+ -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
exit_fail "Expected 200. got: $STATUS"
fi
-
+H_WIRE=$(jq -r .kyc_data[0].h_wire < "$LAST_RESPONSE")
echo " OK"
echo -n "Getting information about KYC in plaintext ..."
-STATUS=$(curl -H "Accept: text/plain" -X GET \
- http://localhost:9966/private/kyc \
- -w "%{http_code}" -s -o "$LAST_RESPONSE")
+STATUS=$(curl -H "Accept: text/plain" \
+ -X GET \
+ http://localhost:9966/private/kyc \
+ -w "%{http_code}" \
+ -s \
+ -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
@@ -177,17 +199,48 @@ echo " OK"
echo -n "Getting exchange status information ..."
-STATUS=$(curl -H "Accept: application/json" -X GET \
- http://localhost:9966/exchanges \
- -w "%{http_code}" -s -o "$LAST_RESPONSE")
+STATUS=$(curl -H "Accept: application/json" \
+ -X GET \
+ http://localhost:9966/exchanges \
+ -w "%{http_code}" \
+ -s \
+ -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
jq < "$LAST_RESPONSE"
exit_fail "Expected 200. got: $STATUS"
fi
+echo " OK"
+
+echo -n "Requesting KYC wire transfer instructions ..."
+
+STATUS=$(curl -H "Accept: application/json" \
+ -X POST \
+ "http://localhost:9966/private/accounts/$H_WIRE/kycauth" \
+ -d '{"exchange_url":"http://localhost:8081/"}' \
+ -w "%{http_code}" \
+ -s \
+ -o "$LAST_RESPONSE")
+
+if [ "$STATUS" != "200" ]
+then
+ jq < "$LAST_RESPONSE"
+ exit_fail "Expected 200. got: $STATUS"
+fi
+
+WI_TYPE=$(jq -r .wire_instructions[0].subject.type < "$LAST_RESPONSE")
+
+if [ "$WI_TYPE" != "SIMPLE" ]
+then
+ jq < "$LAST_RESPONSE"
+ exit_fail "Type should be SIMPLE, got: $WI_TYPE"
+fi
echo " OK"
+
+
+
echo "TEST PASSED"
exit 0