use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class ScheduleMessageHandlerTest method handler_receiving_auto_cleanup_calls_config_serice_with_message_data.
@Test
void handler_receiving_auto_cleanup_calls_config_serice_with_message_data() {
/* prepare */
long days = System.nanoTime();
AdministrationConfigMessage configMessage = new AdministrationConfigMessage();
configMessage.setAutoCleanupInDays(days);
DomainMessage message = new DomainMessage(MessageID.AUTO_CLEANUP_CONFIGURATION_CHANGED);
message.set(MessageDataKeys.AUTO_CLEANUP_CONFIG_CHANGE_DATA, configMessage);
/* execute */
scheduleHandlerToTest.receiveAsyncMessage(message);
/* test */
verify(scheduleHandlerToTest.configService).updateAutoCleanupInDays(days);
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class ScheduleMessageHandlerTest method when_sending_message_id_USER_DELETED_the_revokeUserService_is_called.
@Test
void when_sending_message_id_USER_DELETED_the_revokeUserService_is_called() {
/* prepare */
DomainMessage request = new DomainMessage(MessageID.USER_DELETED);
UserMessage content = new UserMessage();
content.setUserId("userId1");
request.set(MessageDataKeys.USER_DELETE_DATA, content);
/* execute */
simulateEventSend(request, scheduleHandlerToTest);
/* test */
verify(scheduleHandlerToTest.revokeUserService).revokeUserAccess("userId1");
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class ScheduleMessageHandlerTest method when_sending_message_id_USER_REMOVED_FROM_PROJECT_the_revokeUserFromProjectService_is_called.
@Test
void when_sending_message_id_USER_REMOVED_FROM_PROJECT_the_revokeUserFromProjectService_is_called() {
/* prepare */
DomainMessage request = new DomainMessage(MessageID.USER_REMOVED_FROM_PROJECT);
UserMessage content = new UserMessage();
content.setProjectId("projectId1");
content.setUserId("userId1");
request.set(MessageDataKeys.PROJECT_TO_USER_DATA, content);
/* execute */
simulateEventSend(request, scheduleHandlerToTest);
/* test */
verify(scheduleHandlerToTest.revokeUserFromProjectService).revokeUserAccessFromProject("userId1", "projectId1");
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class SynchronSecHubJobExecutor method execute.
@IsSendingSyncMessage(MessageID.START_SCAN)
public void execute(final ScheduleSecHubJob secHubJob, final Long batchJobId) {
Thread scanThread = new Thread(new Runnable() {
@Override
public void run() {
UUID secHubJobUUID = secHubJob.getUUID();
String secHubJobUUIDAsString = secHubJobUUID.toString();
try {
String secHubConfiguration = secHubJob.getJsonConfiguration();
/* own thread so MDC.put necessary */
MDC.clear();
MDC.put(LogConstants.MDC_SECHUB_JOB_UUID, secHubJobUUIDAsString);
MDC.put(LogConstants.MDC_SECHUB_PROJECT_ID, secHubJob.getProjectId());
LOG.info("Executing sechub job: {}", secHubJobUUIDAsString);
/* we send no a synchronous SCAN event */
DomainMessage request = new DomainMessage(MessageID.START_SCAN);
request.set(MessageDataKeys.EXECUTED_BY, secHubJob.getOwner());
request.set(MessageDataKeys.SECHUB_UUID, secHubJobUUID);
request.set(MessageDataKeys.SECHUB_CONFIG, MessageDataKeys.SECHUB_CONFIG.getProvider().get(secHubConfiguration));
BatchJobMessage batchJobIdMessage = new BatchJobMessage();
batchJobIdMessage.setBatchJobId(batchJobId);
batchJobIdMessage.setSecHubJobUUID(secHubJobUUID);
request.set(MessageDataKeys.BATCH_JOB_ID, batchJobIdMessage);
/* wait for scan event result - synchron */
DomainMessageSynchronousResult response = messageService.sendSynchron(request);
updateSecHubJob(secHubJobUUID, response);
sendJobDoneMessageWhenNotAbandonded(secHubJobUUID, response);
} catch (Exception e) {
LOG.error("Error happend at spring batch task execution:" + e.getMessage(), e);
markSechHubJobFailed(secHubJobUUID);
sendJobFailed(secHubJobUUID);
} finally {
/* cleanup MDC */
MDC.clear();
}
}
}, "scan_" + secHubJob.getUUID());
scanThread.start();
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class SynchronSecHubJobExecutor method sendJobInfo.
private void sendJobInfo(MessageDataKey<JobMessage> key, UUID jobUUID, MessageID id) {
DomainMessage request = new DomainMessage(id);
JobMessage message = createMessage(jobUUID);
request.set(key, message);
messageService.sendAsynchron(request);
}
Aggregations