コード例 #1
0
 @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());
 }
コード例 #2
0
 @Test
 public void shouldNotChangePasswordWithoutOldPassword() {
   motechUserService.register(
       "userName", "password", "1234", "", asList("IT_ADMIN", "DB_ADMIN"), Locale.ENGLISH);
   motechUserService.changePassword("userName", "foo", "newPassword");
   MotechUser motechUser = usersDataService.findByUserName("userName");
   assertTrue(passwordEncoder.isPasswordValid(motechUser.getPassword(), "password"));
 }
コード例 #3
0
 @Test
 public void testPasswordEncoding() {
   String plainTextPassword = "******";
   motechUserService.register(
       "testuser", plainTextPassword, "entity1", "", asList("ADMIN"), Locale.ENGLISH);
   MotechUser motechUser = usersDataService.findByUserName("testuser");
   assertTrue(passwordEncoder.isPasswordValid(motechUser.getPassword(), plainTextPassword));
 }
コード例 #4
0
 @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"));
 }
コード例 #5
0
  @After
  public void tearDown() throws Exception {
    super.tearDown();

    usersDataService.deleteAll();
    rolesDataService.deleteAll();

    clearSecurityContext();
  }
コード例 #6
0
 @Test
 public void shouldCreateBlockedUser() {
   motechUserService.register(
       "userName",
       "password",
       "1234",
       "",
       asList("IT_ADMIN", "DB_ADMIN"),
       Locale.ENGLISH,
       UserStatus.BLOCKED,
       null);
   MotechUser motechUser = usersDataService.findByUserName("userName");
   assertEquals(UserStatus.BLOCKED, motechUser.getUserStatus());
 }
コード例 #7
0
  @Before
  @Override
  public void setUp() throws Exception {
    super.setUp();

    passwordEncoder = getFromContext(MotechPasswordEncoder.class);

    usersDataService.deleteAll();
    rolesDataService.deleteAll();

    // authorize
    motechUserService.registerMotechAdmin("admin", "admin", "*****@*****.**", Locale.ENGLISH);

    setUpSecurityContext("admin", "admin", getPermissions());
  }
コード例 #8
0
 @Test
 public void shouldNotActivateInvalidUser() {
   motechUserService.register(
       "userName",
       "password",
       "1234",
       "",
       asList("IT_ADMIN", "DB_ADMIN"),
       Locale.ENGLISH,
       UserStatus.BLOCKED,
       null);
   motechUserService.activateUser("userName1");
   MotechUser motechUser = usersDataService.findByUserName("userName");
   assertFalse(motechUser.isActive());
 }