예제 #1
0
  @Test
  public void should_log_in() {
    User user = randomUser();
    UserFlow navigation = login(navigate(), user.getEmail());
    VRaptorTestResult loginResult = navigation.followRedirect().execute();
    loginResult.wasStatus(200).isValid();

    LoggedUser loggedUser = loginResult.getObject("currentUser");
    User currentUser = loggedUser.getCurrent();

    assertThat(currentUser.getId(), equalTo(user.getId()));
  }
예제 #2
0
파일: LDAPApi.java 프로젝트: stxnext/mamute
 private void updateAvatarImage(LDAPResource ldap, Entry entry, User user) {
   try {
     byte[] jpegBytes = getAvatarImage(ldap, entry);
     if (jpegBytes != null) {
       String fileName = user.getEmail() + ".jpg";
       DefaultUploadedFile avatar =
           new DefaultUploadedFile(
               new ByteArrayInputStream(jpegBytes), fileName, "image/jpeg", jpegBytes.length);
       Attachment attachment = imageStore.processAndStore(avatar, user, clientIp);
       Attachment old = user.getAvatar();
       if (old != null) {
         imageStore.delete(old);
       }
       user.setAvatar(attachment);
     }
   } catch (LdapException | IOException e) {
     // problems with avatar processing are non-fatal
     logger.warn("Error updating user avatar from LDAP: " + user.getName(), e);
   }
 }