@Test
public void testPostAccessTokenRequestOpenIdScopeMaxTimeout() throws UnsupportedEncodingException {

    System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY, "src/test/resources/unit_test_zts_at_private.pem");
    CloudStore cloudStore = new CloudStore();
    cloudStore.setHttpClient(null);
    ZTSImpl ztsImpl = new ZTSImpl(cloudStore, store);
    // set back to our zts rsa private key
    System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY, "src/test/resources/unit_test_zts_private.pem");
    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);
    // default max timeout is 12 hours so we'll pick a value
    // bigger than that
    final String scope = URLEncoder.encode("coretech:domain openid coretech:service.api", "UTF-8");
    AccessTokenResponse resp = ztsImpl.postAccessTokenRequest(context,
            "grant_type=client_credentials&scope=" + scope + "&expires_in=57600");
    assertNotNull(resp);
    assertEquals("coretech:role.writers openid", resp.getScope());
    String accessTokenStr = resp.getAccess_token();
    assertNotNull(accessTokenStr);
    String idToken = resp.getId_token();
    assertNotNull(idToken);
    Jws<Claims> claims;
    try {
        claims = Jwts.parserBuilder().setSigningKey(Crypto.extractPublicKey(ztsImpl.privateKey.getKey())).build().parseClaimsJws(idToken);
    } catch (SignatureException e) {
        throw new ResourceException(ResourceException.UNAUTHORIZED);
    }
    assertNotNull(claims);
    // the value should be 12 hours - the default max
    assertEquals(12 * 60 * 60 * 1000, claims.getBody().getExpiration().getTime() - claims.getBody().getIssuedAt().getTime());
}