use of org.motechproject.security.domain.MotechUser in project motech by motech.
the class MotechLoginSuccessHandlerTest method shouldSetSessionTimeoutAndStore.
@Test
public void shouldSetSessionTimeoutAndStore() throws ServletException, IOException {
MotechUser user = new MotechUser();
user.setUserName("testUser");
user.setFailureLoginCounter(3);
when(authentication.getName()).thenReturn("testUser");
when(motechUsersDao.findByUserName("testUser")).thenReturn(user);
when(request.getSession()).thenReturn(session);
when(settingService.getSessionTimeout()).thenReturn(500);
motechLoginSuccessHandler.onAuthenticationSuccess(request, response, authentication);
verify(session).setMaxInactiveInterval(500);
verify(sessionHandler).addSession(session);
}
use of org.motechproject.security.domain.MotechUser in project motech by motech.
the class PasswordReminderEventHandlerTest method prepareUser.
private void prepareUser() {
user = new MotechUser();
user.setLastPasswordChange(DateUtil.now().minusDays(DAYS_TO_CHANGE_PASSWORD - DAYS_FOR_REMINDER));
user.setUserName("FooUsername");
user.setEmail("fooUser@domain.com");
}
use of org.motechproject.security.domain.MotechUser in project motech by motech.
the class MotechUserServiceBundleIT method testPasswordEncoding.
@Test
public void testPasswordEncoding() {
String plainTextPassword = "testpassword";
motechUserService.register("testuser", plainTextPassword, "entity1", "", asList("ADMIN"), Locale.ENGLISH);
MotechUser motechUser = usersDataService.findByUserName("testuser");
assertTrue(passwordEncoder.isPasswordValid(motechUser.getPassword(), plainTextPassword));
}
use of org.motechproject.security.domain.MotechUser in project motech by motech.
the class MotechUserServiceBundleIT method testRegister.
@Test
public void testRegister() {
motechUserService.register("userName", "password", "1234", "", asList("IT_ADMIN", "DB_ADMIN"), Locale.ENGLISH);
MotechUser motechUser = usersDataService.findByUserName("userName");
assertNotNull(motechUser);
assertTrue(motechUser.getRoles().contains("IT_ADMIN"));
assertTrue(motechUser.getRoles().contains("DB_ADMIN"));
}
use of org.motechproject.security.domain.MotechUser in project motech by motech.
the class MotechUserServiceBundleIT method shouldCreateActiveUserByDefault.
@Test
public void shouldCreateActiveUserByDefault() {
motechUserService.register("userName", "password", "1234", "", asList("IT_ADMIN", "DB_ADMIN"), Locale.ENGLISH);
MotechUser motechUser = usersDataService.findByUserName("userName");
assertEquals(UserStatus.ACTIVE, motechUser.getUserStatus());
}
Aggregations