use of com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest in project cia by Hack23.
the class AbstractServiceFunctionalIntegrationTest method configureMailServer.
/**
* Configure mail server.
*
* @param createTestApplicationSession
* the create test application session
* @return the simple smtp server
* @throws IOException
* Signals that an I/O exception has occurred.
*/
protected final SimpleSmtpServer configureMailServer(CreateApplicationSessionRequest createTestApplicationSession) throws IOException {
final SimpleSmtpServer dumbster = SimpleSmtpServer.start(SimpleSmtpServer.AUTO_SMTP_PORT);
setAuthenticatedAdminuser();
createTestApplicationSession = createTestApplicationSession();
final ApplicationConfiguration sendEmail = applicationConfigurationService.checkValueOrLoadDefault("Email configuration send emails", "Send email", ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), "Send email", "Responsible for sending email", "application.email.send.email", "false");
final ApplicationConfiguration smtpPort = applicationConfigurationService.checkValueOrLoadDefault("Email configuration smtp port", "Smtp port", ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), "Smtp port", "Responsible for sending email", "application.email.smtp.port", "587");
final ApplicationConfiguration smtpHost = applicationConfigurationService.checkValueOrLoadDefault("Email configuration smtp host", "Smtp host", ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), "Smtp host", "Responsible for sending email", "application.email.smtp.host", "localhost");
updateApplicationConfiguration(createTestApplicationSession, sendEmail, "true");
updateApplicationConfiguration(createTestApplicationSession, smtpPort, Integer.toString(dumbster.getPort()));
updateApplicationConfiguration(createTestApplicationSession, smtpHost, "localhost");
return dumbster;
}
use of com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest in project cia by Hack23.
the class CreateApplicationSessionService method processService.
@Secured({ "ROLE_ANONYMOUS" })
@Override
public CreateApplicationSessionResponse processService(final CreateApplicationSessionRequest serviceRequest) {
final ApplicationSession applicationSession = new ApplicationSession();
applicationSession.setCreatedDate(new Date());
applicationSession.setSessionId(serviceRequest.getSessionId());
applicationSession.setIpInformation(serviceRequest.getIpInformation());
applicationSession.setLocale(serviceRequest.getLocale());
applicationSession.setTimeZone(serviceRequest.getTimeZone());
applicationSession.setScreenSize(serviceRequest.getScreenSize());
applicationSession.setOperatingSystem(serviceRequest.getOperatingSystem());
applicationSession.setUserAgentInformation(serviceRequest.getUserAgentInformation());
applicationSession.setSessionType(serviceRequest.getSessionType());
applicationSession.setEvents(new ArrayList<>());
applicationSession.setSessionType(ApplicationSessionType.ANONYMOUS);
applicationSessionDAO.persist(applicationSession);
LOGGER.info("Create application session:{}", applicationSession);
return new CreateApplicationSessionResponse(ServiceResult.SUCCESS);
}
use of com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest in project cia by Hack23.
the class AbstractServiceFunctionalIntegrationTest method restoreMailConfiguration.
/**
* Restore mail configuration.
*
* @param createTestApplicationSession
* the create test application session
* @param dumbster
* the dumbster
*/
protected final void restoreMailConfiguration(final CreateApplicationSessionRequest createTestApplicationSession, final SimpleSmtpServer dumbster) {
final ApplicationConfiguration sendEmail = applicationConfigurationService.checkValueOrLoadDefault("Email configuration send emails", "Send email", ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), "Send email", "Responsible for sending email", "application.email.send.email", "false");
final ApplicationConfiguration smtpPort = applicationConfigurationService.checkValueOrLoadDefault("Email configuration smtp port", "Smtp port", ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), "Smtp port", "Responsible for sending email", "application.email.smtp.port", "587");
updateApplicationConfiguration(createTestApplicationSession, sendEmail, "false");
updateApplicationConfiguration(createTestApplicationSession, smtpPort, "587");
dumbster.stop();
}
use of com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest in project cia by Hack23.
the class AbstractServiceFunctionalIntegrationTest method updateApplicationConfiguration.
/**
* Update application configuration.
*
* @param createTestApplicationSession
* the create test application session
* @param applicationConfiguration
* the application configuration
* @param propertyValue
* the property value
*/
private void updateApplicationConfiguration(final CreateApplicationSessionRequest createTestApplicationSession, final ApplicationConfiguration applicationConfiguration, final String propertyValue) {
final UpdateApplicationConfigurationRequest serviceRequest = new UpdateApplicationConfigurationRequest();
serviceRequest.setApplicationConfigurationId(applicationConfiguration.getHjid());
serviceRequest.setSessionId(createTestApplicationSession.getSessionId());
serviceRequest.setComponentDescription(applicationConfiguration.getComponentDescription());
serviceRequest.setConfigDescription(applicationConfiguration.getConfigDescription());
serviceRequest.setConfigTitle(applicationConfiguration.getConfigTitle());
serviceRequest.setComponentTitle(applicationConfiguration.getComponentTitle());
serviceRequest.setPropertyValue(propertyValue);
final UpdateApplicationConfigurationResponse response = (UpdateApplicationConfigurationResponse) applicationManager.service(serviceRequest);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
}
use of com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest in project cia by Hack23.
the class ManageUserAccountServiceITest method manageUserAccountSuccessLockTest.
@Test
public void manageUserAccountSuccessLockTest() throws Exception {
setAuthenticatedAnonymousUser();
final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
final RegisterUserRequest createAccountRequest = new RegisterUserRequest();
createAccountRequest.setCountry("Sweden");
createAccountRequest.setUsername(UUID.randomUUID().toString());
createAccountRequest.setEmail(createAccountRequest.getUsername() + "@email.com");
createAccountRequest.setUserpassword("Userpassword1!");
createAccountRequest.setUserType(UserType.PRIVATE);
createAccountRequest.setSessionId(createSessionRequest.getSessionId());
final RegisterUserResponse response = (RegisterUserResponse) applicationManager.service(createAccountRequest);
assertNotNull("Expect a result", response);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
setAuthenticatedAdminuser();
final DataContainer<UserAccount, Long> userContainer = applicationManager.getDataContainer(UserAccount.class);
final List<UserAccount> firstCreatedUsed = userContainer.getAllBy(UserAccount_.username, createAccountRequest.getUsername());
assertEquals(1, firstCreatedUsed.size());
final ManageUserAccountRequest deleteAccountRequest = new ManageUserAccountRequest();
deleteAccountRequest.setSessionId(createSessionRequest.getSessionId());
deleteAccountRequest.setAccountOperation(AccountOperation.LOCK);
deleteAccountRequest.setUserAcountId(firstCreatedUsed.get(0).getUserId());
final ManageUserAccountResponse deleteAccountResponse = (ManageUserAccountResponse) applicationManager.service(deleteAccountRequest);
assertNotNull(EXPECT_A_RESULT, deleteAccountResponse);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, deleteAccountResponse.getResult());
final List<UserAccount> allByAfterDelete = userContainer.getAllBy(UserAccount_.username, createAccountRequest.getUsername());
assertEquals(1, allByAfterDelete.size());
assertEquals(allByAfterDelete.get(0).getUserLockStatus(), UserLockStatus.LOCKED);
}
Aggregations