Search in sources :

Example 56 with TestRequest

use of io.vertx.ext.web.validation.testutils.TestRequest in project vertx-web by vert-x3.

the class RouterBuilderSecurityHandlerOptionalTest method mountSingle.

@Test
public void mountSingle(Vertx vertx, VertxTestContext testContext) {
    Checkpoint checkpoint = testContext.checkpoint();
    loadBuilderAndStartServer(vertx, SECURITY_TESTS, testContext, routerBuilder -> {
        routerBuilder.setOptions(FACTORY_OPTIONS);
        routerBuilder.securityHandler("api_key", SimpleAuthenticationHandler.create().authenticate(ctx -> Future.failedFuture(new HttpException(401, "Oops!")))).operation("pets").handler(routingContext -> routingContext.response().setStatusCode(200).end());
    }).onComplete(h -> testRequest(client, HttpMethod.GET, "/pets").expect(statusCode(200), statusMessage("OK")).send(testContext, checkpoint));
}
Also used : VertxTestContext(io.vertx.junit5.VertxTestContext) APIKeyHandler(io.vertx.ext.web.handler.APIKeyHandler) SimpleAuthenticationHandler(io.vertx.ext.web.handler.SimpleAuthenticationHandler) Vertx(io.vertx.core.Vertx) TestRequest(io.vertx.ext.web.validation.testutils.TestRequest) OAuth2AuthHandler(io.vertx.ext.web.handler.OAuth2AuthHandler) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) Timeout(io.vertx.junit5.Timeout) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) HttpMethod(io.vertx.core.http.HttpMethod) Checkpoint(io.vertx.junit5.Checkpoint) HttpException(io.vertx.ext.web.handler.HttpException) Checkpoint(io.vertx.junit5.Checkpoint) HttpException(io.vertx.ext.web.handler.HttpException) Test(org.junit.jupiter.api.Test)

Aggregations

Vertx (io.vertx.core.Vertx)56 HttpMethod (io.vertx.core.http.HttpMethod)56 TestRequest (io.vertx.ext.web.validation.testutils.TestRequest)56 Checkpoint (io.vertx.junit5.Checkpoint)56 VertxTestContext (io.vertx.junit5.VertxTestContext)56 Test (org.junit.jupiter.api.Test)56 JsonObject (io.vertx.core.json.JsonObject)55 VertxExtension (io.vertx.junit5.VertxExtension)50 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)50 Future (io.vertx.core.Future)47 Timeout (io.vertx.junit5.Timeout)47 Handler (io.vertx.core.Handler)46 Route (io.vertx.ext.web.Route)46 Router (io.vertx.ext.web.Router)46 RoutingContext (io.vertx.ext.web.RoutingContext)46 Arrays (java.util.Arrays)46 Collectors (java.util.stream.Collectors)46 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)46 Condition (org.assertj.core.api.Condition)46 ArrayList (java.util.ArrayList)36