use of com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails in project cloudbreak by hortonworks.
the class LegacyKafkaStructuredEventHandler method sanitizeSensitiveRestData.
protected void sanitizeSensitiveRestData(StructuredEvent event) {
if ("StructuredRestCallEvent".equals(event.getType())) {
StructuredRestCallEvent restEvent = (StructuredRestCallEvent) event;
RestRequestDetails restRequestDetails = restEvent.getRestCall().getRestRequest();
restRequestDetails.setBody(REPLACEMENT);
restRequestDetails.setHeaders(new HashMap());
RestResponseDetails restResponseDetails = restEvent.getRestCall().getRestResponse();
restResponseDetails.setBody(REPLACEMENT);
restResponseDetails.setHeaders(new HashMap<>());
}
}
use of com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails in project cloudbreak by hortonworks.
the class CDPRestCommonServiceTest method testWhenNameAndResourceCrnComeFromTheResponsesValue.
@Test
public void testWhenNameAndResourceCrnComeFromTheResponsesValue() {
RestCallDetails restCallDetails = new RestCallDetails();
RestRequestDetails request = new RestRequestDetails();
RestResponseDetails response = new RestResponseDetails();
response.setBody(new Json(Map.of("responses", List.of(Map.of("name", "name1", "crn", "crn1"), Map.of("name", "name2", "crn", "crn2")))).getValue());
restCallDetails.setRestRequest(request);
restCallDetails.setRestResponse(response);
Map<String, Object> expected = new HashMap<>();
expected.put("names", "name1,name2");
expected.put("crns", "crn1,crn2");
Map<String, String> actual = underTest.collectCrnAndNameIfPresent(restCallDetails, null, Collections.emptyMap(), "names", "crns");
assertEquals(expected, actual);
}
use of com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails in project cloudbreak by hortonworks.
the class CDPRestCommonServiceTest method testWhenNamesAndCrnAreList.
@Test
public void testWhenNamesAndCrnAreList() {
RestCallDetails restCallDetails = new RestCallDetails();
RestRequestDetails request = new RestRequestDetails();
request.setBody(new Json(Map.of("names", List.of("names1", "names2"), "crns", List.of("crns1", "crns2"))).getValue());
RestResponseDetails response = new RestResponseDetails();
restCallDetails.setRestRequest(request);
restCallDetails.setRestResponse(response);
Map<String, Object> expected = new HashMap<>();
expected.put(CLUSTER_NAME, "names1,names2");
expected.put(CLUSTER_CRN, "crns1,crns2");
Map<String, String> actual = underTest.collectCrnAndNameIfPresent(restCallDetails, null, Collections.emptyMap(), CLUSTER_NAME, CLUSTER_CRN);
assertEquals(expected, actual);
}
use of com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails in project cloudbreak by hortonworks.
the class CDPRestCommonServiceTest method testWhenNameAndResourceCrnNotExists.
@Test
public void testWhenNameAndResourceCrnNotExists() {
RestCallDetails restCallDetails = new RestCallDetails();
RestRequestDetails request = new RestRequestDetails();
request.setMethod("POST");
request.setRequestUri("uri");
RestResponseDetails response = new RestResponseDetails();
restCallDetails.setRestRequest(request);
restCallDetails.setRestResponse(response);
UnsupportedOperationException exception = assertThrows(UnsupportedOperationException.class, () -> underTest.collectCrnAndNameIfPresent(restCallDetails, null, Collections.emptyMap(), CLUSTER_NAME, CLUSTER_CRN));
assertEquals(exception.getMessage(), "Cannot determine the resource crn or name, so we does not support for auditing for method: " + "POST, uri: uri, body: null");
}
use of com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails in project cloudbreak by hortonworks.
the class CDPRestCommonServiceTest method testWhenNameAndResourceCrnComeFromTheRequestBodyButExistInResponse.
@Test
public void testWhenNameAndResourceCrnComeFromTheRequestBodyButExistInResponse() {
RestCallDetails restCallDetails = new RestCallDetails();
RestRequestDetails request = new RestRequestDetails();
request.setBody(new Json(Map.of("name", "name2", "resourceCrn", "crn2")).getValue());
RestResponseDetails response = new RestResponseDetails();
response.setBody(new Json(Map.of("name", "name3", "resourceCrn", "crn3")).getValue());
restCallDetails.setRestRequest(request);
restCallDetails.setRestResponse(response);
Map<String, Object> expected = new HashMap<>();
expected.put(CLUSTER_NAME, "name2");
expected.put(CLUSTER_CRN, "crn2");
Map<String, String> actual = underTest.collectCrnAndNameIfPresent(restCallDetails, null, Collections.emptyMap(), CLUSTER_NAME, CLUSTER_CRN);
assertEquals(expected, actual);
}
Aggregations