Skip to content

Commit

Permalink
Test security and securitySet in CallbackOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
Azquelt committed Jun 20, 2022
1 parent 2ac736c commit d58ec04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -41,6 +41,7 @@
import org.eclipse.microprofile.openapi.annotations.security.OAuthFlows;
import org.eclipse.microprofile.openapi.annotations.security.OAuthScope;
import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement;
import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirementsSet;
import org.eclipse.microprofile.openapi.annotations.security.SecurityScheme;
import org.eclipse.microprofile.openapi.annotations.servers.Server;
import org.eclipse.microprofile.openapi.annotations.servers.ServerVariable;
Expand Down Expand Up @@ -268,7 +269,14 @@ public Response getReviewByAirlineAndUser(
schema = @Schema(type = SchemaType.ARRAY,
implementation = Review.class))),
extensions = @Extension(name = "x-callback-operation",
value = "test-callback-operation")),
value = "test-callback-operation"),
security = @SecurityRequirement(name = "httpTestScheme"),
securitySets = {@SecurityRequirementsSet({
@SecurityRequirement(name = "testScheme1"),
@SecurityRequirement(name = "testScheme2")
}),
@SecurityRequirementsSet()
}),
extensions = @Extension(name = "x-callback", value = "test-callback"))
})
@Tag(ref = "Reviews")
Expand Down
Expand Up @@ -564,6 +564,18 @@ public void testSecurityRequirement(String type) {
hasEntry(equalTo("userBearerHttp"), empty()))));
}

@RunAsClient
@Test(dataProvider = "formatProvider")
public void testSecuirtyRequirementInCallback(String type) {
ValidatableResponse vr = callEndpoint(type);
String callbackOpPath =
"paths.'/reviews'.post.callbacks.testCallback.'http://localhost:9080/oas3-airlines/reviews'.get";
vr.body(callbackOpPath + ".security", containsInAnyOrder(
hasKey("httpTestScheme"),
allOf(hasKey("testScheme1"), hasKey("testScheme2")),
anEmptyMap()));
}

@RunAsClient
@Test(dataProvider = "formatProvider")
public void testSecuritySchemes(String type) {
Expand Down

0 comments on commit d58ec04

Please sign in to comment.