Package org.jtalks.jcommune.model.dto

Examples of org.jtalks.jcommune.model.dto.LoginUserDto


        when(userService.loginUser(any(LoginUserDto.class), any(HttpServletRequest.class),
                any(HttpServletResponse.class))).thenReturn(true);

        JsonResponse response = userController.loginAjax(null, null, "on", null, null);
        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
        LoginUserDto loginUserDto = new LoginUserDto("userName", "password", true, "192.168.1.1");
        verify(userService).loginUser(loginUserDto,
                any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here


        verify(userService).loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
    }

    @Test(enabled = false)
    public void testLoginWithCorrectParametersShouldBeSuccessful() throws Exception {
        LoginUserDto loginUserDto = new LoginUserDto("userName", "password", true, "192.168.1.1");
        when(userService.loginUser(loginUserDto, any(HttpServletRequest.class), any(HttpServletResponse.class)))
                .thenReturn(true);
       
        ModelAndView view = userController.login(loginUserDto, "on", null, request, null);
View Full Code Here

    @Test
    public void testLoginWithIncorrectParametersShouldFail() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class)))
                .thenReturn(false);
       
        LoginUserDto loginUserDto = new LoginUserDto();
        ModelAndView view = userController.login(loginUserDto, null,  "on", request, null);

//        assertEquals(view.getViewName(), "login");
        verify(userService).loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here

    public void testLoginUserShouldFailIfConnectionErrorOccurred() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class),
                any(HttpServletRequest.class), any(HttpServletResponse.class)))
                .thenThrow(new NoConnectionException());
       
        LoginUserDto loginUserDto = new LoginUserDto();
        ModelAndView view = userController.login(loginUserDto, null,  "on", request, null);

        assertEquals(view.getViewName(), UserController.AUTH_SERVICE_FAIL_URL);
        verify(userService).loginUser(eq(loginUserDto), any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here

    @Test
    public void testLoginUserShouldFailIfUnexpectedErrorOccurred() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class)))
                .thenThrow(new UnexpectedErrorException());
       
        LoginUserDto loginUserDto = new LoginUserDto();
        ModelAndView view = userController.login(loginUserDto, null,  "on", request, null);

        assertEquals(view.getViewName(), UserController.AUTH_SERVICE_FAIL_URL);
        verify(userService).loginUser(eq(loginUserDto),
                any(HttpServletRequest.class), any(HttpServletResponse.class));
View Full Code Here

    @Test
    public void testLoginUserWithCorrectCredentialsShouldBeSuccessful()
            throws UnexpectedErrorException, NoConnectionException {
        HttpServletRequest httpRequest = new MockHttpServletRequest();
        HttpServletResponse httpResponse = new MockHttpServletResponse();
        LoginUserDto loginUserDto = new LoginUserDto("username", "password", true, "192.168.1.1");
        when(authenticator.authenticate(loginUserDto, httpRequest, httpResponse))
                .thenReturn(true);

        boolean result = userService.loginUser(loginUserDto, httpRequest, httpResponse);
View Full Code Here

    @Test
    public void testLoginUserWithBadCredentialsShouldFail()
            throws UnexpectedErrorException, NoConnectionException {
        HttpServletRequest httpRequest = new MockHttpServletRequest();
        HttpServletResponse httpResponse = new MockHttpServletResponse();
        LoginUserDto loginUserDto = new LoginUserDto("", "password", true, "192.168.1.1");
        when(authenticator.authenticate(loginUserDto, httpRequest, httpResponse))
                .thenReturn(false);

        boolean result = userService.loginUser(loginUserDto, httpRequest, httpResponse);
View Full Code Here

    @Test
    public void authenticateExistingUserShouldBeSuccessful() throws Exception {
        String passwordHash = "5f4dcc3b5aa765d61d8327deb882cf99";
        JCUser user = getDefaultUser();
        LoginUserDto loginUserDto = createDefaultLoginUserDto();
        Map<String, String> authInfo = createAuthInfo(user.getUsername(), user.getEmail());
        when(userDao.getByUsername(user.getUsername())).thenReturn(user);
        when(encryptionService.encryptPassword(user.getPassword())).thenReturn(passwordHash);
        prepareAuth();
        preparePlugin(user.getUsername(), passwordHash, authInfo);
View Full Code Here

    }

    @Test
    public void authenticateNotExistingUserShouldBeSuccessful() throws Exception {
        String passwordHash = "5f4dcc3b5aa765d61d8327deb882cf99";
        LoginUserDto loginUserDto = createDefaultLoginUserDto();
        JCUser user = getDefaultUser();
        Map<String, String> authInfo = createAuthInfo(user.getUsername(), user.getEmail());
        when(userDao.getByUsername(user.getUsername())).thenReturn(null).thenReturn(null).thenReturn(user);
        when(encryptionService.encryptPassword(user.getPassword())).thenReturn(passwordHash);
        prepareAuth();
View Full Code Here

    @Test
    public void authenticateUserWithNewCredentialsShouldBeSuccessful() throws Exception {
        String passwordHash = "5f4dcc3b5aa765d61d8327deb882cf99";
        String email = "email@email.em";
        LoginUserDto loginUserDto = createDefaultLoginUserDto();
        JCUser oldUser = prepareOldUser(loginUserDto.getUserName());
        Map<String, String> authInfo = createAuthInfo(oldUser.getUsername(), email);
        authInfo.put("enabled", "true");
        Group group = new Group(AdministrationGroup.USER.getName());
        when(groupDao.getGroupByName(AdministrationGroup.USER.getName())).thenReturn(group);
        when(userDao.getByUsername(oldUser.getUsername())).thenReturn(oldUser);
        when(encryptionService.encryptPassword(loginUserDto.getPassword())).thenReturn(passwordHash);
        UsernamePasswordAuthenticationToken expectedToken = mock(UsernamePasswordAuthenticationToken.class);
        when(securityFacade.getContext()).thenReturn(securityContext);
        when(expectedToken.isAuthenticated()).thenReturn(true);

        when(authenticationManager.authenticate(any(UsernamePasswordAuthenticationToken.class)))
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.dto.LoginUserDto

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.