use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Response in project cloudbreak by hortonworks.
the class AuditGetAction method action.
@Override
public AuditTestDto action(TestContext testContext, AuditTestDto testDto, CloudbreakClient client) throws Exception {
AuditEventV4Response response = client.getDefaultClient().auditV4Endpoint().getAuditEventById(client.getWorkspaceId(), testDto.getAuditId());
testDto.setResponse(response);
Log.whenJson(LOGGER, " Audit listed successfully:\n", testDto.getResponse());
return testDto;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Response in project cloudbreak by hortonworks.
the class AuditEventServiceTest method testGetAuditEventByWorkspaceIdWhenEventExistsAndHasPermissionToReadItThenTheExpectedEventShouldReturn.
@Test
public void testGetAuditEventByWorkspaceIdWhenEventExistsAndHasPermissionToReadItThenTheExpectedEventShouldReturn() {
AuditEventV4Response expected = mock(AuditEventV4Response.class);
StructuredEventEntity repoResult = new StructuredEventEntity();
when(structuredEventEntityToAuditEventV4ResponseConverter.convert(repoResult)).thenReturn(expected);
when(legacyStructuredEventDBService.findByWorkspaceIdAndId(TEST_DEFAULT_ORG_ID, TEST_AUDIT_ID)).thenReturn(repoResult);
AuditEventV4Response actual = underTest.getAuditEventByWorkspaceId(TEST_DEFAULT_ORG_ID, TEST_AUDIT_ID);
Assert.assertEquals(expected, actual);
verify(structuredEventEntityToAuditEventV4ResponseConverter, times(1)).convert(repoResult);
verify(legacyStructuredEventDBService, times(1)).findByWorkspaceIdAndId(TEST_DEFAULT_ORG_ID, TEST_AUDIT_ID);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Response in project cloudbreak by hortonworks.
the class AuditEventServiceTest method testGetAuditEventWhenEventExistsAndHasPermissionToReadItThenTheExpectedEventShouldReturn.
@Test
public void testGetAuditEventWhenEventExistsAndHasPermissionToReadItThenTheExpectedEventShouldReturn() {
AuditEventV4Response expected = mock(AuditEventV4Response.class);
StructuredEventEntity repoResult = new StructuredEventEntity();
when(structuredEventEntityToAuditEventV4ResponseConverter.convert(repoResult)).thenReturn(expected);
when(legacyStructuredEventDBService.findByWorkspaceIdAndId(TEST_DEFAULT_ORG_ID, TEST_AUDIT_ID)).thenReturn(repoResult);
AuditEventV4Response actual = underTest.getAuditEvent(TEST_AUDIT_ID);
Assert.assertEquals(expected, actual);
verify(structuredEventEntityToAuditEventV4ResponseConverter, times(1)).convert(repoResult);
verify(legacyStructuredEventDBService, times(1)).findByWorkspaceIdAndId(TEST_DEFAULT_ORG_ID, TEST_AUDIT_ID);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Response in project cloudbreak by hortonworks.
the class AuditEventV4Controller method getAuditEventsZipResponse.
private Response getAuditEventsZipResponse(Collection<AuditEventV4Response> auditEventV4Responses, String resourceType) {
StreamingOutput streamingOutput = output -> {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(output)) {
zipOutputStream.putNextEntry(new ZipEntry("struct-events.json"));
zipOutputStream.write(JsonUtil.writeValueAsString(auditEventV4Responses).getBytes());
zipOutputStream.closeEntry();
}
};
String fileName = String.format("audit-%s.zip", resourceType);
return Response.ok(streamingOutput).header("content-disposition", String.format("attachment; filename = %s", fileName)).build();
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Response in project cloudbreak by hortonworks.
the class AuditEventService method getAuditEventsByWorkspaceId.
public List<AuditEventV4Response> getAuditEventsByWorkspaceId(Long workspaceId, String resourceType, Long resourceId, String resourceCrn) {
User user = userService.getOrCreate(legacyRestRequestThreadLocalService.getCloudbreakUser());
Workspace workspace = getWorkspaceService().get(workspaceId, user);
List<AuditEventV4Response> auditEventV4Responses = getEventsForUserWithTypeAndResourceIdByWorkspace(workspace, resourceType, resourceId, resourceCrn);
auditEventV4Responses.sort(new AuditEventComparator().reversed());
return auditEventV4Responses;
}
Aggregations