-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_dual_auth.sh
More file actions
executable file
·50 lines (37 loc) · 1.52 KB
/
Copy pathtest_dual_auth.sh
File metadata and controls
executable file
·50 lines (37 loc) · 1.52 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
#!/bin/bash
# Test script to demonstrate dual authentication support
# Shows both X-API-Key and Authorization Bearer methods work
echo "🔐 Testing Dual Authentication Support"
echo "====================================="
# Test endpoint that requires authentication
ENDPOINT="http://localhost:8080/api/v1/health"
echo "Testing health endpoint (no auth required):"
echo "curl -s \"$ENDPOINT\""
curl -s "$ENDPOINT" | jq .
echo
echo "Testing protected endpoint with different auth methods:"
echo "Note: Replace 'your-valid-api-key' with an actual API key to test"
echo
PROTECTED_ENDPOINT="http://localhost:8080/api/v1/counties?limit=1"
echo "Method 1 - X-API-Key Header:"
echo "curl -H \"X-API-Key: your-valid-api-key\" \"$PROTECTED_ENDPOINT\""
echo
echo "Method 2 - Authorization Bearer:"
echo "curl -H \"Authorization: Bearer your-valid-api-key\" \"$PROTECTED_ENDPOINT\""
echo
echo "Expected behavior:"
echo "- Both methods should work identically"
echo "- Invalid keys return 401 with helpful error message"
echo "- Missing auth returns 401 with both header options mentioned"
echo
echo "Testing missing authentication:"
curl -s "$PROTECTED_ENDPOINT" | jq .
echo
echo "Testing invalid Authorization format:"
curl -s -H "Authorization: InvalidFormat some-key" "$PROTECTED_ENDPOINT" | jq .
echo
echo "Testing invalid API key (X-API-Key):"
curl -s -H "X-API-Key: invalid-key" "$PROTECTED_ENDPOINT" | jq .
echo
echo "Testing invalid API key (Authorization Bearer):"
curl -s -H "Authorization: Bearer invalid-key" "$PROTECTED_ENDPOINT" | jq .