-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bulk_upload.sh
More file actions
executable file
·51 lines (41 loc) · 1.44 KB
/
Copy pathtest_bulk_upload.sh
File metadata and controls
executable file
·51 lines (41 loc) · 1.44 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
#!/bin/bash
# Test bulk upload endpoint
# Usage: ./test_bulk_upload.sh <auth_token> [base_url]
TOKEN="${1:-}"
BASE_URL="${2:-http://localhost:8080}"
if [ -z "$TOKEN" ]; then
echo "Usage: ./test_bulk_upload.sh <auth_token> [base_url]"
echo ""
echo "Get your token from browser localStorage:"
echo " localStorage.getItem('authToken')"
exit 1
fi
echo "Testing bulk upload endpoint..."
echo "Base URL: $BASE_URL"
echo ""
# First, test if the endpoint is reachable with a simple OPTIONS request
echo "1. Testing OPTIONS (CORS preflight)..."
curl -s -X OPTIONS "$BASE_URL/api/v1/admin/datasets/upload-bulk" \
-H "Origin: http://localhost:3000" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: Authorization, Content-Type" \
-w "\nHTTP Status: %{http_code}\n" \
-o /dev/null
echo ""
echo "2. Testing POST without file (should get validation error)..."
curl -s -X POST "$BASE_URL/api/v1/admin/datasets/upload-bulk" \
-H "Authorization: Bearer $TOKEN" \
-F "state=OH" \
| jq . 2>/dev/null || cat
echo ""
echo "3. Testing with a dummy file..."
# Create a small test file
echo '{"type":"FeatureCollection","features":[]}' > /tmp/test-upload.geojson
curl -s -X POST "$BASE_URL/api/v1/admin/datasets/upload-bulk" \
-H "Authorization: Bearer $TOKEN" \
-F "state=OH" \
-F "files=@/tmp/test-upload.geojson" \
| jq . 2>/dev/null || cat
rm /tmp/test-upload.geojson
echo ""
echo "Done!"