Package com.github.ebnew.ki4so.core.authentication

Examples of com.github.ebnew.ki4so.core.authentication.AuthenticationManager.authenticate()


    InvalidCredentialException exception = Mockito.mock(InvalidCredentialException.class);
    String code = "message code";
    String msgKey ="message key";
    Mockito.when(exception.getCode()).thenReturn(code);
    Mockito.when(exception.getMsgKey()).thenReturn(msgKey);
    Mockito.when(authenticationManager.authenticate(credential)).thenThrow(exception);
    LoginResult loginResult = ki4soService.login(credential);
    LoginResult expected = new LoginResult();
    expected.setSuccess(false);
    expected.setCode(code);
    expected.setMsgKey(msgKey);
View Full Code Here


   
   
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(exception.getCode()).thenReturn(msgKey);
    Mockito.when(exception.getCode()).thenReturn(code);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    loginResult = ki4soService.login(credential);
    expected = new LoginResult();
    expected.setSuccess(true);
    expected.setAuthentication(authentication);
    //比较结果。
View Full Code Here

   
    /**
     * 测试正常参数情况,但是验证成功。
     */
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    this.ki4soService.logout(credential);
   
    /**
     * 测试正常参数情况,但是验证成功。
     */
 
View Full Code Here

    /**
     * 测试正常参数情况,但是验证成功。
     */
    authentication = Mockito.mock(Authentication.class);
    Mockito.when(authentication.getPrincipal()).thenReturn(Mockito.mock(Principal.class));
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    this.ki4soService.logout(credential);
   
   
    /**
     * 测试认证抛出异常情况。
 
View Full Code Here

   
   
    /**
     * 测试认证抛出异常情况。
     */
    Mockito.when(authenticationManager.authenticate(credential)).thenThrow(Mockito.mock(InvalidCredentialException.class));
    this.ki4soService.logout(credential);
  }
 
  @Test
  public void testGetAppList(){
View Full Code Here

    /**
     * 测试正确参数,但是返回值的属principal为空的情况。
     */
    credential = Mockito.mock(Credential.class);
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    Assert.assertEquals(0, this.ki4soService.getAppList(credential).size());
   
   
    /**
     * 测试正确参数,但是返回值的属principal不是空的情况。
 
View Full Code Here

    /**
     * 测试正确参数,但是返回值的属principal不是空的情况。
     */
    credential = Mockito.mock(Credential.class);
    authentication = Mockito.mock(Authentication.class);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    Mockito.when(authentication.getPrincipal()).thenReturn(Mockito.mock(Principal.class));
    List<UserLoggedStatus> list = new ArrayList<UserLoggedStatus>();
    UserLoggedStatus loggedStatus = new UserLoggedStatus("test", "1001");
    list.add(loggedStatus);
    Mockito.when(userLoggedStatusStore.findUserLoggedStatus(Mockito.anyString())).thenReturn(list);
View Full Code Here

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.