From c0cbed188c1e6cf2bc98e17d23b970b2ede8753c Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Thu, 29 Oct 2020 09:15:44 +0100 Subject: Do not implement unexported interface --- .../athenz/aws/AwsCredentialProviderTest.java | 36 -------------------- .../yahoo/vespa/athenz/aws/AwsCredentialsTest.java | 38 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 36 deletions(-) delete mode 100644 vespa-athenz/src/test/java/com/yahoo/vespa/athenz/aws/AwsCredentialProviderTest.java create mode 100644 vespa-athenz/src/test/java/com/yahoo/vespa/athenz/aws/AwsCredentialsTest.java (limited to 'vespa-athenz/src/test') diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/aws/AwsCredentialProviderTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/aws/AwsCredentialProviderTest.java deleted file mode 100644 index 3569f231814..00000000000 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/aws/AwsCredentialProviderTest.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.athenz.aws; - -import com.yahoo.vespa.athenz.api.AwsTemporaryCredentials; -import org.junit.Assert; -import org.junit.Test; - -import java.time.Clock; -import java.time.Duration; -import java.time.Instant; - -/** - * @author tokle - */ -public class AwsCredentialProviderTest { - - @Test - public void refreshes_correctly() { - Clock clock = Clock.systemUTC(); - // Does not require refresh when expires in 10 minutes - Assert.assertFalse(AwsCredentialsProvider.shouldRefresh(getCredentials(clock.instant().plus(Duration.ofMinutes(10))))); - - // Requires refresh when expires in 3 minutes - Assert.assertTrue(AwsCredentialsProvider.shouldRefresh(getCredentials(clock.instant().plus(Duration.ofMinutes(3))))); - - // Requires refresh when expired - Assert.assertTrue(AwsCredentialsProvider.shouldRefresh(getCredentials(clock.instant().minus(Duration.ofMinutes(1))))); - - // Refreshes when no credentials provided - Assert.assertTrue(AwsCredentialsProvider.shouldRefresh(null)); - } - - private AwsTemporaryCredentials getCredentials(Instant expiration) { - return new AwsTemporaryCredentials("accesskey", "secretaccesskey", "sessionToken", expiration); - } -} diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/aws/AwsCredentialsTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/aws/AwsCredentialsTest.java new file mode 100644 index 00000000000..5467504285b --- /dev/null +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/aws/AwsCredentialsTest.java @@ -0,0 +1,38 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.athenz.aws; + +import com.yahoo.vespa.athenz.api.AwsTemporaryCredentials; +import org.junit.Assert; +import org.junit.Test; + +import java.time.Clock; +import java.time.Duration; +import java.time.Instant; + +import static org.junit.Assert.assertFalse; + +/** + * @author tokle + */ +public class AwsCredentialsTest { + + @Test + public void refreshes_correctly() { + Clock clock = Clock.systemUTC(); + // Does not require refresh when expires in 10 minutes + assertFalse(AwsCredentials.shouldRefresh(getCredentials(clock.instant().plus(Duration.ofMinutes(10))))); + + // Requires refresh when expires in 3 minutes + Assert.assertTrue(AwsCredentials.shouldRefresh(getCredentials(clock.instant().plus(Duration.ofMinutes(3))))); + + // Requires refresh when expired + Assert.assertTrue(AwsCredentials.shouldRefresh(getCredentials(clock.instant().minus(Duration.ofMinutes(1))))); + + // Refreshes when no credentials provided + Assert.assertTrue(AwsCredentials.shouldRefresh(null)); + } + + private AwsTemporaryCredentials getCredentials(Instant expiration) { + return new AwsTemporaryCredentials("accesskey", "secretaccesskey", "sessionToken", expiration); + } +} -- cgit v1.2.3