aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-06-20 13:07:04 -0300
committerSebastian <sebasjm@gmail.com>2024-06-20 13:07:04 -0300
commit54bf557a46536e6e0590d66cfd1c3e68796447de (patch)
tree95fe4e4916a379ecebf99af7057d327d8da77188
parent9c0c6c39e4a9c67502ba058cfaadcff7ff8f3e62 (diff)
merchant account: equal doesn't match the unique constrain, so singleton fails
-rw-r--r--src/backenddb/pg_select_account_by_uri.c3
-rwxr-xr-xsrc/testing/test_merchant_accounts.sh73
2 files changed, 74 insertions, 2 deletions
diff --git a/src/backenddb/pg_select_account_by_uri.c b/src/backenddb/pg_select_account_by_uri.c
index fd05793f..fafae088 100644
--- a/src/backenddb/pg_select_account_by_uri.c
+++ b/src/backenddb/pg_select_account_by_uri.c
@@ -73,8 +73,7 @@ TMH_PG_select_account_by_uri (void *cls,
" (SELECT merchant_serial "
" FROM merchant_instances"
" WHERE merchant_id=$1)"
- " AND REGEXP_REPLACE(payto_uri,'\\?.*','')"
- " =REGEXP_REPLACE($2,'\\?.*','')");
+ " AND payto_uri = $2");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"select_account_by_uri",
params,
diff --git a/src/testing/test_merchant_accounts.sh b/src/testing/test_merchant_accounts.sh
index df9a80ad..9672b5e6 100755
--- a/src/testing/test_merchant_accounts.sh
+++ b/src/testing/test_merchant_accounts.sh
@@ -128,5 +128,78 @@ then
exit_fail "Expected account active."
fi
+echo "OK" >&2
+
+echo -n "creating same account with different name ..." >&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/43?receiver-name=not-user-43"}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
+
+
+if [ "$STATUS" != "200" ]
+then
+ exit_fail "Expected 200 OK. Got: $STATUS"
+fi
+
+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")
+
+ACTIVE=$(jq -r .active $LAST_RESPONSE)
+
+if [ "$ACTIVE" != "true" ]
+then
+ exit_fail "Expected account active."
+fi
+
+echo "OK" >&2
+
+echo -n "deleting the 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 "now make it active again ..." >&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/43?receiver-name=not-user-43"}' \
+ -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
+
echo " OK" >&2