-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-comprehensive-api.sh
More file actions
165 lines (146 loc) · 5.48 KB
/
test-comprehensive-api.sh
File metadata and controls
165 lines (146 loc) · 5.48 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
# DataCoreX Comprehensive API Testing Script
# Based on the complete API documentation from /api-docs
BASE_URL="http://localhost:8081"
ORG_ID="1"
API_KEY="dcx_EXAMPLE_API_KEY_FOR_TESTING"
echo "🧪 DataCoreX Comprehensive API Testing"
echo "====================================="
# Test 1: API Information
echo "📋 1. Testing API Information..."
response=$(curl -s "$BASE_URL/api/info")
if [[ $response == *"DataCoreX"* ]]; then
echo "✅ API Information endpoint working"
else
echo "❌ API Information endpoint failed"
fi
# Test 2: System Health Check
echo "🏥 2. Testing System Health..."
response=$(curl -s "$BASE_URL/api/health")
if [[ $response == *"UP"* ]]; then
echo "✅ System health check passed"
else
echo "❌ System health check failed"
fi
# Test 3: Organization Profile
echo "🏢 3. Testing Organization Profile..."
response=$(curl -s -H "X-API-Key: $API_KEY" "$BASE_URL/api/organization/profile/$ORG_ID")
if [[ $response == *"success"* || $response == *"Profile"* ]]; then
echo "✅ Organization profile retrieved successfully"
echo " Profile: $(echo $response)"
else
echo "❌ Organization profile retrieval failed"
echo " Response: $response"
fi
# Test 4: System Information
echo "🖥️ 4. Testing System Information..."
response=$(curl -s -H "X-API-Key: $API_KEY" "$BASE_URL/api/system/info")
if [[ $response == *"javaVersion"* || $response == *"osName"* || $response == *"totalMemory"* ]]; then
echo "✅ System information retrieved"
echo " Java Version: $(echo $response | grep -o '"javaVersion":"[^"]*"' | cut -d'"' -f4)"
else
echo "❌ System information failed"
echo " Response: $response"
fi
# Test 5: Real-time Service Status
echo "⚡ 5. Testing Real-time Service Status..."
response=$(curl -s "$BASE_URL/api/realtime/status")
if [[ $response == *"status"* ]]; then
echo "✅ Real-time service status retrieved"
else
echo "❌ Real-time service status failed"
fi
# Test 6: Storage Statistics
echo "💾 6. Testing Storage Statistics..."
response=$(curl -s -H "X-API-Key: $API_KEY" "$BASE_URL/api/storage/stats")
if [[ $? -eq 0 ]]; then
echo "✅ Storage statistics endpoint accessible"
else
echo "❌ Storage statistics endpoint failed"
fi
# Test 7: Activity Log Statistics
echo "📊 7. Testing Activity Log Statistics..."
response=$(curl -s -H "X-API-Key: $API_KEY" "$BASE_URL/api/activity-logs/statistics")
if [[ $response == *"totalLogs"* || $response == *"statistics"* || $? -eq 0 ]]; then
echo "✅ Activity log statistics retrieved"
else
echo "❌ Activity log statistics failed"
echo " Response: $response"
fi
# Test 8: Cloud Functions Health
echo "☁️ 8. Testing Cloud Functions Health..."
response=$(curl -s -H "X-API-Key: $API_KEY" "$BASE_URL/api/functions/health")
if [[ $? -eq 0 ]]; then
echo "✅ Cloud functions health check accessible"
else
echo "❌ Cloud functions health check failed"
fi
# Test 9: Firebase Service Status
echo "🔥 9. Testing Firebase Service Status..."
response=$(curl -s -H "X-API-Key: $API_KEY" "$BASE_URL/api/firebase/status")
if [[ $? -eq 0 ]]; then
echo "✅ Firebase service status accessible"
else
echo "❌ Firebase service status failed"
fi
# Test 10: Real-time Data Statistics
echo "📈 10. Testing Real-time Data Statistics..."
response=$(curl -s "$BASE_URL/api/realtime-data/statistics")
if [[ $? -eq 0 ]]; then
echo "✅ Real-time data statistics accessible"
else
echo "❌ Real-time data statistics failed"
fi
# Test 11: Current Metrics
echo "📏 11. Testing Current Metrics..."
response=$(curl -s "$BASE_URL/api/realtime-data/metrics/current")
if [[ $? -eq 0 ]]; then
echo "✅ Current metrics endpoint accessible"
else
echo "❌ Current metrics endpoint failed"
fi
# Test 12: Debug System Information
echo "🐛 12. Testing Debug System Information..."
response=$(curl -s -H "X-API-Key: $API_KEY" "$BASE_URL/api/debug/system-info")
if [[ $response == *"java"* || $response == *"os"* || $response == *"system"* || $? -eq 0 ]]; then
echo "✅ Debug system information retrieved"
else
echo "❌ Debug system information failed"
echo " Response: $response"
fi
# Test 13: Test Real-time Database Collection Query
echo "🗄️ 13. Testing Real-time Database Query..."
response=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "X-API-Key: $API_KEY" \
"$BASE_URL/api/realtime-db/organizations/$ORG_ID/collections/test/query" \
-d '{"limit": 10}')
if [[ $? -eq 0 ]]; then
echo "✅ Real-time database query endpoint accessible"
else
echo "❌ Real-time database query failed"
fi
# Test 14: List Functions for Organization
echo "⚙️ 14. Testing Function Listing..."
response=$(curl -s -H "X-API-Key: $API_KEY" "$BASE_URL/api/functions/list/$ORG_ID")
if [[ $? -eq 0 ]]; then
echo "✅ Function listing endpoint accessible"
else
echo "❌ Function listing failed"
fi
# Test 15: Real-time Connections
echo "🔗 15. Testing Real-time Connections..."
response=$(curl -s "$BASE_URL/api/realtime/connections")
if [[ $? -eq 0 ]]; then
echo "✅ Real-time connections endpoint accessible"
else
echo "❌ Real-time connections failed"
fi
echo ""
echo "🎉 Comprehensive API Testing Complete!"
echo "====================================="
echo "📚 Full API Documentation: http://localhost:8081/api-docs"
echo "🖥️ H2 Database Console: http://localhost:8081/h2-console"
echo "❤️ Health Status: http://localhost:8081/actuator/health"
echo ""
echo "🚀 Your DataCoreX BaaS Platform is Ready for Integration!"