-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-webhook.sh
More file actions
executable file
·59 lines (49 loc) · 1.63 KB
/
Copy pathtest-webhook.sh
File metadata and controls
executable file
·59 lines (49 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Test script for webhook system
# This demonstrates how to register and manage webhooks
BASE_URL="http://localhost:5000/api"
echo "=== USV Token Webhook System Test ==="
echo ""
# Test 1: Register a webhook
echo "1. Registering webhook..."
WEBHOOK_RESPONSE=$(curl -s -X POST "$BASE_URL/webhooks" \
-H "Content-Type: application/json" \
-d '{
"name": "Test QR Generator Webhook",
"url": "https://webhook.site/test-endpoint",
"secret": "test-secret-key-123",
"events": ["qr.claimed"]
}')
echo "Response: $WEBHOOK_RESPONSE"
echo ""
# Extract webhook ID (requires jq)
if command -v jq &> /dev/null; then
WEBHOOK_ID=$(echo "$WEBHOOK_RESPONSE" | jq -r '.webhook.id')
echo "Webhook ID: $WEBHOOK_ID"
else
echo "Note: Install jq to extract webhook ID automatically"
fi
echo ""
# Test 2: List all webhooks
echo "2. Listing all webhooks..."
curl -s "$BASE_URL/webhooks" | jq '.' || curl -s "$BASE_URL/webhooks"
echo ""
# Test 3: Update webhook (disable it)
if [ ! -z "$WEBHOOK_ID" ]; then
echo "3. Disabling webhook..."
curl -s -X PATCH "$BASE_URL/webhooks/$WEBHOOK_ID" \
-H "Content-Type: application/json" \
-d '{"isActive": false}' | jq '.' || echo "Update sent"
echo ""
fi
# Test 4: List webhooks again to see the change
echo "4. Listing webhooks after update..."
curl -s "$BASE_URL/webhooks" | jq '.' || curl -s "$BASE_URL/webhooks"
echo ""
echo "=== Test Complete ==="
echo ""
echo "To test webhook delivery:"
echo "1. Go to https://webhook.site and get a unique URL"
echo "2. Register a webhook with that URL"
echo "3. Scan and claim a QR code in the app"
echo "4. Check webhook.site to see the notification"