forked from Healthy-Stellar/Healthy-Stellar-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-api-key-implementation.sh
More file actions
126 lines (111 loc) · 3.11 KB
/
Copy pathverify-api-key-implementation.sh
File metadata and controls
126 lines (111 loc) · 3.11 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
#!/bin/bash
# Verification script for API Key implementation
# Run this script to verify the API key authentication system is working
set -e
echo "🔍 Verifying API Key Implementation..."
echo ""
# Check if migration file exists
echo "✓ Checking migration file..."
if [ -f "src/migrations/1772500000000-CreateApiKeysTable.ts" ]; then
echo " ✔ Migration file found"
else
echo " ✗ Migration file not found"
exit 1
fi
# Check entity file
echo "✓ Checking API Key entity..."
if [ -f "src/auth/entities/api-key.entity.ts" ]; then
echo " ✔ Entity file found"
if grep -q "enum ApiKeyScope" src/auth/entities/api-key.entity.ts; then
echo " ✔ ApiKeyScope enum defined"
else
echo " ✗ ApiKeyScope enum not found"
exit 1
fi
else
echo " ✗ Entity file not found"
exit 1
fi
# Check service file
echo "✓ Checking API Key service..."
if [ -f "src/auth/services/api-key.service.ts" ]; then
echo " ✔ Service file found"
if grep -q "validateApiKey" src/auth/services/api-key.service.ts; then
echo " ✔ validateApiKey method found"
else
echo " ✗ validateApiKey method not found"
exit 1
fi
else
echo " ✗ Service file not found"
exit 1
fi
# Check guard file
echo "✓ Checking API Key guard..."
if [ -f "src/auth/guards/api-key.guard.ts" ]; then
echo " ✔ Guard file found"
else
echo " ✗ Guard file not found"
exit 1
fi
# Check strategy file
echo "✓ Checking API Key strategy..."
if [ -f "src/auth/strategies/api-key.strategy.ts" ]; then
echo " ✔ Strategy file found"
else
echo " ✗ Strategy file not found"
exit 1
fi
# Check admin controller
echo "✓ Checking Admin controller..."
if [ -f "src/admin/controllers/admin.controller.ts" ]; then
echo " ✔ Admin controller found"
if grep -q "POST\|DELETE\|GET" src/admin/controllers/admin.controller.ts; then
echo " ✔ All CRUD endpoints defined"
else
echo " ✗ CRUD endpoints not properly defined"
exit 1
fi
else
echo " ✗ Admin controller not found"
exit 1
fi
# Check test files
echo "✓ Checking test files..."
if [ -f "test/unit/api-key.service.spec.ts" ]; then
echo " ✔ Service tests found"
else
echo " ✗ Service tests not found"
fi
if [ -f "test/unit/api-key.guard.spec.ts" ]; then
echo " ✔ Guard tests found"
else
echo " ✗ Guard tests not found"
fi
if [ -f "test/unit/api-key.strategy.spec.ts" ]; then
echo " ✔ Strategy tests found"
else
echo " ✗ Strategy tests not found"
fi
# Check throttler guard
echo "✓ Checking API Key throttler..."
if [ -f "src/common/throttler/api-key-throttler.guard.ts" ]; then
echo " ✔ API Key throttler guard found"
else
echo " ✗ API Key throttler guard not found"
exit 1
fi
# Check documentation
echo "✓ Checking documentation..."
if [ -f "docs/api-key-authentication.md" ]; then
echo " ✔ Documentation found"
else
echo " ✗ Documentation not found"
fi
echo ""
echo "✅ All API Key implementation checks passed!"
echo ""
echo "📋 Next steps:"
echo " 1. Run database migrations: npm run migration:run"
echo " 2. Run unit tests: npm test"
echo " 3. Review documentation: docs/api-key-authentication.md"