Package com.commafeed.backend.model

Examples of com.commafeed.backend.model.User


public class SecurityCheckFactoryTest {

  @Test
  public void cookie_login_should_perform_post_login_activities_if_user_is_logged_in() {
    User userInSession = new User();

    SessionHelper sessionHelper = mock(SessionHelper.class);
    when(sessionHelper.getLoggedInUser()).thenReturn(Optional.of(userInSession));

    PostLoginActivities postLoginActivities = mock(PostLoginActivities.class);
View Full Code Here


  private void testOpmlVersion(String fileName) throws IOException {
    FeedCategoryDAO feedCategoryDAO = Mockito.mock(FeedCategoryDAO.class);
    FeedSubscriptionService feedSubscriptionService = Mockito.mock(FeedSubscriptionService.class);
    CacheService cacheService = Mockito.mock(CacheService.class);
    User user = Mockito.mock(User.class);

    String xml = IOUtils.toString(getClass().getResourceAsStream(fileName));

    OPMLImporter importer = new OPMLImporter(feedCategoryDAO, feedSubscriptionService, cacheService);
    importer.importOpml(user, xml);
View Full Code Here

    Assert.assertFalse(user.isPresent());
  }

  @Test
  public void getting_user_should_return_user_if_user_present_in_http_session() {
    User userInSession = new User();

    HttpSession session = mock(HttpSession.class);
    when(session.getAttribute(SESSION_KEY_USER)).thenReturn(userInSession);

    HttpServletRequest request = mock(HttpServletRequest.class);
View Full Code Here

  }
 
  @Test public void
  login_should_populate_http_session_if_successfull() {
    // Create a user
    User user = new User();
   
    // Create UserService mock
    UserService service = mock(UserService.class);
    when(service.login("user", "password")).thenReturn(Optional.of(user));
   
View Full Code Here

  }
 
  @Test public void
  register_should_populate_http_session() {
    // Create a user
    User user = new User();
   
    // Create UserService mock
    UserService service = mock(UserService.class);
    when(service.register(any(String.class), any(String.class), any(String.class), Matchers.anyListOf(Role.class))).thenReturn(user);
    when(service.login(any(String.class), any(String.class))).thenReturn(Optional.of(user));
View Full Code Here

  public Optional<User> login(String nameOrEmail, String password) {
    if (nameOrEmail == null || password == null) {
      return Optional.absent();
    }

    User user = userDAO.findByName(nameOrEmail);
    if (user == null) {
      user = userDAO.findByEmail(nameOrEmail);
    }
    if (user != null && !user.isDisabled()) {
      boolean authenticated = encryptionService.authenticate(password, user.getPassword(), user.getSalt());
      if (authenticated) {
        performPostLoginActivities(user);
        return Optional.of(user);
      }
    }
View Full Code Here

  public Optional<User> login(String apiKey) {
    if (apiKey == null) {
      return Optional.absent();
    }

    User user = userDAO.findByApiKey(apiKey);
    if (user != null && !user.isDisabled()) {
      performPostLoginActivities(user);
      return Optional.of(user);
    }
    return Optional.absent();
  }
View Full Code Here

    Preconditions.checkArgument(userDAO.findByName(name) == null, "Name already taken");
    if (StringUtils.isNotBlank(email)) {
      Preconditions.checkArgument(userDAO.findByEmail(email) == null, "Email already taken");
    }

    User user = new User();
    byte[] salt = encryptionService.generateSalt();
    user.setName(name);
    user.setEmail(email);
    user.setCreated(new Date());
    user.setSalt(salt);
    user.setPassword(encryptionService.getEncryptedPassword(password, salt));
    for (Role role : roles) {
      user.getRoles().add(new UserRole(user, role));
    }
    userDAO.saveOrUpdate(user);
    return user;
  }
View Full Code Here

TOP

Related Classes of com.commafeed.backend.model.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.