Java Code Examples for io.restassured.RestAssured#useRelaxedHTTPSValidation()

The following examples show how to use io.restassured.RestAssured#useRelaxedHTTPSValidation() . 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: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void verifyHttpHeadersOnEureka() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    Map<String, String> expectedHeaders = new HashMap<>();
    expectedHeaders.put("X-Content-Type-Options", "nosniff");
    expectedHeaders.put("X-XSS-Protection", "1; mode=block");
    expectedHeaders.put("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
    expectedHeaders.put("Pragma", "no-cache");
    expectedHeaders.put("Content-Type", "application/xml");
    expectedHeaders.put("X-Frame-Options", "DENY");

    List<String> forbiddenHeaders = new ArrayList<>();
    forbiddenHeaders.add("Strict-Transport-Security");

    RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig());
    Response response = RestAssured
        .given()
            .get(getDiscoveryUriWithPath("/eureka/apps"));
    Map<String, String> responseHeaders = new HashMap<>();
    response.getHeaders().forEach(h -> responseHeaders.put(h.getName(), h.getValue()));

    expectedHeaders.forEach((key, value) -> assertThat(responseHeaders, hasEntry(key, value)));
    forbiddenHeaders.forEach(h -> assertThat(responseHeaders, not(hasKey(h))));
}
 
Example 2
Source File: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void verifyHttpHeadersOnApi() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    Map<String, String> expectedHeaders = new HashMap<>();
    expectedHeaders.put("X-Content-Type-Options", "nosniff");
    expectedHeaders.put("X-XSS-Protection", "1; mode=block");
    expectedHeaders.put("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
    expectedHeaders.put("Pragma", "no-cache");
    expectedHeaders.put("X-Frame-Options", "DENY");

    List<String> forbiddenHeaders = new ArrayList<>();
    forbiddenHeaders.add("Strict-Transport-Security");

    Response response = RestAssured
        .given()
          .auth().basic(username, password)
          .get(getDiscoveryUriWithPath("/application/info"));
    Map<String, String> responseHeaders = new HashMap<>();
    response.getHeaders().forEach(h -> responseHeaders.put(h.getName(), h.getValue()));

    expectedHeaders.forEach((key, value) -> assertThat(responseHeaders, hasEntry(key, value)));
    forbiddenHeaders.forEach(h -> assertThat(responseHeaders, not(hasKey(h))));
}
 
Example 3
Source File: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
@Flaky
public void verifyHttpHeadersOnUi() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    Map<String, String> expectedHeaders = new HashMap<>();
    expectedHeaders.put("X-Content-Type-Options", "nosniff");
    expectedHeaders.put("X-XSS-Protection", "1; mode=block");
    expectedHeaders.put("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
    expectedHeaders.put("Pragma", "no-cache");
    expectedHeaders.put("Content-Type", "text/html;charset=UTF-8");
    expectedHeaders.put("Transfer-Encoding", "chunked");
    expectedHeaders.put("X-Frame-Options", "DENY");

    List<String> forbiddenHeaders = new ArrayList<>();
    forbiddenHeaders.add("Strict-Transport-Security");

    Response response = RestAssured
        .given()
            .auth().basic(username, password)
            .get(getDiscoveryUriWithPath("/"));
    Map<String, String> responseHeaders = new HashMap<>();
    response.getHeaders().forEach(h -> responseHeaders.put(h.getName(), h.getValue()));

    expectedHeaders.forEach((key, value) -> assertThat(responseHeaders, hasEntry(key, value)));
    forbiddenHeaders.forEach(h -> assertThat(responseHeaders, not(hasKey(h))));
}
 
Example 4
Source File: PageRedirectionTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Initiate gateway properties, such as host, port, scheme
 */
private void initGatewayProperties() {
    GatewayServiceConfiguration gatewayServiceConfiguration = ConfigReader.environmentConfiguration().getGatewayServiceConfiguration();
    gatewayScheme = gatewayServiceConfiguration.getScheme();
    gatewayHost = gatewayServiceConfiguration.getHost();
    gatewayPort = gatewayServiceConfiguration.getPort();

    RestAssured.port = gatewayPort;
    RestAssured.useRelaxedHTTPSValidation();

    requestUrl = String.format("%s://%s:%d%s%s%s", gatewayScheme, gatewayHost, gatewayPort, API_PREFIX, "/" + SERVICE_ID, "/redirect");
}
 
Example 5
Source File: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testGatewayIsDiscoveredByEureka() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig());
    given()
    .when()
        .get(getDiscoveryUriWithPath("/eureka/apps/gateway"))
    .then()
        .statusCode(is(HttpStatus.SC_OK));
}
 
Example 6
Source File: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testApplicationInfoEndpoints_whenProvidedNothing() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    given()
    .when()
        .get(getDiscoveryUriWithPath("/application/info"))
    .then()
        .statusCode(is(HttpStatus.SC_OK));
}
 
Example 7
Source File: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testEurekaEndpoints_whenProvidedNothing() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    given()
    .when()
        .get(getDiscoveryUriWithPath("/eureka/apps"))
    .then()
        .statusCode(is(HttpStatus.SC_FORBIDDEN))
        .header(HttpHeaders.WWW_AUTHENTICATE, nullValue());
}
 
Example 8
Source File: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
@TestsNotMeantForZowe @Flaky
public void testApplicationInfoEndpoints_whenProvidedToken() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    String jwtToken = SecurityUtils.gatewayToken(username, password);
    given()
        .cookie(COOKIE, jwtToken)
    .when()
        .get(getDiscoveryUriWithPath("/application/beans"))
    .then()
        .statusCode(is(HttpStatus.SC_OK));
}
 
Example 9
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@BeforeClass
static public void setup() throws MalformedURLException {
    // set base URI and port number to use for all requests
    String serverUrl = System.getProperty("test.url");
    String protocol = DEFAULT_PROTOCOL;
    String host = DEFAULT_HOST;
    int port = DEFAULT_PORT;

    if (serverUrl != null) {
        URL url = new URL(serverUrl);
        protocol = url.getProtocol();
        host = url.getHost();
        port = (url.getPort() == -1) ? DEFAULT_PORT : url.getPort();
    }

    RestAssured.baseURI = protocol + "://" + host;
    RestAssured.port = port;

    // set user name and password to use for basic authentication for all requests
    String userName = System.getProperty("test.user");
    String password = System.getProperty("test.pwd");

    if (userName != null && password != null) {
        RestAssured.authentication = RestAssured.basic(userName, password);
        RestAssured.useRelaxedHTTPSValidation();
    }

    contextRoot = System.getProperty("context.root", "/optionalTCK");

    applicationPort = Integer.parseInt(System.getProperty("application.port", Integer.toString(port)));

}
 
Example 10
Source File: AuthenticationOnDeploymentTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
    RestAssured.useRelaxedHTTPSValidation();
    RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig());
    verifier = RequestVerifier.getInstance();
    verifier.clear();
}
 
Example 11
Source File: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
@Flaky
public void testUIEndpoints_whenProvidedBasicAuthentication() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    given()
        .auth().basic(username, password)
    .when()
        .get(getDiscoveryUriWithPath("/"))
    .then()
        .statusCode(is(HttpStatus.SC_OK));
}
 
Example 12
Source File: EurekaInstancesIntegrationTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
@Flaky
public void testUIEndpoints_whenProvidedToken() throws Exception {
    RestAssured.useRelaxedHTTPSValidation();
    String jwtToken = SecurityUtils.gatewayToken(username, password);
    given()
        .cookie(COOKIE, jwtToken)
    .when()
        .get(getDiscoveryUriWithPath("/"))
    .then()
        .statusCode(is(HttpStatus.SC_OK));
}
 
Example 13
Source File: LoginIntegrationTest.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    RestAssured.port = PORT;
    RestAssured.useRelaxedHTTPSValidation();
}
 
Example 14
Source File: DownloadApiIntegrationTest.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeAll
public static void beforeClass() {
    RestAssured.useRelaxedHTTPSValidation();
}
 
Example 15
Source File: EncodedCharactersTest.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeAll
public static void beforeClass() {
    RestAssured.useRelaxedHTTPSValidation();
}
 
Example 16
Source File: SslServerWithP12Test.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@BeforeAll
public static void setupRestAssured() {
    RestAssured.useRelaxedHTTPSValidation();
}
 
Example 17
Source File: ApiCatalogHttpHeadersIntegrationTest.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    RestAssured.useRelaxedHTTPSValidation();
}
 
Example 18
Source File: PassTicketTest.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    RestAssured.port = PORT;
    RestAssured.useRelaxedHTTPSValidation();
    RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
}
 
Example 19
Source File: GatewaySecurityTest.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    RestAssured.useRelaxedHTTPSValidation();
}
 
Example 20
Source File: SslServerWithPemTest.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@BeforeAll
public static void setupRestAssured() {
    RestAssured.useRelaxedHTTPSValidation();
}