Skip to content

Commit bb40cf3

Browse files
openapi: address Gemini review findings on bearerAuth switch
- Assert basicAuth is absent (not just that bearerAuth is present) in the performance test, so removal of the old key is explicitly verified - Strengthen testMultiSecuritySchemeScenario: verify bearerAuth scheme type/scheme values, assert basicAuth is gone, and verify the API-level security requirement actually references bearerAuth Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6160439 commit bb40cf3

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

modules/openapi/src/test/java/org/apache/axis2/openapi/AdvancedGuideIntegrationTest.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,21 @@ public void testMultiSecuritySchemeScenario() throws Exception {
273273
boolean hasOAuth2 = securitySchemes.containsKey("oauth2");
274274

275275
assertTrue("Should have bearer token authentication by default", hasBearerAuth);
276-
277-
// Test that operations can use different security schemes
278-
Map<String, PathItem> paths = openApi.getPaths();
279-
for (PathItem pathItem : paths.values()) {
280-
for (Operation operation : pathItem.readOperationsMap().values()) {
281-
if (operation.getSecurity() != null && !operation.getSecurity().isEmpty()) {
282-
// Verify security requirements are properly structured
283-
for (SecurityRequirement secReq : operation.getSecurity()) {
284-
assertFalse("Security requirements should not be empty", secReq.isEmpty());
285-
}
286-
}
287-
}
288-
}
276+
assertFalse("basicAuth must not appear in the default spec", securitySchemes.containsKey("basicAuth"));
277+
278+
// Verify the bearerAuth scheme is correctly typed
279+
SecurityScheme bearer = securitySchemes.get("bearerAuth");
280+
assertEquals("bearerAuth type must be HTTP", SecurityScheme.Type.HTTP, bearer.getType());
281+
assertEquals("bearerAuth scheme must be bearer", "bearer", bearer.getScheme());
282+
283+
// Verify the API-level security requirement references bearerAuth
284+
List<SecurityRequirement> apiSecurity = openApi.getSecurity();
285+
assertNotNull("API-level security requirements should be set", apiSecurity);
286+
assertFalse("API-level security requirements should not be empty", apiSecurity.isEmpty());
287+
boolean apiReferencesBearerAuth = apiSecurity.stream()
288+
.anyMatch(req -> req.containsKey("bearerAuth"));
289+
assertTrue("At least one API-level security requirement must reference bearerAuth",
290+
apiReferencesBearerAuth);
289291
}
290292

291293
// ========== Advanced SwaggerUI Customization Tests ==========

modules/openapi/src/test/java/org/apache/axis2/openapi/OpenApiConfigurationTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,10 @@ public void testLargeConfigurationPerformance() {
456456
assertEquals(10000, config.getResourcePackages().size());
457457
assertEquals(10000, config.getResourceClasses().size());
458458
assertEquals(10000, config.getIgnoredRoutes().size());
459-
// +1 for default bearerAuth scheme
459+
// +1 for default bearerAuth scheme; basicAuth must not be present
460460
assertEquals(10001, config.getSecurityDefinitions().size());
461+
assertFalse("basicAuth must not be present after switch to bearerAuth",
462+
config.getSecurityDefinitions().containsKey("basicAuth"));
461463
}
462464

463465
@Test

0 commit comments

Comments
 (0)