@Test
public void testGetRoleToken() {

    SignedDomain signedDomain = createSignedDomain("coretech", "weather", "storage", true);
    store.processDomain(signedDomain, false);
    
    Principal principal = SimplePrincipal.create("user_domain", "user",
            "v=U1;d=user_domain;n=user;s=signature", 0, null);
    ResourceContext context = createResourceContext(principal);
    
    RoleToken roleToken = zts.getRoleToken(context, "coretech", null, 600,
            1200, null);
    com.yahoo.athenz.auth.token.RoleToken token = new com.yahoo.athenz.auth.token.RoleToken(roleToken.getToken());
    assertEquals(token.getRoles().size(), 1);
    assertTrue(token.getRoles().contains("writers"));
    assertTrue(roleToken.getToken().contains(";h=localhost;"));
    assertTrue(roleToken.getToken().contains(";i=10.11.12.13"));
    assertTrue(roleToken.getToken().contains(";p=user_domain.user;"));
    assertEquals(roleToken.getExpiryTime(), token.getExpiryTime());
    
    Principal principal1 = SimplePrincipal.create("user_domain", "user1",
            "v=U1;d=user_domain;n=user1;s=signature", 0, null);
    ResourceContext context1 = createResourceContext(principal1);
    
    roleToken = zts.getRoleToken(context1, "coretech", null, null, 1200, null);
    token = new com.yahoo.athenz.auth.token.RoleToken(roleToken.getToken());
    assertEquals(token.getRoles().size(), 2);
    assertTrue(token.getRoles().contains("readers"));
    assertTrue(token.getRoles().contains("writers"));
    
    Principal principal4 = SimplePrincipal.create("user_domain", "user4",
            "v=U1;d=user_domain;n=user4;s=signature", 0, null);
    ResourceContext context4 = createResourceContext(principal4);
    
    roleToken = zts.getRoleToken(context4, "coretech", null, 600,
            null, null);
    token = new com.yahoo.athenz.auth.token.RoleToken(roleToken.getToken());
    assertEquals(token.getRoles().size(), 1);
    assertTrue(token.getRoles().contains("readers"));
    assertTrue(roleToken.getToken().contains(";p=user_domain.user4;"));
    assertTrue(roleToken.getToken().contains(";c=1;"));
    
    // turn off the include role complete set flag
    
    zts.includeRoleCompleteFlag = false;
    roleToken = zts.getRoleToken(context4, "coretech", null, 600,
            null, null);
    token = new com.yahoo.athenz.auth.token.RoleToken(roleToken.getToken());
    assertEquals(token.getRoles().size(), 1);
    assertTrue(token.getRoles().contains("readers"));
    assertTrue(roleToken.getToken().contains(";p=user_domain.user4;"));
    assertFalse(roleToken.getToken().contains(";c=1;"));
    zts.includeRoleCompleteFlag = true;
}