Search in sources :

Example 6 with EndpointInfo

use of com.hw.helper.EndpointInfo in project mt-auth by publicdevop2019.

the class EndpointTest method create_new_endpoint_then_delete.

@Test
public void create_new_endpoint_then_delete() {
    EndpointInfo endpointInfo1 = new EndpointInfo();
    endpointInfo1.setResourceId("0C8AZTODP4HT");
    endpointInfo1.setUserRoles(new HashSet<>(List.of("ROLE_ADMIN")));
    endpointInfo1.setUserOnly(true);
    endpointInfo1.setName("test");
    endpointInfo1.setMethod("GET");
    endpointInfo1.setWebsocket(false);
    endpointInfo1.setPath("/test/" + UUID.randomUUID().toString().replace("-", "").replaceAll("\\d", "") + "/abc");
    ResponseEntity<String> profile = createProfile(endpointInfo1);
    Assert.assertEquals(HttpStatus.OK, profile.getStatusCode());
    ResponseEntity<String> stringResponseEntity = deleteProfile(profile.getHeaders().getLocation().toString());
    Assert.assertEquals(HttpStatus.OK, stringResponseEntity.getStatusCode());
}
Also used : EndpointInfo(com.hw.helper.EndpointInfo) Test(org.junit.Test)

Example 7 with EndpointInfo

use of com.hw.helper.EndpointInfo in project mt-auth by publicdevop2019.

the class GatewayFilterTest method should_sanitize_request_json.

@Test
// move this feature to individual application level
@Ignore
public void should_sanitize_request_json() {
    EndpointInfo endpointInfo1 = new EndpointInfo();
    endpointInfo1.setResourceId("0C8AZTODP4HT");
    endpointInfo1.setSecured(false);
    endpointInfo1.setMethod("GET");
    endpointInfo1.setName("Test");
    endpointInfo1.setDescription("<script>test</script>");
    endpointInfo1.setPath("/test/" + UUID.randomUUID().toString().replace("-", "").replaceAll("\\d", "") + "/abc");
    ResponseEntity<String> profile = createProfile(endpointInfo1);
    String s = profile.getHeaders().getLocation().toString();
    Assert.assertEquals(HttpStatus.OK, profile.getStatusCode());
    ResponseEntity<EndpointInfo> securityProfileResponseEntity = readProfile(s);
    Assert.assertEquals("&lt;script&gt;test&lt;/script&gt;", securityProfileResponseEntity.getBody().getDescription());
}
Also used : EndpointInfo(com.hw.helper.EndpointInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

EndpointInfo (com.hw.helper.EndpointInfo)7 HttpEntity (org.springframework.http.HttpEntity)5 HttpHeaders (org.springframework.http.HttpHeaders)5 Test (org.junit.Test)3 Ignore (org.junit.Ignore)2 SumTotal (com.hw.helper.SumTotal)1