Search in sources :

Example 1 with RequestOptions

use of io.vertx.core.http.RequestOptions in project vert.x by eclipse.

the class Http1xTLSTest method testRedirectFromSSL.

@Test
public void testRedirectFromSSL() throws Exception {
    HttpServer redirectServer = vertx.createHttpServer(new HttpServerOptions().setSsl(true).setKeyStoreOptions(Cert.SERVER_JKS.get()).setHost(DEFAULT_HTTP_HOST).setPort(DEFAULT_HTTP_PORT)).requestHandler(req -> {
        req.response().setStatusCode(307).putHeader("location", "http://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI).end();
    });
    startServer(redirectServer);
    RequestOptions options = new RequestOptions().setHost(DEFAULT_HTTP_HOST).setURI(DEFAULT_TEST_URI).setPort(4043);
    testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.NONE, Trust.NONE).clientSSL(true).serverSSL(false).requestOptions(options).followRedirects(true).pass();
}
Also used : RequestOptions(io.vertx.core.http.RequestOptions) HttpServer(io.vertx.core.http.HttpServer) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Test(org.junit.Test)

Example 2 with RequestOptions

use of io.vertx.core.http.RequestOptions in project vert.x by eclipse.

the class Http1xTLSTest method testRedirectToSSL.

// Redirect tests
@Test
public void testRedirectToSSL() throws Exception {
    HttpServer redirectServer = vertx.createHttpServer(new HttpServerOptions().setHost(DEFAULT_HTTP_HOST).setPort(DEFAULT_HTTP_PORT)).requestHandler(req -> {
        req.response().setStatusCode(307).putHeader("location", "https://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI).end();
    });
    startServer(redirectServer);
    RequestOptions options = new RequestOptions().setHost(DEFAULT_HTTP_HOST).setURI(DEFAULT_TEST_URI).setPort(DEFAULT_HTTP_PORT);
    testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(false).serverSSL(true).requestOptions(options).followRedirects(true).pass();
}
Also used : RequestOptions(io.vertx.core.http.RequestOptions) HttpServer(io.vertx.core.http.HttpServer) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Test(org.junit.Test)

Example 3 with RequestOptions

use of io.vertx.core.http.RequestOptions in project vert.x by eclipse.

the class Http1xTLSTest method testSSLClientRequestOptionsSetSSL.

@Test
public // Client trusts all server certs
void testSSLClientRequestOptionsSetSSL() throws Exception {
    RequestOptions options = new RequestOptions().setHost(DEFAULT_HTTP_HOST).setPort(4043).setURI(DEFAULT_TEST_URI).setSsl(true);
    testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(true).requestOptions(options).pass();
}
Also used : RequestOptions(io.vertx.core.http.RequestOptions) Test(org.junit.Test)

Example 4 with RequestOptions

use of io.vertx.core.http.RequestOptions in project vert.x by eclipse.

the class Http1xTLSTest method testClearClientRequestOptionsSetSSL.

// RequestOptions tests
@Test
public // Client trusts all server certs
void testClearClientRequestOptionsSetSSL() throws Exception {
    RequestOptions options = new RequestOptions().setHost(DEFAULT_HTTP_HOST).setPort(4043).setURI(DEFAULT_TEST_URI).setSsl(true);
    testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(false).requestOptions(options).pass();
}
Also used : RequestOptions(io.vertx.core.http.RequestOptions) Test(org.junit.Test)

Example 5 with RequestOptions

use of io.vertx.core.http.RequestOptions in project vert.x by eclipse.

the class Http1xTLSTest method testSSLClientRequestOptionsSetClear.

@Test
public // Client trusts all server certs
void testSSLClientRequestOptionsSetClear() throws Exception {
    RequestOptions options = new RequestOptions().setHost(DEFAULT_HTTP_HOST).setURI(DEFAULT_TEST_URI).setPort(4043).setSsl(false);
    testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(true).serverSSL(false).requestOptions(options).pass();
}
Also used : RequestOptions(io.vertx.core.http.RequestOptions) Test(org.junit.Test)

Aggregations

RequestOptions (io.vertx.core.http.RequestOptions)6 Test (org.junit.Test)6 HttpServer (io.vertx.core.http.HttpServer)2 HttpServerOptions (io.vertx.core.http.HttpServerOptions)2