diff options
author | Sebastian <sebasjm@gmail.com> | 2024-06-20 13:17:02 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-06-20 13:17:02 -0300 |
commit | 66c45f6c7dcfc0abb0bd144cacd87f6e9104971c (patch) | |
tree | 4d31a6c37af39c09b6a418c79fd3e01518f9e4a6 | |
parent | 54bf557a46536e6e0590d66cfd1c3e68796447de (diff) |
more comments and test
-rwxr-xr-x | src/testing/test_merchant_accounts.sh | 120 |
1 files changed, 119 insertions, 1 deletions
diff --git a/src/testing/test_merchant_accounts.sh b/src/testing/test_merchant_accounts.sh index 9672b5e6..4ae1f07f 100755 --- a/src/testing/test_merchant_accounts.sh +++ b/src/testing/test_merchant_accounts.sh @@ -51,6 +51,11 @@ fi echo "OK" >&2 +## +# Test deleting and creating the account again. +# it should bring the account active again +## + echo -n "creating first account ..." >&2 STATUS=$(curl -H "Content-Type: application/json" -X POST \ @@ -103,7 +108,6 @@ echo "OK" >&2 echo -n "creating same account again to make it active ..." >&2 - STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:new_value' \ http://localhost:9966/private/accounts \ @@ -130,6 +134,10 @@ fi echo "OK" >&2 +## +# Using different name should not conflict with previous account. +## + echo -n "creating same account with different name ..." >&2 STATUS=$(curl -H "Content-Type: application/json" -X POST \ @@ -203,3 +211,113 @@ fi echo " OK" >&2 + +## +# Activating the account again with different values should not break. +## + +echo -n "creating second account ..." >&2 + +STATUS=$(curl -H "Content-Type: application/json" -X POST \ + -H 'Authorization: Bearer secret-token:new_value' \ + http://localhost:9966/private/accounts \ + -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/12?receiver-name=user12"}' \ + -w "%{http_code}" -s -o "$LAST_RESPONSE") + + +if [ "$STATUS" != "200" ] +then + exit_fail "Expected 200 OK. Got: $STATUS" +fi + +echo "OK" >&2 + + +ACCOUNT_ID=$(jq -r .h_wire $LAST_RESPONSE) + +STATUS=$(curl -H "Content-Type: application/json" -X GET \ + -H 'Authorization: Bearer secret-token:new_value' \ + http://localhost:9966/private/accounts/$ACCOUNT_ID \ + -w "%{http_code}" -s -o "$LAST_RESPONSE") + +if [ "$STATUS" != "200" ] +then + exit_fail "Expected 200 OK. Got: $STATUS" +fi + +ACTIVE=$(jq -r .active $LAST_RESPONSE) + +if [ "$ACTIVE" != "true" ] +then + exit_fail "Expected account active." +fi + +echo -n "deleting second account ..." >&2 + +STATUS=$(curl -H "Content-Type: application/json" -X DELETE \ + -H 'Authorization: Bearer secret-token:new_value' \ + http://localhost:9966/private/accounts/$ACCOUNT_ID \ + -w "%{http_code}" -s ) + +if [ "$STATUS" != "204" ] +then + exit_fail "Expected 204 OK. Got: $STATUS" +fi + +echo "OK" >&2 + +echo -n "make it active with different facade ..." >&2 + +STATUS=$(curl -H "Content-Type: application/json" -X POST \ + -H 'Authorization: Bearer secret-token:new_value' \ + http://localhost:9966/private/accounts \ + -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/12?receiver-name=user12", "credit_facade_credentials":{"type":"none"},"credit_facade_url":"http://asd.com/"}' \ + -w "%{http_code}" -s -o "$LAST_RESPONSE") + + +if [ "$STATUS" != "200" ] +then + exit_fail "Expected 200 OK. Got: $STATUS" +fi + +STATUS=$(curl -H "Content-Type: application/json" -X GET \ + -H 'Authorization: Bearer secret-token:new_value' \ + http://localhost:9966/private/accounts/$ACCOUNT_ID \ + -w "%{http_code}" -s -o "$LAST_RESPONSE") + +ACTIVE=$(jq -r .active $LAST_RESPONSE) + +if [ "$ACTIVE" != "true" ] +then + exit_fail "Expected account active." +fi + +FACADE=$(jq -r .credit_facade_url $LAST_RESPONSE) + +if [ "$FACADE" != "http://asd.com/" ] +then + exit_fail "Expected account with facade http://asd.com/." +fi + +echo "OK" >&2 + +## +# Still, the previous activation should only work if the account is deactivated, the same as if the account was deleted. +# Trying to create when there is already an active account but with different values should return Conflict 409. +## + +echo -n "should validate conflict ..." >&2 + +STATUS=$(curl -H "Content-Type: application/json" -X POST \ + -H 'Authorization: Bearer secret-token:new_value' \ + http://localhost:9966/private/accounts \ + -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/12?receiver-name=user12", "credit_facade_credentials":{"type":"none"},"credit_facade_url":"http://invalid.com/"}' \ + -w "%{http_code}" -s -o "$LAST_RESPONSE") + + +if [ "$STATUS" != "409" ] +then + exit_fail "Expected 409 Conflict. Got: $STATUS" +fi + +echo "OK" >&2 |