diff options
Diffstat (limited to 'vespa-athenz')
13 files changed, 115 insertions, 86 deletions
diff --git a/vespa-athenz/pom.xml b/vespa-athenz/pom.xml index 580910799c1..55482dd1fed 100644 --- a/vespa-athenz/pom.xml +++ b/vespa-athenz/pom.xml @@ -22,6 +22,12 @@ <artifactId>container-dev</artifactId> <version>${project.version}</version> <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> @@ -38,11 +44,6 @@ <!-- test --> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> @@ -52,6 +53,30 @@ <artifactId>testutil</artifactId> <version>${project.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + <exclusion> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> </dependency> <!-- compile --> @@ -90,6 +115,10 @@ <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> </exclusion> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> </exclusions> </dependency> <dependency> <!-- needed by auth-core --> diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/AthenzDomainTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/AthenzDomainTest.java index ff3d8d20797..d7d5428c11b 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/AthenzDomainTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/AthenzDomainTest.java @@ -1,14 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.athenz.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.function.Supplier; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; /** * @author bjorncs @@ -16,28 +13,28 @@ import static org.junit.Assert.fail; public class AthenzDomainTest { @Test - public void domain_can_be_constructed_from_valid_string() { + void domain_can_be_constructed_from_valid_string() { new AthenzDomain("home.john.my-app"); } @Test - public void invalid_domain_throws_exception() { + void invalid_domain_throws_exception() { assertInvalid(() -> new AthenzDomain("endswithdot.")); assertInvalid(() -> new AthenzDomain(".startswithdot")); } @Test - public void parent_domain_is_without_name_suffix() { + void parent_domain_is_without_name_suffix() { assertEquals(new AthenzDomain("home.john"), new AthenzDomain("home.john.myapp").getParent()); } @Test - public void domain_name_suffix_is_the_suffix_after_last_dot() { + void domain_name_suffix_is_the_suffix_after_last_dot() { assertEquals("myapp", new AthenzDomain("home.john.myapp").getNameSuffix()); } @Test - public void domain_without_dot_is_toplevel() { + void domain_without_dot_is_toplevel() { assertTrue(new AthenzDomain("toplevel").isTopLevelDomain()); assertFalse(new AthenzDomain("not.toplevel").isTopLevelDomain()); } diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/AthenzResourceNameTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/AthenzResourceNameTest.java index ececa45d5fb..a2de235906c 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/AthenzResourceNameTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/AthenzResourceNameTest.java @@ -1,9 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.athenz.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author bjorncs @@ -11,7 +11,7 @@ import static org.junit.Assert.*; public class AthenzResourceNameTest { @Test - public void can_serialize_and_deserialize_to_string() { + void can_serialize_and_deserialize_to_string() { AthenzResourceName resourceName = new AthenzResourceName(new AthenzDomain("domain"), "entity"); String resourceNameString = resourceName.toResourceNameString(); assertEquals("domain:entity", resourceNameString); diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/NTokenGeneratorTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/NTokenGeneratorTest.java index 7c4ee36926f..dd12bca03f3 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/NTokenGeneratorTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/api/NTokenGeneratorTest.java @@ -3,13 +3,13 @@ package com.yahoo.vespa.athenz.api; import com.yahoo.athenz.auth.util.CryptoException; import com.yahoo.test.ManualClock; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.security.PrivateKey; import java.time.Instant; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.mock; /** @@ -19,14 +19,14 @@ public class NTokenGeneratorTest { private final PrivateKey key = mock(PrivateKey.class); @Test - public void ntoken() { + void ntoken() { var signer = new Signer("signature"); NTokenGenerator generator = new NTokenGenerator(signer, new ManualClock(Instant.ofEpochSecond(12L)), () -> 3L); AthenzIdentity identity = new AthenzService("domain", "service"); NToken token = generator.setIdentity(identity) - .setKeyVersion("0") - .sign(key); + .setKeyVersion("0") + .sign(key); assertEquals("v=S1;d=domain;n=service;k=0;a=3;t=12;e=612", signer.message); assertSame(key, signer.key); 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 index 39ab8294409..48ff3ab651a 100644 --- 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 @@ -2,14 +2,14 @@ package com.yahoo.vespa.athenz.aws; import com.yahoo.vespa.athenz.api.AwsTemporaryCredentials; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.time.Clock; import java.time.Duration; import java.time.Instant; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author tokle @@ -17,19 +17,19 @@ import static org.junit.Assert.assertFalse; public class AwsCredentialsTest { @Test - public void refreshes_correctly() { + 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))))); + 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))))); + assertTrue(AwsCredentials.shouldRefresh(getCredentials(clock.instant().minus(Duration.ofMinutes(1))))); // Refreshes when no credentials provided - Assert.assertTrue(AwsCredentials.shouldRefresh(null)); + assertTrue(AwsCredentials.shouldRefresh(null)); } private AwsTemporaryCredentials getCredentials(Instant expiration) { diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identity/SiaIdentityProviderTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identity/SiaIdentityProviderTest.java index f502951572c..764b2d26006 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identity/SiaIdentityProviderTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identity/SiaIdentityProviderTest.java @@ -7,9 +7,8 @@ import com.yahoo.security.SignatureAlgorithm; import com.yahoo.security.X509CertificateBuilder; import com.yahoo.security.X509CertificateUtils; import com.yahoo.vespa.athenz.api.AthenzService; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import javax.security.auth.x500.X500Principal; import java.io.File; @@ -22,27 +21,27 @@ import java.time.Duration; import java.time.Instant; import static com.yahoo.yolean.Exceptions.uncheck; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author bjorncs */ public class SiaIdentityProviderTest { - @Rule - public TemporaryFolder tempDirectory = new TemporaryFolder(); + @TempDir + public File tempDirectory; @Test - public void constructs_ssl_context_from_file() throws IOException { - File keyFile = tempDirectory.newFile(); + void constructs_ssl_context_from_file() throws IOException { + File keyFile = File.createTempFile("junit", null, tempDirectory); KeyPair keypair = KeyUtils.generateKeypair(KeyAlgorithm.RSA); createPrivateKeyFile(keyFile, keypair); X509Certificate certificate = createCertificate(keypair); - File certificateFile = tempDirectory.newFile(); + File certificateFile = File.createTempFile("junit", null, tempDirectory); createCertificateFile(certificate, certificateFile); - File trustStoreFile = tempDirectory.newFile(); + File trustStoreFile = File.createTempFile("junit", null, tempDirectory); createTrustStoreFile(certificate, trustStoreFile); SiaIdentityProvider provider = @@ -56,16 +55,16 @@ public class SiaIdentityProviderTest { } @Test - public void constructs_ssl_context_with_pem_trust_store() throws IOException { - File keyFile = tempDirectory.newFile(); + void constructs_ssl_context_with_pem_trust_store() throws IOException { + File keyFile = File.createTempFile("junit", null, tempDirectory); KeyPair keypair = KeyUtils.generateKeypair(KeyAlgorithm.RSA); createPrivateKeyFile(keyFile, keypair); X509Certificate certificate = createCertificate(keypair); - File certificateFile = tempDirectory.newFile(); + File certificateFile = File.createTempFile("junit", null, tempDirectory); createCertificateFile(certificate, certificateFile); - File trustStoreFile = tempDirectory.newFile(); + File trustStoreFile = File.createTempFile("junit", null, tempDirectory); createPemTrustStoreFile(certificate, trustStoreFile); SiaIdentityProvider provider = diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/api/VespaUniqueInstanceIdTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/api/VespaUniqueInstanceIdTest.java index 81f2d2a08cb..d22a791fa60 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/api/VespaUniqueInstanceIdTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/api/VespaUniqueInstanceIdTest.java @@ -1,10 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.athenz.identityprovider.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static com.yahoo.vespa.athenz.identityprovider.api.IdentityType.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author bjorncs @@ -12,7 +12,7 @@ import static org.junit.Assert.*; public class VespaUniqueInstanceIdTest { @Test - public void can_serialize_to_and_deserialize_from_string() { + void can_serialize_to_and_deserialize_from_string() { VespaUniqueInstanceId id = new VespaUniqueInstanceId(1, "cluster-id", "instance", "application", "tenant", "region", "environment", TENANT); String stringRepresentation = id.asDottedString(); diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java index 21f2c84710a..c9d2ea581bb 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/AthenzIdentityProviderImplTest.java @@ -14,12 +14,13 @@ import com.yahoo.security.Pkcs10CsrBuilder; import com.yahoo.security.SignatureAlgorithm; import com.yahoo.security.X509CertificateBuilder; import com.yahoo.test.ManualClock; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import javax.security.auth.x500.X500Principal; + +import java.io.File; import java.io.IOException; import java.math.BigInteger; import java.nio.file.Path; @@ -32,6 +33,7 @@ import java.util.Date; import java.util.concurrent.ScheduledExecutorService; import java.util.function.Supplier; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -44,8 +46,8 @@ import static org.mockito.Mockito.when; */ public class AthenzIdentityProviderImplTest { - @Rule - public TemporaryFolder tempDir = new TemporaryFolder(); + @TempDir + public File tempDir; public static final Duration certificateValidity = Duration.ofDays(30); @@ -63,7 +65,7 @@ public class AthenzIdentityProviderImplTest { private Path trustStoreFile; private X509Certificate caCertificate; - @Before + @BeforeEach public void createTrustStoreFile() throws IOException { caCertificate = X509CertificateBuilder .fromKeypair( @@ -74,7 +76,7 @@ public class AthenzIdentityProviderImplTest { SignatureAlgorithm.SHA256_WITH_ECDSA, BigInteger.ONE) .build(); - trustStoreFile = tempDir.newFile().toPath(); + trustStoreFile = File.createTempFile("junit", null, tempDir).toPath(); KeyStoreUtils.writeKeyStoreToFile( KeyStoreBuilder.withType(KeyStoreType.JKS) .withKeyEntry("default", caKeypair.getPrivate(), caCertificate) @@ -82,17 +84,19 @@ public class AthenzIdentityProviderImplTest { trustStoreFile); } - @Test(expected = AthenzIdentityProviderException.class) - public void component_creation_fails_when_credentials_not_found() { - AthenzCredentialsService credentialService = mock(AthenzCredentialsService.class); - when(credentialService.registerInstance()) - .thenThrow(new RuntimeException("athenz unavailable")); - - new AthenzIdentityProviderImpl(IDENTITY_CONFIG, mock(Metric.class), trustStoreFile ,credentialService, mock(ScheduledExecutorService.class), new ManualClock(Instant.EPOCH)); + @Test + void component_creation_fails_when_credentials_not_found() { + assertThrows(AthenzIdentityProviderException.class, () -> { + AthenzCredentialsService credentialService = mock(AthenzCredentialsService.class); + when(credentialService.registerInstance()) + .thenThrow(new RuntimeException("athenz unavailable")); + + new AthenzIdentityProviderImpl(IDENTITY_CONFIG, mock(Metric.class), trustStoreFile, credentialService, mock(ScheduledExecutorService.class), new ManualClock(Instant.EPOCH)); + }); } @Test - public void metrics_updated_on_refresh() { + void metrics_updated_on_refresh() { ManualClock clock = new ManualClock(Instant.EPOCH); Metric metric = mock(Metric.class); diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java index 5a3099aff76..5253fee0802 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/IdentityDocumentSignerTest.java @@ -7,7 +7,7 @@ import com.yahoo.vespa.athenz.api.AthenzService; import com.yahoo.vespa.athenz.identityprovider.api.IdentityType; import com.yahoo.vespa.athenz.identityprovider.api.SignedIdentityDocument; import com.yahoo.vespa.athenz.identityprovider.api.VespaUniqueInstanceId; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.security.KeyPair; import java.time.Instant; @@ -16,7 +16,7 @@ import java.util.HashSet; import static com.yahoo.vespa.athenz.identityprovider.api.IdentityType.TENANT; import static com.yahoo.vespa.athenz.identityprovider.api.SignedIdentityDocument.DEFAULT_DOCUMENT_VERSION; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author bjorncs @@ -25,7 +25,7 @@ public class IdentityDocumentSignerTest { public static final int KEY_VERSION = 0; @Test - public void generates_and_validates_signature() { + void generates_and_validates_signature() { IdentityDocumentSigner signer = new IdentityDocumentSigner(); IdentityType identityType = TENANT; VespaUniqueInstanceId id = diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/InstanceCsrGeneratorTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/InstanceCsrGeneratorTest.java index fc0b0a9c85f..3e4f8541aaa 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/InstanceCsrGeneratorTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/client/InstanceCsrGeneratorTest.java @@ -6,13 +6,13 @@ import com.yahoo.security.KeyUtils; import com.yahoo.vespa.athenz.api.AthenzService; import com.yahoo.vespa.athenz.identityprovider.api.VespaUniqueInstanceId; import com.yahoo.security.Pkcs10Csr; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.security.auth.x500.X500Principal; import java.security.KeyPair; import java.util.Collections; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author mortent @@ -24,7 +24,7 @@ public class InstanceCsrGeneratorTest { private static final String ATHENZ_SERVICE = "foo.bar"; @Test - public void it_generates_csr_with_correct_subject() { + void it_generates_csr_with_correct_subject() { CsrGenerator csrGenerator = new CsrGenerator(DNS_SUFFIX, PROVIDER_SERVICE); AthenzService service = new AthenzService(ATHENZ_SERVICE); diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/AthenzIdentitiesTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/AthenzIdentitiesTest.java index 1b5dc3b7a71..262bac012b8 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/AthenzIdentitiesTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/AthenzIdentitiesTest.java @@ -4,9 +4,9 @@ package com.yahoo.vespa.athenz.utils; import com.yahoo.vespa.athenz.api.AthenzDomain; import com.yahoo.vespa.athenz.api.AthenzIdentity; import com.yahoo.vespa.athenz.api.AthenzService; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author bjorncs @@ -14,7 +14,7 @@ import static org.junit.Assert.assertEquals; public class AthenzIdentitiesTest { @Test - public void athenz_identity_is_parsed_from_dot_separated_string() { + void athenz_identity_is_parsed_from_dot_separated_string() { AthenzIdentity expectedIdentity = new AthenzService(new AthenzDomain("my.subdomain"), "myservicename"); String fullName = expectedIdentity.getFullName(); AthenzIdentity actualIdentity = AthenzIdentities.from(fullName); diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/AthenzIdentityVerifierTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/AthenzIdentityVerifierTest.java index 5b699be4088..e59d9998170 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/AthenzIdentityVerifierTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/AthenzIdentityVerifierTest.java @@ -7,7 +7,7 @@ import com.yahoo.security.X509CertificateBuilder; import com.yahoo.vespa.athenz.api.AthenzIdentity; import com.yahoo.vespa.athenz.api.AthenzService; import com.yahoo.vespa.athenz.tls.AthenzIdentityVerifier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; @@ -21,8 +21,8 @@ import java.time.Instant; import static com.yahoo.security.SignatureAlgorithm.SHA256_WITH_ECDSA; import static java.util.Collections.singleton; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -32,7 +32,7 @@ import static org.mockito.Mockito.when; public class AthenzIdentityVerifierTest { @Test - public void verifies_certificate_with_athenz_service_as_common_name() throws Exception { + void verifies_certificate_with_athenz_service_as_common_name() throws Exception { AthenzIdentity trustedIdentity = new AthenzService("mydomain", "alice"); AthenzIdentity unknownIdentity = new AthenzService("mydomain", "mallory"); KeyPair keyPair = KeyUtils.generateKeypair(KeyAlgorithm.EC); diff --git a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/SiaUtilsTest.java b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/SiaUtilsTest.java index 62c187b8c2c..7be55ec18a8 100644 --- a/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/SiaUtilsTest.java +++ b/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/utils/SiaUtilsTest.java @@ -3,29 +3,29 @@ package com.yahoo.vespa.athenz.utils; import com.yahoo.vespa.athenz.api.AthenzIdentity; import com.yahoo.vespa.athenz.api.AthenzService; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author bjorncs */ public class SiaUtilsTest { - @Rule - public TemporaryFolder tempDirectory = new TemporaryFolder(); + @TempDir + public File tempDirectory; @Test - public void it_finds_all_identity_names_from_files_in_sia_keys_directory() throws IOException { - Path siaRoot = tempDirectory.getRoot().toPath(); + void it_finds_all_identity_names_from_files_in_sia_keys_directory() throws IOException { + Path siaRoot = tempDirectory.toPath(); assertTrue(SiaUtils.findSiaServices(siaRoot).isEmpty()); Files.createDirectory(siaRoot.resolve("keys")); AthenzService fooService = new AthenzService("my.domain.foo"); |