Package com.commafeed.frontend.auth

Source Code of com.commafeed.frontend.auth.SecurityCheckFactoryTest

package com.commafeed.frontend.auth;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.junit.Test;

import com.commafeed.backend.model.User;
import com.commafeed.backend.service.UserService;
import com.commafeed.backend.service.internal.PostLoginActivities;
import com.commafeed.frontend.session.SessionHelper;
import com.google.common.base.Optional;

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);

    UserService service = new UserService(null, null, null, null, null, postLoginActivities);

    SecurityCheckFactory factory = new SecurityCheckFactory(null, false);
    factory.userService = service;
    factory.cookieSessionLogin(sessionHelper);

    verify(postLoginActivities).executeFor(userInSession);
  }

}
TOP

Related Classes of com.commafeed.frontend.auth.SecurityCheckFactoryTest

TOP
Copyright © 2018 www.massapi.com. 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.