io.restassured.config.SSLConfig Java Examples

The following examples show how to use io.restassured.config.SSLConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VerifySSLComponentTest.java    From riposte with Apache License 2.0 8 votes vote down vote up
@Test
public void verify_get(){
    String responseString= given()
            .config(RestAssuredConfig.newConfig().sslConfig(new SSLConfig().relaxedHTTPSValidation()))
            .baseUri("https://127.0.0.1")
            .port(serverConfig.endpointsSslPort())
            .basePath(SSLTestEndpoint.MATCHING_PATH)
            .log().all()
        .when()
            .get()
        .then()
            .log().all()
            .statusCode(200)
            .extract().asString();

    assertThat(responseString).isEqualTo(RESPONSE_STRING);
}
 
Example #2
Source File: VerifyProxySSLComponentTest.java    From riposte with Apache License 2.0 6 votes vote down vote up
@Test
public void verify_get() {
    String responseString = given()
            .config(RestAssuredConfig.newConfig().sslConfig(new SSLConfig().relaxedHTTPSValidation()))
            .baseUri("http://127.0.0.1")
            .port(proxyServerConfig.endpointsPort())
            .basePath(RouterEndpoint.MATCHING_PATH)
            .log().all()
            .when()
            .get()
            .then()
            .log().all()
            .statusCode(200)
            .extract().asString();

    assertThat(responseString).isEqualTo(RESPONSE_STRING);
}
 
Example #3
Source File: SecurityUtils.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
public static SSLConfig getConfiguredSslConfig() {
    TlsConfiguration tlsConfiguration = ConfigReader.environmentConfiguration().getTlsConfiguration();
    try {
        SSLContext sslContext = SSLContexts.custom()
            .loadKeyMaterial(
                new File(tlsConfiguration.getKeyStore()),
                tlsConfiguration.getKeyStorePassword() != null ? tlsConfiguration.getKeyStorePassword().toCharArray() : null,
                tlsConfiguration.getKeyPassword() != null ? tlsConfiguration.getKeyPassword().toCharArray() : null,
                (aliases, socket) -> tlsConfiguration.getKeyAlias())
            .loadTrustMaterial(
                new File(tlsConfiguration.getTrustStore()),
                tlsConfiguration.getTrustStorePassword() != null ? tlsConfiguration.getTrustStorePassword().toCharArray() : null)
            .build();
        SSLSocketFactoryAdapter sslSocketFactory = new SSLSocketFactoryAdapter(new SSLConnectionSocketFactory(sslContext, new DefaultHostnameVerifier()));
        return SSLConfig.sslConfig().with().sslSocketFactory(sslSocketFactory);
    } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException | KeyStoreException
        | CertificateException | IOException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
Example #4
Source File: RestAssuredConfiguration.java    From cukes with Apache License 2.0 5 votes vote down vote up
private RestAssuredConfig buildRestAssuredConfig() {
    RestAssuredConfig config = newConfig()
        .jsonConfig(jsonConfig().numberReturnType(JsonPathConfig.NumberReturnType.BIG_DECIMAL))
        .redirect(redirectConfig().followRedirects(world.getBoolean(CukesOptions.FOLLOW_REDIRECTS, true)));
    if(logStream != null)
        config = config.logConfig(logConfig().defaultStream(logStream));
    if (!world.getBoolean(CukesOptions.GZIP_SUPPORT, true)) {
        config = config.decoderConfig(decoderConfig().contentDecoders(DEFLATE));
    }
    config = config.sslConfig(new SSLConfig().allowAllHostnames());
    return config;
}
 
Example #5
Source File: HttpsIT.java    From seed with Mozilla Public License 2.0 5 votes vote down vote up
private ResponseSpecification expect(boolean followRedirects) {
    return RestAssured.given()
            .config(RestAssured.config()
                    .sslConfig(SSLConfig.sslConfig().relaxedHTTPSValidation("TLS"))
                    .redirect(RedirectConfig.redirectConfig().followRedirects(followRedirects))
            )
            .expect();
}
 
Example #6
Source File: AbstractApiMethod.java    From carina with Apache License 2.0 5 votes vote down vote up
public void setSSLContext(SSLContext sslContext) {
    SSLSocketFactory socketFactory = new SSLSocketFactory(sslContext);
    SSLConfig sslConfig = new SSLConfig();
    sslConfig = sslConfig.sslSocketFactory(socketFactory);

    RestAssuredConfig cfg = new RestAssuredConfig();
    cfg = cfg.sslConfig(sslConfig);
    request = request.config(cfg);
}
 
Example #7
Source File: WebSecurityIT.java    From seed with Mozilla Public License 2.0 4 votes vote down vote up
private RequestSpecification givenRelaxedSSL() {
    return RestAssured.given()
            .config(RestAssured.config().sslConfig(SSLConfig.sslConfig().relaxedHTTPSValidation()));
}
 
Example #8
Source File: XsrfIT.java    From seed with Mozilla Public License 2.0 4 votes vote down vote up
private RequestSpecification givenRelaxedSSL() {
    return RestAssured.given()
            .config(RestAssured.config().sslConfig(SSLConfig.sslConfig().relaxedHTTPSValidation()));
}
 
Example #9
Source File: HttpsWithCertificateIT.java    From seed with Mozilla Public License 2.0 4 votes vote down vote up
ResponseSpecification expect() {
    return RestAssured.given()
            .config(RestAssured.config()
                    .sslConfig(SSLConfig.sslConfig()
                            .sslSocketFactory(new SSLSocketFactory(sslContext,
                                    SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER))))
            .expect();
}
 
Example #10
Source File: RefreshIT.java    From seed with Mozilla Public License 2.0 4 votes vote down vote up
private ResponseSpecification expect() {
    return RestAssured.given()
            .config(RestAssured.config().sslConfig(SSLConfig.sslConfig().relaxedHTTPSValidation()))
            .expect();
}