Java Code Examples for io.restassured.RestAssured#config()
The following examples show how to use
io.restassured.RestAssured#config() .
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: PassTicketTest.java From api-layer with Eclipse Public License 2.0 | 7 votes |
@Test public void doTicketWithoutToken() { String expectedMessage = "No authorization token provided for URL '" + TICKET_ENDPOINT + "'"; RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); TicketRequest ticketRequest = new TicketRequest(APPLICATION_NAME); given() .contentType(JSON) .body(ticketRequest) .when() .post(String.format("%s://%s:%d%s", SCHEME, HOST, PORT, TICKET_ENDPOINT)) .then() .statusCode(is(SC_UNAUTHORIZED)) .body("messages.find { it.messageNumber == 'ZWEAG131E' }.messageContent", equalTo(expectedMessage)); }
Example 2
Source File: PassTicketTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test @TestsNotMeantForZowe public void doTicketWithInvalidApplicationName() { String expectedMessage = "The generation of the PassTicket failed. Reason: Unable to generate PassTicket. Verify that the secured signon (PassTicket) function and application ID is configured properly by referring to Using PassTickets in z/OS Security Server RACF Security Administrator's Guide."; RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); String jwt = gatewayToken(); TicketRequest ticketRequest = new TicketRequest(UNKNOWN_APPLID); given() .contentType(JSON) .body(ticketRequest) .cookie(COOKIE, jwt) .when() .post(String.format("%s://%s:%d%s", SCHEME, HOST, PORT, TICKET_ENDPOINT)) .then() .statusCode(is(SC_BAD_REQUEST)) .body("messages.find { it.messageNumber == 'ZWEAG141E' }.messageContent", equalTo(expectedMessage)); }
Example 3
Source File: EurekaInstancesIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@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 4
Source File: PassTicketTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void doTicketWithInvalidCookie() { String jwt = "invalidToken"; String expectedMessage = "Token is not valid for URL '" + TICKET_ENDPOINT + "'"; RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); TicketRequest ticketRequest = new TicketRequest(APPLICATION_NAME); given() .contentType(JSON) .body(ticketRequest) .cookie(COOKIE, jwt) .when() .post(String.format("%s://%s:%d%s", SCHEME, HOST, PORT, TICKET_ENDPOINT)) .then() .statusCode(is(SC_UNAUTHORIZED)) .body("messages.find { it.messageNumber == 'ZWEAG130E' }.messageContent", equalTo(expectedMessage)); }
Example 5
Source File: ApiCatalogSecurityIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void accessProtectedEndpointWithInvalidCookieCatalog() { String expectedMessage = "Token is not valid for URL '" + CATALOG_SERVICE_ID + endpoint + "'"; String invalidToken = "nonsense"; RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); String catalogUrl = DiscoveryUtils.getInstances("APICATALOG").get(0).getUrl(); given() .cookie(COOKIE, invalidToken) .when() .get(String.format("%s%s%s", catalogUrl, CATALOG_SERVICE_ID, endpoint)) .then() .statusCode(is(SC_UNAUTHORIZED)) .body("messages.find { it.messageNumber == 'ZWEAS130E' }.messageContent", equalTo(expectedMessage)); }
Example 6
Source File: PassTicketTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test public void doTicketWithInvalidMethod() { String expectedMessage = "Authentication method 'GET' is not supported for URL '" + TICKET_ENDPOINT + "'"; RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); TicketRequest ticketRequest = new TicketRequest(APPLICATION_NAME); given() .contentType(JSON) .body(ticketRequest) .when() .get(String.format("%s://%s:%d%s", SCHEME, HOST, PORT, TICKET_ENDPOINT)) .then() .statusCode(is(SC_METHOD_NOT_ALLOWED)) .body("messages.find { it.messageNumber == 'ZWEAG101E' }.messageContent", equalTo(expectedMessage)); }
Example 7
Source File: PassTicketTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test @TestsNotMeantForZowe public void doTicketWithValidHeaderAndCertificate() { RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); String jwt = gatewayToken(); TicketRequest ticketRequest = new TicketRequest(APPLICATION_NAME); //Generate ticket TicketResponse ticketResponse = given() .contentType(JSON) .body(ticketRequest) .header("Authorization", "Bearer " + jwt) .when() .post(String.format("%s://%s:%d%s", SCHEME, HOST, PORT, TICKET_ENDPOINT)) .then() .statusCode(is(SC_OK)) .extract().body().as(TicketResponse.class); assertEquals(jwt, ticketResponse.getToken()); assertEquals(USERNAME, ticketResponse.getUserId()); assertEquals(APPLICATION_NAME, ticketResponse.getApplicationName()); // Validate ticket given() .auth().preemptive().basic(USERNAME, ticketResponse.getTicket()) .param("appliId", APPLICATION_NAME) .when() .get(String.format("%s://%s:%d%s%s", SCHEME, HOST, PORT, DISCOVERABLECLIENT_BASE_PATH, PASSTICKET_TEST_ENDPOINT)) .then() .statusCode(is(SC_OK)); }
Example 8
Source File: PageRedirectionTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
/** * Initiate Discoverable Client properties, such as host, port, scheme * * @throws URISyntaxException */ private void initDiscoverableClientProperties() throws URISyntaxException { DiscoveryServiceConfiguration discoveryServiceConfiguration = ConfigReader.environmentConfiguration().getDiscoveryServiceConfiguration(); final String scheme = discoveryServiceConfiguration.getScheme(); final String username = discoveryServiceConfiguration.getUser(); final String password = discoveryServiceConfiguration.getPassword(); final String host = discoveryServiceConfiguration.getHost(); final int port = discoveryServiceConfiguration.getPort(); URI uri = new URIBuilder().setScheme(scheme).setHost(host).setPort(port).setPath(EUREKA_APP).build(); RestAssured.config = RestAssured.config().sslConfig(SecurityUtils.getConfiguredSslConfig()); String xml = given() .auth().basic(username, password) .when() .get(uri) .then() .statusCode(is(200)) .extract().body().asString(); Node staticclientNode = XmlPath.from(xml).get("applications.application.find {it.name == 'STATICCLIENT'}"); Node instanceNode = staticclientNode.children().get("instance"); dcHost = instanceNode.children().get("hostName").toString(); Node securePortNode = instanceNode.children().get("securePort"); if (securePortNode.getAttribute("enabled").equalsIgnoreCase("true")) { dcScheme = "https"; dcPort = Integer.parseInt(securePortNode.value()); } else { dcScheme = "http"; dcPort = Integer.parseInt(instanceNode.children().get("port").toString()); } }
Example 9
Source File: AuthenticationOnDeploymentTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@BeforeEach public void setUp() { RestAssured.useRelaxedHTTPSValidation(); RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); verifier = RequestVerifier.getInstance(); verifier.clear(); }
Example 10
Source File: PassTicketTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void doTicketWithoutApplicationName() { String expectedMessage = "The 'applicationName' parameter name is missing."; RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); String jwt = gatewayToken(); given() .cookie(COOKIE, jwt) .when() .post(String.format("%s://%s:%d%s", SCHEME, HOST, PORT, TICKET_ENDPOINT)) .then() .statusCode(is(SC_BAD_REQUEST)) .body("messages.find { it.messageNumber == 'ZWEAG140E' }.messageContent", equalTo(expectedMessage)); }
Example 11
Source File: RequestInfoIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@ParameterizedTest(name = "call endpoint {1} to receive json with signed = {2} : {0}") @MethodSource("getInputs") public void testRequestInfo(String description, String url, Boolean signed) { if (signed) { RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); } given() .when() .get(url) .then() .statusCode(SC_OK) .body("signed", equalTo(signed)); }
Example 12
Source File: JLineupWebApplicationTests.java From jlineup with Apache License 2.0 | 5 votes |
@Before public void setUp() { RestAssured.port = port; RestAssured.config = RestAssuredConfig.config().objectMapperConfig(new ObjectMapperConfig().jackson2ObjectMapperFactory( (cls, charset) -> objectMapper )); }
Example 13
Source File: PassTicketTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test @TestsNotMeantForZowe public void doTicketWithValidCookieAndCertificate() { RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); String jwt = gatewayToken(); log.info(APPLICATION_NAME); TicketRequest ticketRequest = new TicketRequest(APPLICATION_NAME); // Generate ticket TicketResponse ticketResponse = given() .contentType(JSON) .body(ticketRequest) .cookie(COOKIE, jwt) .when() .post(String.format("%s://%s:%d%s", SCHEME, HOST, PORT, TICKET_ENDPOINT)) .then() .statusCode(is(SC_OK)) .extract().body().as(TicketResponse.class); assertEquals(jwt, ticketResponse.getToken()); assertEquals(USERNAME, ticketResponse.getUserId()); assertEquals(APPLICATION_NAME, ticketResponse.getApplicationName()); // Validate ticket given() .auth().preemptive().basic(USERNAME, ticketResponse.getTicket()) .param("appliId", APPLICATION_NAME) .when() .get(String.format("%s://%s:%d%s%s", SCHEME, HOST, PORT, DISCOVERABLECLIENT_BASE_PATH, PASSTICKET_TEST_ENDPOINT)) .then() .statusCode(is(SC_OK)); }
Example 14
Source File: ZosmfAuthenticationTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@BeforeEach public void setUp() { RestAssured.useRelaxedHTTPSValidation(); RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); // unregister current z/OSMF DiscoveryUtils.getDiscoveryUrls().forEach(ds -> DiscoveryUtils.getInstances(ZOSMF_ID).forEach(zosmf -> { given().when() .delete(ds + "/eureka/apps/{appId}/{instanceId}", zosmf.getApp(), zosmf.getInstanceId()) .then().statusCode(SC_OK); }) ); }
Example 15
Source File: RequestInfoIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
public static Stream<Arguments> getInputs() { RestAssured.useRelaxedHTTPSValidation(); RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); return Stream.of( Arguments.of("call DiscoverableClient with sign", getUrl(), Boolean.TRUE), Arguments.of("call DiscoverableClient without sign", getUrl(), Boolean.FALSE), Arguments.of("call DiscoverableClient through Gateway with sign", getGatewayUrl(), Boolean.TRUE), Arguments.of("call DiscoverableClient through Gateway without sign", getGatewayUrl(), Boolean.FALSE) ); }
Example 16
Source File: EurekaInstancesIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void testDiscoveryEndpoints_whenProvidedCertification() throws Exception { RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); given() .when() .get(getDiscoveryUriWithPath("/discovery/api/v1/staticApi")) .then() .statusCode(is(HttpStatus.SC_OK)); }
Example 17
Source File: EurekaInstancesIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@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 18
Source File: EurekaInstancesIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test public void testEurekaEndpoints_whenProvidedCertificate() throws Exception { RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); given() .when() .get(getDiscoveryUriWithPath("/eureka/apps")) .then() .statusCode(is(HttpStatus.SC_OK)); }
Example 19
Source File: LiveTest.java From tutorials with MIT License | 4 votes |
@Before public void setup() { RestAssured.config = config().redirect(RedirectConfig.redirectConfig() .followRedirects(false)); }
Example 20
Source File: LogoutTest.java From api-layer with Eclipse Public License 2.0 | 4 votes |
@BeforeEach public void setUp() { RestAssured.useRelaxedHTTPSValidation(); RestAssured.config = RestAssured.config().sslConfig(getConfiguredSslConfig()); }