forked from cleanappio/cleanapp_back_end_v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_report_auth_auth.sh
More file actions
executable file
·55 lines (46 loc) · 2.06 KB
/
test_report_auth_auth.sh
File metadata and controls
executable file
·55 lines (46 loc) · 2.06 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
#!/bin/bash
# Test script for report-auth service authentication
# This script demonstrates both authentication methods
echo "Testing Report Auth Service Authentication"
echo "=========================================="
echo ""
# Base URL for the report-auth service
REPORT_AUTH_URL="http://localhost:8081"
echo "1. Testing without authentication (should fail):"
echo "-----------------------------------------------"
curl -s -X POST "$REPORT_AUTH_URL/api/v3/reports/authorization" \
-H "Content-Type: application/json" \
-d '{"report_seqs": [1, 2, 3]}' | jq .
echo ""
echo "2. Testing with invalid JWT token (should fail):"
echo "------------------------------------------------"
curl -s -X POST "$REPORT_AUTH_URL/api/v3/reports/authorization" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer invalid_token_here" \
-d '{"report_seqs": [1, 2, 3]}' | jq .
echo ""
echo "3. Testing with internal service header (should work if service is running):"
echo "--------------------------------------------------------------------------"
curl -s -X POST "$REPORT_AUTH_URL/api/v3/reports/authorization" \
-H "Content-Type: application/json" \
-H "X-User-ID: test_user_123" \
-d '{"report_seqs": [1, 2, 3]}' | jq .
echo ""
echo "4. Testing health endpoint (should work without auth):"
echo "-----------------------------------------------------"
curl -s "$REPORT_AUTH_URL/health" | jq .
echo ""
echo "5. Testing API health endpoint (should work without auth):"
echo "----------------------------------------------------------"
curl -s "$REPORT_AUTH_URL/api/v3/health" | jq .
echo ""
echo "Note: For JWT token authentication, you need to:"
echo "1. Login to the auth-service to get a valid token"
echo "2. Use that token in the Authorization header"
echo "3. The token will be validated by calling the auth-service"
echo ""
echo "Example with valid JWT:"
echo "curl -X POST \"$REPORT_AUTH_URL/api/v3/reports/authorization\" \\"
echo " -H \"Content-Type: application/json\" \\"
echo " -H \"Authorization: Bearer YOUR_JWT_TOKEN_HERE\" \\"
echo " -d '{\"report_seqs\": [1, 2, 3]}'"