Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8428E200CD3 for ; Fri, 28 Jul 2017 13:16:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8274616C9C0; Fri, 28 Jul 2017 11:16:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C581B16C9BA for ; Fri, 28 Jul 2017 13:16:05 +0200 (CEST) Received: (qmail 26007 invoked by uid 500); 28 Jul 2017 11:16:04 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 25998 invoked by uid 99); 28 Jul 2017 11:16:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jul 2017 11:16:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3A128E02F6; Fri, 28 Jul 2017 11:16:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: coheigea@apache.org To: commits@cxf.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: Expiry check Date: Fri, 28 Jul 2017 11:16:03 +0000 (UTC) archived-at: Fri, 28 Jul 2017 11:16:06 -0000 Repository: cxf Updated Branches: refs/heads/master 74b975e88 -> 3fc5e2901 Expiry check Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3fc5e290 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3fc5e290 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3fc5e290 Branch: refs/heads/master Commit: 3fc5e29018ca32c14f82ced1f07678c4bf35bfea Parents: 74b975e Author: Colm O hEigeartaigh Authored: Fri Jul 28 12:15:47 2017 +0100 Committer: Colm O hEigeartaigh Committed: Fri Jul 28 12:15:58 2017 +0100 ---------------------------------------------------------------------- .../token/provider/JWTProviderLifetimeTest.java | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/3fc5e290/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/JWTProviderLifetimeTest.java ---------------------------------------------------------------------- diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/JWTProviderLifetimeTest.java b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/JWTProviderLifetimeTest.java index e017c24..10906f2 100644 --- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/JWTProviderLifetimeTest.java +++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/JWTProviderLifetimeTest.java @@ -71,13 +71,13 @@ public class JWTProviderLifetimeTest extends org.junit.Assert { Lifetime lifetime = new Lifetime(); lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); - + providerParameters.getTokenRequirements().setLifetime(lifetime); TokenProviderResponse providerResponse = tokenProvider.createToken(providerParameters); assertTrue(providerResponse != null); assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId() != null); - + long duration = Duration.between(providerResponse.getCreated(), providerResponse.getExpires()).getSeconds(); assertEquals(requestedLifetime, duration); @@ -117,8 +117,11 @@ public class JWTProviderLifetimeTest extends org.junit.Assert { JwsJwtCompactConsumer jwtConsumer = new JwsJwtCompactConsumer(token); JwtToken jwt = jwtConsumer.getJwtToken(); assertEquals(jwt.getClaim(JwtConstants.CLAIM_ISSUED_AT), providerResponse.getCreated().getEpochSecond()); - } + Instant now = Instant.now(); + Long expiry = (Long)jwt.getClaim(JwtConstants.CLAIM_EXPIRY); + Instant.ofEpochSecond(expiry).isAfter(now); + } /** * Issue JWT token with a with a lifetime @@ -144,7 +147,7 @@ public class JWTProviderLifetimeTest extends org.junit.Assert { Lifetime lifetime = new Lifetime(); lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); - + providerParameters.getTokenRequirements().setLifetime(lifetime); try { @@ -178,7 +181,7 @@ public class JWTProviderLifetimeTest extends org.junit.Assert { Lifetime lifetime = new Lifetime(); lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); - + providerParameters.getTokenRequirements().setLifetime(lifetime); try { @@ -216,7 +219,7 @@ public class JWTProviderLifetimeTest extends org.junit.Assert { Lifetime lifetime = new Lifetime(); lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); - + providerParameters.getTokenRequirements().setLifetime(lifetime); TokenProviderResponse providerResponse = tokenProvider.createToken(providerParameters); @@ -257,7 +260,7 @@ public class JWTProviderLifetimeTest extends org.junit.Assert { Lifetime lifetime = new Lifetime(); lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); - + providerParameters.getTokenRequirements().setLifetime(lifetime); TokenProviderResponse providerResponse = tokenProvider.createToken(providerParameters); @@ -297,7 +300,7 @@ public class JWTProviderLifetimeTest extends org.junit.Assert { Lifetime lifetime = new Lifetime(); lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); lifetime.setExpires(expirationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); - + providerParameters.getTokenRequirements().setLifetime(lifetime); try { @@ -342,7 +345,7 @@ public class JWTProviderLifetimeTest extends org.junit.Assert { Lifetime lifetime = new Lifetime(); lifetime.setCreated(creationTime.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true))); - + providerParameters.getTokenRequirements().setLifetime(lifetime); TokenProviderResponse providerResponse = tokenProvider.createToken(providerParameters);