[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] 02/02: merchant account: equal doesn't match the unique
From: |
gnunet |
Subject: |
[taler-merchant] 02/02: merchant account: equal doesn't match the unique constrain, so singleton fails |
Date: |
Thu, 20 Jun 2024 18:07:12 +0200 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository merchant.
commit 54bf557a46536e6e0590d66cfd1c3e68796447de
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Jun 20 13:07:04 2024 -0300
merchant account: equal doesn't match the unique constrain, so singleton
fails
---
src/backenddb/pg_select_account_by_uri.c | 3 +-
src/testing/test_merchant_accounts.sh | 73 ++++++++++++++++++++++++++++++++
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
@@ -111,6 +111,79 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
-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
+
+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"
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.