Skip to content

Commit 98087cf

Browse files
committed
test(protocol): add comprehensive protocol conformance test
1 parent b112885 commit 98087cf

14 files changed

Lines changed: 6243 additions & 1 deletion

open-agent-auth-integration-tests/pom.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@
141141
<groupId>org.apache.maven.plugins</groupId>
142142
<artifactId>maven-surefire-plugin</artifactId>
143143
<configuration>
144-
<!-- Include E2E tests when running mvn test -->
144+
<!-- Include E2E, Integration, and Conformance tests when running mvn test -->
145145
<includes>
146146
<include>**/*E2ETest.java</include>
147147
<include>**/*IntegrationTest.java</include>
148+
<include>**/*ConformanceTest.java</include>
148149
</includes>
149150
</configuration>
150151
</plugin>
@@ -171,5 +172,22 @@
171172
</plugins>
172173
</build>
173174
</profile>
175+
<!-- Profile for running protocol conformance tests -->
176+
<profile>
177+
<id>protocol-conformance</id>
178+
<build>
179+
<plugins>
180+
<plugin>
181+
<groupId>org.apache.maven.plugins</groupId>
182+
<artifactId>maven-surefire-plugin</artifactId>
183+
<configuration>
184+
<includes>
185+
<include>**/*ConformanceTest.java</include>
186+
</includes>
187+
</configuration>
188+
</plugin>
189+
</plugins>
190+
</build>
191+
</profile>
174192
</profiles>
175193
</project>
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
#!/bin/bash
2+
3+
###############################################################################
4+
# Open Agent Auth - Protocol Conformance Environment Diagnostic Script
5+
#
6+
# This script checks if the environment is ready for protocol conformance testing.
7+
# It validates all required services and protocol endpoints are accessible.
8+
#
9+
# Usage: ./scripts/diagnose-conformance-env.sh
10+
#
11+
# Author: Open Agent Auth Team
12+
###############################################################################
13+
14+
# Script directory
15+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
17+
18+
# Colors for output
19+
RED='\033[0;31m'
20+
GREEN='\033[0;32m'
21+
YELLOW='\033[1;33m'
22+
BLUE='\033[0;34m'
23+
MAGENTA='\033[0;35m'
24+
CYAN='\033[0;36m'
25+
NC='\033[0m' # No Color
26+
27+
echo -e "${CYAN}╔════════════════════════════════════════════════════════════════╗${NC}"
28+
echo -e "${CYAN}║ ║${NC}"
29+
echo -e "${CYAN}║ Protocol Conformance Environment Diagnostic Tool ║${NC}"
30+
echo -e "${CYAN}║ ║${NC}"
31+
echo -e "${CYAN}╚════════════════════════════════════════════════════════════════╝${NC}"
32+
echo ""
33+
34+
TOTAL_CHECKS=7
35+
ALL_PASSED=true
36+
37+
# Check 1: Java version
38+
echo -e "${BLUE}[Check 1/${TOTAL_CHECKS}] Java Version${NC}"
39+
echo -e "${YELLOW}─────────────────────────────────────────────────────────────${NC}"
40+
41+
JAVA_VERSION=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2)
42+
echo -e " Java version: ${JAVA_VERSION}"
43+
44+
if [[ "$JAVA_VERSION" == "17"* ]] || [[ "$JAVA_VERSION" == "21"* ]]; then
45+
echo -e " ${GREEN}✓ Java version is compatible${NC}"
46+
else
47+
echo -e " ${YELLOW}⚠ Java version may not be compatible (recommended: 17 or 21)${NC}"
48+
fi
49+
echo ""
50+
51+
# Check 2: Maven
52+
echo -e "${BLUE}[Check 2/${TOTAL_CHECKS}] Maven Installation${NC}"
53+
echo -e "${YELLOW}─────────────────────────────────────────────────────────────${NC}"
54+
55+
if command -v mvn &> /dev/null; then
56+
MVN_VERSION=$(mvn -version 2>&1 | head -n 1)
57+
echo -e " ${GREEN}✓ Maven is installed${NC}"
58+
echo -e " $MVN_VERSION"
59+
else
60+
echo -e " ${RED}✗ Maven is not installed${NC}"
61+
ALL_PASSED=false
62+
fi
63+
echo ""
64+
65+
# Check 3: Required services (port listening)
66+
echo -e "${BLUE}[Check 3/${TOTAL_CHECKS}] Required Services (Port Listening)${NC}"
67+
echo -e "${YELLOW}─────────────────────────────────────────────────────────────${NC}"
68+
69+
REQUIRED_SERVICES=(
70+
"8082:Agent IDP"
71+
"8083:Agent User IDP"
72+
"8084:AS User IDP"
73+
"8085:Authorization Server"
74+
"8086:Resource Server"
75+
)
76+
77+
ALL_SERVICES_RUNNING=true
78+
for service_info in "${REQUIRED_SERVICES[@]}"; do
79+
port=$(echo "$service_info" | cut -d: -f1)
80+
name=$(echo "$service_info" | cut -d: -f2)
81+
82+
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
83+
echo -e " ${GREEN}$name (port $port) - Running${NC}"
84+
else
85+
echo -e " ${RED}$name (port $port) - Not running${NC}"
86+
ALL_SERVICES_RUNNING=false
87+
ALL_PASSED=false
88+
fi
89+
done
90+
91+
if [ "$ALL_SERVICES_RUNNING" = true ]; then
92+
echo -e " ${GREEN}✓ All services are running${NC}"
93+
else
94+
echo -e " ${RED}✗ Some services are not running${NC}"
95+
fi
96+
echo ""
97+
98+
# Check 4: JWKS endpoints (health check)
99+
echo -e "${BLUE}[Check 4/${TOTAL_CHECKS}] JWKS Endpoints (Health Check)${NC}"
100+
echo -e "${YELLOW}─────────────────────────────────────────────────────────────${NC}"
101+
102+
JWKS_SERVICES=(
103+
"8082:Agent IDP"
104+
"8083:Agent User IDP"
105+
"8084:AS User IDP"
106+
"8085:Authorization Server"
107+
)
108+
109+
ALL_JWKS_HEALTHY=true
110+
for service_info in "${JWKS_SERVICES[@]}"; do
111+
port=$(echo "$service_info" | cut -d: -f1)
112+
name=$(echo "$service_info" | cut -d: -f2)
113+
114+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:$port/.well-known/jwks.json" 2>/dev/null || echo "000")
115+
116+
if [ "$HTTP_CODE" = "200" ]; then
117+
echo -e " ${GREEN}$name JWKS endpoint (HTTP $HTTP_CODE)${NC}"
118+
else
119+
echo -e " ${RED}$name JWKS endpoint (HTTP $HTTP_CODE)${NC}"
120+
ALL_JWKS_HEALTHY=false
121+
ALL_PASSED=false
122+
fi
123+
done
124+
125+
if [ "$ALL_JWKS_HEALTHY" = true ]; then
126+
echo -e " ${GREEN}✓ All JWKS endpoints are accessible${NC}"
127+
fi
128+
echo ""
129+
130+
# Check 5: OAuth 2.0 protocol endpoints
131+
echo -e "${BLUE}[Check 5/${TOTAL_CHECKS}] OAuth 2.0 Protocol Endpoints${NC}"
132+
echo -e "${YELLOW}─────────────────────────────────────────────────────────────${NC}"
133+
134+
OAUTH_ENDPOINTS=(
135+
"http://localhost:8085/.well-known/openid-configuration:OIDC Discovery"
136+
"http://localhost:8085/.well-known/jwks.json:JWKS"
137+
)
138+
139+
ALL_OAUTH_HEALTHY=true
140+
for endpoint_info in "${OAUTH_ENDPOINTS[@]}"; do
141+
url=$(echo "$endpoint_info" | cut -d: -f1-3)
142+
name=$(echo "$endpoint_info" | cut -d: -f4)
143+
144+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$url" 2>/dev/null || echo "000")
145+
146+
if [ "$HTTP_CODE" = "200" ]; then
147+
echo -e " ${GREEN}$name ($url) - HTTP $HTTP_CODE${NC}"
148+
else
149+
echo -e " ${RED}$name ($url) - HTTP $HTTP_CODE${NC}"
150+
ALL_OAUTH_HEALTHY=false
151+
ALL_PASSED=false
152+
fi
153+
done
154+
155+
# Token endpoint requires POST, so we check with a simple POST
156+
TOKEN_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST "http://localhost:8085/oauth2/token" 2>/dev/null || echo "000")
157+
if [ "$TOKEN_CODE" = "400" ] || [ "$TOKEN_CODE" = "401" ]; then
158+
echo -e " ${GREEN}✓ Token Endpoint (http://localhost:8085/oauth2/token) - HTTP $TOKEN_CODE (expected error for empty request)${NC}"
159+
elif [ "$TOKEN_CODE" = "000" ]; then
160+
echo -e " ${RED}✗ Token Endpoint (http://localhost:8085/oauth2/token) - Not reachable${NC}"
161+
ALL_OAUTH_HEALTHY=false
162+
ALL_PASSED=false
163+
else
164+
echo -e " ${YELLOW}⚠ Token Endpoint (http://localhost:8085/oauth2/token) - HTTP $TOKEN_CODE${NC}"
165+
fi
166+
167+
# PAR endpoint requires POST
168+
PAR_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST "http://localhost:8085/par" 2>/dev/null || echo "000")
169+
if [ "$PAR_CODE" = "400" ] || [ "$PAR_CODE" = "401" ]; then
170+
echo -e " ${GREEN}✓ PAR Endpoint (http://localhost:8085/par) - HTTP $PAR_CODE (expected error for empty request)${NC}"
171+
elif [ "$PAR_CODE" = "000" ]; then
172+
echo -e " ${RED}✗ PAR Endpoint (http://localhost:8085/par) - Not reachable${NC}"
173+
ALL_OAUTH_HEALTHY=false
174+
ALL_PASSED=false
175+
else
176+
echo -e " ${YELLOW}⚠ PAR Endpoint (http://localhost:8085/par) - HTTP $PAR_CODE${NC}"
177+
fi
178+
179+
if [ "$ALL_OAUTH_HEALTHY" = true ]; then
180+
echo -e " ${GREEN}✓ All OAuth 2.0 protocol endpoints are accessible${NC}"
181+
fi
182+
echo ""
183+
184+
# Check 6: Conformance test files
185+
echo -e "${BLUE}[Check 6/${TOTAL_CHECKS}] Conformance Test Files${NC}"
186+
echo -e "${YELLOW}─────────────────────────────────────────────────────────────${NC}"
187+
188+
CONFORMANCE_DIR="$PROJECT_ROOT/src/test/java/com/alibaba/openagentauth/integration/conformance"
189+
190+
EXPECTED_FILES=(
191+
"ProtocolConformanceTest.java"
192+
"ProtocolConformanceTestCondition.java"
193+
"OidcDiscoveryConformanceTest.java"
194+
"OAuth2TokenEndpointConformanceTest.java"
195+
"OAuth2ParConformanceTest.java"
196+
"OAuth2DcrConformanceTest.java"
197+
"JwksEndpointConformanceTest.java"
198+
"OidcIdTokenConformanceTest.java"
199+
"WimseWorkloadCredsConformanceTest.java"
200+
)
201+
202+
ALL_FILES_EXIST=true
203+
for file in "${EXPECTED_FILES[@]}"; do
204+
if [ -f "$CONFORMANCE_DIR/$file" ]; then
205+
echo -e " ${GREEN}$file${NC}"
206+
else
207+
echo -e " ${RED}$file - Missing${NC}"
208+
ALL_FILES_EXIST=false
209+
ALL_PASSED=false
210+
fi
211+
done
212+
213+
if [ "$ALL_FILES_EXIST" = true ]; then
214+
echo -e " ${GREEN}✓ All conformance test files exist${NC}"
215+
fi
216+
echo ""
217+
218+
# Check 7: Maven profile
219+
echo -e "${BLUE}[Check 7/${TOTAL_CHECKS}] Maven Profile Configuration${NC}"
220+
echo -e "${YELLOW}─────────────────────────────────────────────────────────────${NC}"
221+
222+
POM_FILE="$PROJECT_ROOT/pom.xml"
223+
if grep -q "protocol-conformance" "$POM_FILE" 2>/dev/null; then
224+
echo -e " ${GREEN}✓ protocol-conformance profile is configured in pom.xml${NC}"
225+
else
226+
echo -e " ${RED}✗ protocol-conformance profile is missing from pom.xml${NC}"
227+
ALL_PASSED=false
228+
fi
229+
230+
if grep -q "ConformanceTest" "$POM_FILE" 2>/dev/null; then
231+
echo -e " ${GREEN}✓ ConformanceTest pattern is included in surefire configuration${NC}"
232+
else
233+
echo -e " ${RED}✗ ConformanceTest pattern is missing from surefire configuration${NC}"
234+
ALL_PASSED=false
235+
fi
236+
echo ""
237+
238+
# Summary
239+
echo -e "${BLUE}═════════════════════════════════════════════════════════════════${NC}"
240+
echo -e "${BLUE}Diagnostic Summary${NC}"
241+
echo -e "${BLUE}═════════════════════════════════════════════════════════════════${NC}"
242+
echo ""
243+
244+
if [ "$ALL_PASSED" = true ]; then
245+
echo -e "${GREEN}✓ Environment is ready for protocol conformance testing${NC}"
246+
echo ""
247+
echo -e "${CYAN}Next Steps:${NC}"
248+
echo -e " Run conformance tests: ./scripts/run-conformance-tests.sh"
249+
echo -e " Run with skip-services: ./scripts/run-conformance-tests.sh --skip-services --skip-build"
250+
else
251+
echo -e "${RED}✗ Environment is not ready for protocol conformance testing${NC}"
252+
echo ""
253+
echo -e "${CYAN}Recommended Actions:${NC}"
254+
255+
if [ "$ALL_SERVICES_RUNNING" = false ]; then
256+
echo -e " 1. Start all services: ../open-agent-auth-samples/scripts/sample-start.sh"
257+
fi
258+
259+
if [ "$ALL_JWKS_HEALTHY" = false ] || [ "$ALL_OAUTH_HEALTHY" = false ]; then
260+
echo -e " 2. Check service logs: ../open-agent-auth-samples/scripts/sample-logs.sh <service-name>"
261+
echo -e " 3. Restart services: ../open-agent-auth-samples/scripts/sample-restart.sh"
262+
fi
263+
264+
if [ "$ALL_FILES_EXIST" = false ]; then
265+
echo -e " 4. Ensure all conformance test files are present"
266+
fi
267+
268+
echo -e " 5. Run diagnostics again: ./scripts/diagnose-conformance-env.sh"
269+
fi
270+
271+
echo ""

0 commit comments

Comments
 (0)