From 7d425da40e2500456caab083518b889921945356 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 16 Apr 2021 15:32:15 +0200 Subject: add test foer #6836 --- src/testing/test_key_rotation.sh | 111 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 8 deletions(-) (limited to 'src/testing/test_key_rotation.sh') diff --git a/src/testing/test_key_rotation.sh b/src/testing/test_key_rotation.sh index ad5d4ae4..05d1eb83 100755 --- a/src/testing/test_key_rotation.sh +++ b/src/testing/test_key_rotation.sh @@ -1,5 +1,12 @@ #!/bin/bash # This file is in the public domain. +# +# Note that this test is intentionally NOT run as part of the standard test +# suite, because it is awfully slow (due to necessary 'wait' operations) and +# may even hang on slower computers (with the wallet trying to withdraw and +# failing because all keys have expired) due to the relatively short timeouts +# involved. +# ## Coloring style Text shell script COLOR='\033[0;35m' NOCOLOR='\033[0m' @@ -195,6 +202,18 @@ ORDER_2=`curl -s -H "Content-Type: application/json" -X POST \ | jq -er '.order_id'` PAY2=taler+http://pay/localhost:9966/${ORDER_2}/ +ORDER_3=`curl -s -H "Content-Type: application/json" -X POST \ + http://localhost:9966/private/orders \ + -d '{"create_token":false, "order":{"amount":"TESTKUDOS:0.01","summary":"Minimal test order #3"}}' \ + | jq -er '.order_id'` +PAY3=taler+http://pay/localhost:9966/${ORDER_3}/ + +ORDER_4=`curl -s -H "Content-Type: application/json" -X POST \ + http://localhost:9966/private/orders \ + -d '{"create_token":false, "order":{"amount":"TESTKUDOS:0.01","summary":"Minimal test order #4"}}' \ + | jq -er '.order_id'` +PAY4=taler+http://pay/localhost:9966/${ORDER_4}/ + if [ "$STATUS" != "204" ] then @@ -212,7 +231,7 @@ export EXCHANGE_URL export WALLET_DB echo -n "Setting up keys ..." -taler-exchange-offline -c $CONF \ +taler-exchange-offline -L INFO -c $CONF \ download \ sign \ enable-account payto://x-taler-bank/localhost/Exchange \ @@ -240,7 +259,7 @@ fi echo " OK" echo -n "Setting up auditor signatures ..." -taler-auditor-offline -c $CONF \ +taler-auditor-offline -L INFO -c $CONF \ download sign upload &> taler-auditor-offline.log echo " OK" @@ -265,16 +284,17 @@ echo -n "Pay first order ..." taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri ${PAY1} -y 2> wallet-pay1.err > wallet-pay1.log echo " OK" -echo -n "Wait for old keys to definitively expire..." -sleep 60 +echo -n "Wait for keys to rotate, but not ALL to expire..." +sleep 20 echo " OK" + echo -n "Updating keys ..." -taler-exchange-offline -c $CONF \ +taler-exchange-offline -L INFO -c $CONF \ download \ sign \ upload &> taler-exchange-offline-2.log -taler-auditor-offline -c $CONF \ +taler-auditor-offline -L INFO -c $CONF \ download sign upload &> taler-auditor-offline-2.log echo " OK" @@ -289,8 +309,8 @@ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'withdrawTestBalance' }' \ --arg BANK_URL "$BANK_URL" \ --arg EXCHANGE_URL "$EXCHANGE_URL" - )" 2> /dev/null >/dev/null -taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>/dev/null >/dev/null + )" 2>wallet-withdraw-2.err >wallet-withdraw-2.out +taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet-withdraw-finish-2.err >wallet-withdraw-finish-2.out echo " OK" echo -n "Pay second order ..." @@ -298,6 +318,81 @@ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri ${PAY2} -y 2> w echo " OK" +echo -n "Wait for keys to rotate, and original ones to expire..." +sleep 60 +echo " OK" + +date +echo -n "Updating keys ..." +taler-exchange-offline -c $CONF \ + download > taler-exchange-offline-download-3.log +taler-exchange-offline -c $CONF \ + download sign > taler-exchange-offline-sign-3.log +taler-exchange-offline -L INFO -c $CONF \ + download \ + sign \ + upload &> taler-exchange-offline-3.log +taler-auditor-offline -L INFO -c $CONF \ + download sign upload &> taler-auditor-offline-3.log +echo " OK" + +echo -n "Third withdraw wallet" +rm $WALLET_DB +taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'withdrawTestBalance' \ + "$(jq -n ' + { + amount: "TESTKUDOS:1", + bankBaseUrl: $BANK_URL, + exchangeBaseUrl: $EXCHANGE_URL + }' \ + --arg BANK_URL "$BANK_URL" \ + --arg EXCHANGE_URL "$EXCHANGE_URL" + )" 2>wallet-withdraw-3.err >wallet-withdraw-3.out + +echo " OK" +date +echo -n "Waiting for wallet to finish ..." +taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet-withdraw-finish-3.err >wallet-withdraw-finish-3.out +echo " OK" + +echo -n "Pay third order ..." +taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri ${PAY3} -y 2> wallet-pay3.err > wallet-pay3.log +echo " OK" + + +echo -n "Wait for everything to expire..." +sleep 120 +echo " OK" + +echo -n "Updating keys ..." +taler-exchange-offline -L INFO -c $CONF \ + download \ + sign \ + upload &> taler-exchange-offline-4.log +taler-auditor-offline -L INFO -c $CONF \ + download sign upload &> taler-auditor-offline-4.log +echo " OK" + +echo -n "Fourth withdraw wallet" +rm $WALLET_DB +taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'withdrawTestBalance' \ + "$(jq -n ' + { + amount: "TESTKUDOS:1", + bankBaseUrl: $BANK_URL, + exchangeBaseUrl: $EXCHANGE_URL + }' \ + --arg BANK_URL "$BANK_URL" \ + --arg EXCHANGE_URL "$EXCHANGE_URL" + )" 2>wallet-withdraw-4.err >wallet-withdraw-4.out +taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet-withdraw-finish-4.err >wallet-withdraw-finish-4.out +echo " OK" + +echo -n "Pay fourth order ..." +taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri ${PAY4} -y 2> wallet-pay4.err > wallet-pay4.log +echo " OK" + + exit 0 -- cgit v1.2.3