use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.
the class NotificationMessageHandlerTest method an_event_about_changed_api_token_triggers_newApiTokenUserNotificationService.
@Test
public void an_event_about_changed_api_token_triggers_newApiTokenUserNotificationService() {
/* prepare */
UserMessage userMessage = mock(UserMessage.class);
DomainMessage request = mock(DomainMessage.class);
when(request.getMessageId()).thenReturn(MessageID.USER_API_TOKEN_CHANGED);
when(request.get(MessageDataKeys.USER_API_TOKEN_DATA)).thenReturn(userMessage);
/* execute */
handlerToTest.receiveAsyncMessage(request);
/* test */
verify(mockedNewAPITokenAppliedUserNotificationService).notify(userMessage);
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.
the class UserEmailAddressChangedNotificationServiceTest method sends_emails_to_former_and_new_mail_address_containing_expected_content.
@Test
void sends_emails_to_former_and_new_mail_address_containing_expected_content() {
/* prepare */
String emailAddress = "email.adress@example.org";
String formerEmailAddress = "former_email.adress@example.org";
UserMessage userMessage = new UserMessage();
userMessage.setEmailAdress(emailAddress);
userMessage.setFormerEmailAddress(formerEmailAddress);
userMessage.setSubject("Your mail adress has changed by a test");
SimpleMailMessage simpleMailmessageFormer = new SimpleMailMessage();
simpleMailmessageFormer.setSubject("<former>");
SimpleMailMessage simpleMailmessageNew = new SimpleMailMessage();
simpleMailmessageNew.setSubject("<new>");
when(mailMessageFactory.createMessage(EMAIL_SUBJECT_FORMER_ADDRESS)).thenReturn(simpleMailmessageFormer);
when(mailMessageFactory.createMessage(EMAIL_SUBJECT_NEW_ADDRESS)).thenReturn(simpleMailmessageNew);
/* execute */
serviceToTest.notify(userMessage);
/* test */
Mails mails = fetchSentMailsFromMockObjects(emailAddress, formerEmailAddress);
assertNotNull(mails.receivedNew);
assertNotNull(mails.receivedFormer);
assertNotSame(mails.receivedFormer, mails.receivedNew);
assertEquals("<former>", mails.receivedFormer.getSubject());
assertEquals("<new>", mails.receivedNew.getSubject());
/* @formatter:off */
String receivedFormerText = mails.receivedFormer.getText();
String receivedNewText = mails.receivedNew.getText();
assertEquals("Your mail adress has changed by a test and it will not be used any longer for SecHub.\n" + "\n" + "In case you do not receive a follow up notification to the new email address, please inform your SecHub administrator!", receivedFormerText);
assertEquals("Your mail adress has changed by a test from former_email.adress@example.org to email.adress@example.org. \n" + "Your old email address is not used in SecHub any longer.", receivedNewText);
/* @formatter:on */
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.
the class ScanMessageHandler method handleUserAddedToProject.
@IsReceivingAsyncMessage(MessageID.USER_ADDED_TO_PROJECT)
private void handleUserAddedToProject(DomainMessage request) {
UserMessage data = request.get(MessageDataKeys.PROJECT_TO_USER_DATA);
grantService.grantUserAccessToProject(data.getUserId(), data.getProjectId());
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.
the class ScheduleMessageHandlerTest method when_sending_message_id_USER_ADDED_TO_PROJECT_the_addUserToProjectService_is_called.
@Test
void when_sending_message_id_USER_ADDED_TO_PROJECT_the_addUserToProjectService_is_called() {
/* prepare */
DomainMessage request = new DomainMessage(MessageID.USER_ADDED_TO_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.grantService).grantUserAccessToProject("userId1", "projectId1");
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.
the class SignupCreateServiceTest method a_created_signup_sends_event_containing_userid_and_email.
@Test
public void a_created_signup_sends_event_containing_userid_and_email() {
/* prepare */
SignupJsonInput userSelfRegistrationInput = mock(SignupJsonInput.class);
when(userSelfRegistrationInput.getUserId()).thenReturn("schlaubi");
when(userSelfRegistrationInput.getEmailAdress()).thenReturn("schlaubi@schlumpfhausen.de");
/* execute */
serviceToTest.register(userSelfRegistrationInput);
/* test */
ArgumentCaptor<DomainMessage> domainMessageCaptor = ArgumentCaptor.forClass(DomainMessage.class);
verify(mockedEventBusService).sendAsynchron(domainMessageCaptor.capture());
DomainMessage messageSendByService = domainMessageCaptor.getValue();
assertNotNull("no message send!", messageSendByService);
UserMessage signupDataInMessage = messageSendByService.get(MessageDataKeys.USER_SIGNUP_DATA);
assertNotNull("no signup data inside message!", signupDataInMessage);
// check event contains expected data
assertEquals("schlaubi", signupDataInMessage.getUserId());
assertEquals("schlaubi@schlumpfhausen.de", signupDataInMessage.getEmailAdress());
}
Aggregations