-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-auth.sh
More file actions
executable file
·58 lines (50 loc) · 1.54 KB
/
test-auth.sh
File metadata and controls
executable file
·58 lines (50 loc) · 1.54 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
#!/bin/bash
# Test the translation endpoint with authentication
# Configuration
HOST="localhost"
PORT="8080"
SECRET="test-secret-123"
# Test data
SOURCE_TEXT="London is the capital"
SOURCE_LANG="english"
TARGET_LANG="русский"
MODE="explain"
PROVIDER="gemini"
echo "Testing authenticated translation endpoint..."
echo ""
echo "1. Test with valid authentication:"
curl -v -X POST "http://${HOST}:${PORT}/translation" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${SECRET}" \
-d "{
\"sourceText\": \"${SOURCE_TEXT}\",
\"sourceLang\": \"${SOURCE_LANG}\",
\"targetLang\": \"${TARGET_LANG}\",
\"mode\": \"${MODE}\",
\"provider\": \"${PROVIDER}\",
\"quality\": \"optimal\"
}"
echo -e "\n\n2. Test without authentication (should fail with 403):"
curl -v -X POST "http://${HOST}:${PORT}/translation" \
-H "Content-Type: application/json" \
-d "{
\"sourceText\": \"${SOURCE_TEXT}\",
\"sourceLang\": \"${SOURCE_LANG}\",
\"targetLang\": \"${TARGET_LANG}\",
\"mode\": \"${MODE}\",
\"provider\": \"${PROVIDER}\",
\"quality\": \"optimal\"
}"
echo -e "\n\n3. Test with invalid token (should fail with 403):"
curl -v -X POST "http://${HOST}:${PORT}/translation" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer wrong-token" \
-d "{
\"sourceText\": \"${SOURCE_TEXT}\",
\"sourceLang\": \"${SOURCE_LANG}\",
\"targetLang\": \"${TARGET_LANG}\",
\"mode\": \"${MODE}\",
\"provider\": \"${PROVIDER}\",
\"quality\": \"optimal\"
}"
echo -e "\n\nDone!"