Search in sources :

Example 11 with CreateApplicationSessionRequest

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;
}
Also used : EmailServiceImpl(com.hack23.cia.service.impl.email.EmailServiceImpl) SimpleSmtpServer(com.dumbster.smtp.SimpleSmtpServer) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)

Example 12 with CreateApplicationSessionRequest

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);
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) CreateApplicationSessionResponse(com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse) Date(java.util.Date) Secured(org.springframework.security.access.annotation.Secured)

Example 13 with CreateApplicationSessionRequest

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();
}
Also used : EmailServiceImpl(com.hack23.cia.service.impl.email.EmailServiceImpl) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)

Example 14 with CreateApplicationSessionRequest

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());
}
Also used : UpdateApplicationConfigurationRequest(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest) UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse)

Example 15 with CreateApplicationSessionRequest

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);
}
Also used : CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) RegisterUserRequest(com.hack23.cia.service.api.action.application.RegisterUserRequest) ManageUserAccountRequest(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest) RegisterUserResponse(com.hack23.cia.service.api.action.application.RegisterUserResponse) ManageUserAccountResponse(com.hack23.cia.service.api.action.admin.ManageUserAccountResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Aggregations

CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)29 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)27 Test (org.junit.Test)27 RegisterUserRequest (com.hack23.cia.service.api.action.application.RegisterUserRequest)14 RegisterUserResponse (com.hack23.cia.service.api.action.application.RegisterUserResponse)14 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)13 PerfTest (org.databene.contiperf.PerfTest)13 LoginRequest (com.hack23.cia.service.api.action.application.LoginRequest)7 LoginResponse (com.hack23.cia.service.api.action.application.LoginResponse)7 Required (org.databene.contiperf.Required)7 ApplicationSession (com.hack23.cia.model.internal.application.system.impl.ApplicationSession)5 ServiceResponse (com.hack23.cia.service.api.action.common.ServiceResponse)5 ManageUserAccountRequest (com.hack23.cia.service.api.action.admin.ManageUserAccountRequest)4 ManageUserAccountResponse (com.hack23.cia.service.api.action.admin.ManageUserAccountResponse)4 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)3 CreateApplicationSessionResponse (com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse)3 LogoutRequest (com.hack23.cia.service.api.action.application.LogoutRequest)3 SendEmailRequest (com.hack23.cia.service.api.action.admin.SendEmailRequest)2 SendEmailResponse (com.hack23.cia.service.api.action.admin.SendEmailResponse)2 UpdateApplicationConfigurationRequest (com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest)2