(feat) balance
This commit is contained in:
parent
779ae4d498
commit
aeb9514aa3
15 changed files with 461 additions and 26 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Save as test_multiberry.sh
|
||||
# Extended comprehensive test with DB verification
|
||||
|
||||
BASE_URL="http://localhost:3000/api"
|
||||
|
||||
|
|
@ -8,7 +9,7 @@ echo "1️⃣ REGISTER USER"
|
|||
echo "=========================================="
|
||||
REGISTER=$(curl -s -X POST $BASE_URL/auth/register \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"bank_user_number": 8, "password": "testpass123"}')
|
||||
-d '{"bank_user_number": 1, "password": "testpass123"}')
|
||||
|
||||
echo "$REGISTER" | jq .
|
||||
TOKEN=$(echo "$REGISTER" | jq -r '.token')
|
||||
|
|
@ -21,11 +22,9 @@ echo ""
|
|||
echo "=========================================="
|
||||
echo "2️⃣ LOGIN (verify token works)"
|
||||
echo "=========================================="
|
||||
LOGIN=$(curl -s -X POST $BASE_URL/auth/login \
|
||||
curl -s -X POST $BASE_URL/auth/login \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{\"bank_user_id\": \"$BANK_USER_ID\", \"password\": \"testpass123\"}")
|
||||
|
||||
echo "$LOGIN" | jq .
|
||||
-d "{\"bank_user_id\": \"$BANK_USER_ID\", \"password\": \"testpass123\"}" | jq .
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
|
|
@ -58,17 +57,25 @@ echo "✅ Account ID: $ACCOUNT_ID"
|
|||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "6️⃣ GET BALANCES"
|
||||
echo "6️⃣ GET BALANCES (auto-saved to DB)"
|
||||
echo "=========================================="
|
||||
curl -s $BASE_URL/balances/vbank/$BANK_USER_ID \
|
||||
-H "Authorization: Bearer $TOKEN" | jq .
|
||||
BALANCES=$(curl -s $BASE_URL/balances/vbank/$ACCOUNT_ID \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
|
||||
echo "$BALANCES" | jq .
|
||||
BALANCE_AMOUNT=$(echo "$BALANCES" | jq -r '.data.balance[0].amount.amount')
|
||||
echo "✅ Current Balance: $BALANCE_AMOUNT RUB"
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "7️⃣ GET TRANSACTIONS (page 1, limit 6)"
|
||||
echo "7️⃣ GET TRANSACTIONS (page 1, limit 6 - auto-saved)"
|
||||
echo "=========================================="
|
||||
curl -s "$BASE_URL/transactions/vbank/$BANK_USER_ID/$ACCOUNT_ID?page=1&limit=6" \
|
||||
-H "Authorization: Bearer $TOKEN" | jq .
|
||||
TRANS_PAGE1=$(curl -s "$BASE_URL/transactions/vbank/$BANK_USER_ID/$ACCOUNT_ID?page=1&limit=6" \
|
||||
-H "Authorization: Bearer $TOKEN")
|
||||
|
||||
echo "$TRANS_PAGE1" | jq .
|
||||
TOTAL_RECORDS=$(echo "$TRANS_PAGE1" | jq -r '.meta.totalRecords')
|
||||
echo "✅ Total Records: $TOTAL_RECORDS"
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
|
|
@ -86,11 +93,42 @@ curl -s -X DELETE $BASE_URL/consent/vbank/$BANK_USER_ID \
|
|||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "🔟 VERIFY DB (from another terminal)"
|
||||
echo "🔟 VERIFY DATABASE CACHE"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Run in another terminal:"
|
||||
echo "just psql-exec"
|
||||
echo "SELECT * FROM users;"
|
||||
echo "SELECT * FROM user_consents;"
|
||||
echo "SELECT * FROM accounts;"
|
||||
echo "SELECT * FROM transactions;"
|
||||
echo ""
|
||||
echo "Then execute these queries:"
|
||||
echo ""
|
||||
echo "-- Check users registered:"
|
||||
echo "SELECT bank_user_id, created_at FROM users ORDER BY created_at DESC LIMIT 5;"
|
||||
echo ""
|
||||
echo "-- Check consents granted:"
|
||||
echo "SELECT user_id, bank_code, consent_id, status, expires_at FROM user_consents;"
|
||||
echo ""
|
||||
echo "-- Check accounts cached:"
|
||||
echo "SELECT account_id, user_id, bank_code, nickname, currency FROM accounts;"
|
||||
echo ""
|
||||
echo "-- Check balances cached:"
|
||||
echo "SELECT account_id, balance_type, amount, currency, date_time FROM balances;"
|
||||
echo ""
|
||||
echo "-- Check transactions cached (show count by account):"
|
||||
echo "SELECT account_id, COUNT(*) as tx_count, MIN(booking_date_time) as oldest, MAX(booking_date_time) as newest FROM transactions GROUP BY account_id;"
|
||||
echo ""
|
||||
echo "-- Show recent transactions:"
|
||||
echo "SELECT transaction_id, account_id, amount, currency, credit_debit_indicator, transaction_information, booking_date_time FROM transactions ORDER BY booking_date_time DESC LIMIT 10;"
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "✅ FULL TEST COMPLETE!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Summary:"
|
||||
echo "✅ Authentication (register/login/auth middleware)"
|
||||
echo "✅ Consent Management (request consent)"
|
||||
echo "✅ Account Aggregation (fetch & cache accounts)"
|
||||
echo "✅ Balance Retrieval (fetch & cache balances)"
|
||||
echo "✅ Transaction History (fetch & cache transactions)"
|
||||
echo "✅ Data Persistence (all cached in PostgreSQL)"
|
||||
echo ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue