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

Examples of com.github.ebnew.ki4so.core.authentication.status.UserLoggedStatusStore


        this.handler.setKeyService(keyService);
        EncryCredentialManager encryCredentialManager = Mockito.mock(EncryCredentialManager.class);
        Mockito.when(encryCredentialManager.encrypt(Mockito.any(EncryCredentialInfo.class))).thenReturn(encStringValue);
        this.handler.setEncryCredentialManager(encryCredentialManager);
       
        UserLoggedStatusStore userLoggedStatusStore = Mockito.mock(UserLoggedStatusStore.class);
        this.handler.setUserLoggedStatusStore(userLoggedStatusStore);
       
        authentication = this.handler.postAuthentication(credential, principal);
        assertNotNull(authentication);
    }
View Full Code Here


  public void testLogout(){
    //测试认证失败的情况。
    Credential credential = Mockito.mock(Credential.class);
    //当调用认证方法则抛出异常信息。模拟测试数据。
    AuthenticationManager authenticationManager = Mockito.mock(AuthenticationManager.class);
    UserLoggedStatusStore userLoggedStatusStore = Mockito.mock(UserLoggedStatusStore.class);
   
    this.ki4soService.setAuthenticationManager(authenticationManager);
    this.ki4soService.setUserLoggedStatusStore(userLoggedStatusStore);
   
    /**
 
View Full Code Here

  @Test
  public void testGetAppList(){
   
    //当调用认证方法则抛出异常信息。模拟测试数据。
    AuthenticationManager authenticationManager = Mockito.mock(AuthenticationManager.class);
    UserLoggedStatusStore userLoggedStatusStore = Mockito.mock(UserLoggedStatusStore.class);
    AppService appService = Mockito.mock(AppService.class);
    this.ki4soService.setAuthenticationManager(authenticationManager);
    this.ki4soService.setUserLoggedStatusStore(userLoggedStatusStore);
    this.ki4soService.setAppService(appService);
   
    /**
     * 测试传递错误参数的情况。
     */
    Assert.assertEquals(0, this.ki4soService.getAppList(null).size());
   
    /**
     * 测试正确参数的情况。
     */
    Credential credential = Mockito.mock(Credential.class);
    Assert.assertEquals(0, this.ki4soService.getAppList(credential).size());
   
    /**
     * 测试正确参数,但是返回值的属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不是空的情况。
     */
    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);
    App app = new App();
    Mockito.when(appService.findAppById(Mockito.anyString())).thenReturn(app);
    Assert.assertEquals(1, this.ki4soService.getAppList(credential).size());
  }
View Full Code Here

TOP

Related Classes of com.github.ebnew.ki4so.core.authentication.status.UserLoggedStatusStore

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.