use of io.restassured.response.Response in project SSM by Intel-bigdata.
the class CmdletRestApi method getCmdletInfo.
public static JsonPath getCmdletInfo(long cmdletId) {
Response cmdletInfo = RestAssured.get(CMDLETROOT + "/" + cmdletId + "/info");
cmdletInfo.then().body("status", Matchers.equalTo("OK"));
JsonPath path = cmdletInfo.jsonPath().setRoot("body");
return path;
}
use of io.restassured.response.Response in project SSM by Intel-bigdata.
the class TestSystemRestApi method testVersion.
@Test
public void testVersion() throws Exception {
Response response1 = RestAssured.get(RestApiBase.SYSTEMROOT + "/version");
String json1 = response1.asString();
response1.then().body("body", Matchers.equalTo("1.6.0-SNAPSHOT"));
}
use of io.restassured.response.Response in project SSM by Intel-bigdata.
the class TestClusterRestApi method testPrimary.
@Test
public void testPrimary() {
Response response = RestAssured.get(RestApiBase.PRIMCLUSTERROOT);
String json = response.asString();
response.then().body("message", Matchers.equalTo("Namenode URL"));
response.then().body("body", Matchers.containsString("localhost"));
}
use of io.restassured.response.Response in project ddf by codice.
the class TestOidc method testLogout.
// --------------------------Logout Tests--------------------------//
@Test
public void testLogout() throws Exception {
String jsessionidValue = login();
// Send initial request to get OIDC logout url
Response initialLogoutResponse = given().cookie(JSESSIONID, jsessionidValue).header(USER_AGENT, BROWSER_USER_AGENT).header("Referer", ROOT_URL + "?client_name=" + DDF_CLIENT_ID).header(HOST, "localhost:" + HTTPS_PORT.getPort()).header("X-Requested-With", "XMLHttpRequest").redirects().follow(false).expect().statusCode(200).when().get(LOGOUT_REQUEST_URL.getUrl());
// Get and verify the logout url from body
String body = initialLogoutResponse.getBody().prettyPrint();
Map<String, String> oidcLogoutProperties = GSON.fromJson(body, Map.class);
assertThat(oidcLogoutProperties.get("auth"), is(ADMIN));
URI logoutUri = new URI(oidcLogoutProperties.get("url"));
assertThat(logoutUri.getPath(), is("/auth/admin/master/protocol/openid-connect/logout"));
Map<String, String> requestParams = URLEncodedUtils.parse(logoutUri, StandardCharsets.UTF_8).stream().collect(Collectors.toMap(NameValuePair::getName, NameValuePair::getValue));
assertTrue(requestParams.containsKey("id_token_hint"));
assertTrue(requestParams.containsKey("post_logout_redirect_uri"));
assertThat(requestParams.get("post_logout_redirect_uri"), is(LOGOUT_URL.getUrl()));
// send response keycloak would have sent after logging out user
Response logoutResponse = given().cookie(JSESSIONID, jsessionidValue).header(USER_AGENT, BROWSER_USER_AGENT).header(HOST, "localhost:" + HTTPS_PORT.getPort()).redirects().follow(false).expect().statusCode(303).when().get(requestParams.get("post_logout_redirect_uri"));
String location = logoutResponse.header(LOCATION);
assertThat(location, is(SECURE_ROOT + HTTPS_PORT.getPort() + "/logout/logout-response.html"));
// Verify that we're not logged in
Map<String, Object> userInfoList = getUserInfo(jsessionidValue);
assertThat(userInfoList.get("isGuest"), is(true));
}
use of io.restassured.response.Response in project ddf by codice.
the class TestOidc method processCredentialFlow.
/**
* Processes a credential flow request/response
*
* <ul>
* <li>Sets up a userinfo endpoint that responds with the given {@param userInfoResponse} when
* given {@param accessToken}
* <li>Sends a request to Intrigue with the {@param accessToken} as a parameter
* <li>Asserts that the response is teh expected response
* <li>Verifies if the userinfo endpoint is hit or not
* </ul>
*
* @return the response for additional verification
*/
private Response processCredentialFlow(String accessToken, String userInfoResponse, boolean isSigned, int expectedStatusCode, boolean userInfoShouldBeHit) {
// Host the user info endpoint with the access token in the auth header
String basicAuthHeader = "Bearer " + accessToken;
String contentType = isSigned ? "application/jwt" : APPLICATION_JSON;
whenHttp(server).match(get(USER_INFO_ENDPOINT_PATH), withHeader(AUTHORIZATION, basicAuthHeader)).then(ok(), contentType(contentType), bytesContent(userInfoResponse.getBytes()));
// Send a request to DDF with the access token
Response response = given().redirects().follow(false).expect().statusCode(expectedStatusCode).when().get(ROOT_URL.getUrl() + "?access_token=" + accessToken);
List<Call> endpointCalls = server.getCalls().stream().filter(call -> call.getMethod().getMethodString().equals(GET)).filter(call -> call.getUrl().equals(URL_START + USER_INFO_ENDPOINT_PATH)).collect(Collectors.toList());
if (userInfoShouldBeHit) {
assertThat(endpointCalls.size(), is(greaterThanOrEqualTo(1)));
} else {
assertThat(endpointCalls.size(), is(0));
}
return response;
}
Aggregations