diff options
author | Bjørn Christian Seime <bjorncs@yahooinc.com> | 2022-07-27 16:03:31 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@yahooinc.com> | 2022-07-27 16:03:31 +0200 |
commit | 2afaff6399ae22dfef1430d5cbce9ad41e887a9f (patch) | |
tree | 3ce1dfe82e8e8c0d7a99d9dd36a4bacf06c771ed /security-tools | |
parent | 7078e32616d6a7c8a7c7d34c4634f0b04ba1e8b0 (diff) |
Convert security-tools to junit5
Diffstat (limited to 'security-tools')
-rw-r--r-- | security-tools/pom.xml | 13 | ||||
-rw-r--r-- | security-tools/src/test/java/com/yahoo/vespa/security/tool/securityenv/MainTest.java | 24 |
2 files changed, 21 insertions, 16 deletions
diff --git a/security-tools/pom.xml b/security-tools/pom.xml index 7f248c185a2..2af6e09a84d 100644 --- a/security-tools/pom.xml +++ b/security-tools/pom.xml @@ -27,13 +27,18 @@ <!-- test scope --> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> + <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> <dependency> diff --git a/security-tools/src/test/java/com/yahoo/vespa/security/tool/securityenv/MainTest.java b/security-tools/src/test/java/com/yahoo/vespa/security/tool/securityenv/MainTest.java index 4b8f4bf0156..b1d263a1a82 100644 --- a/security-tools/src/test/java/com/yahoo/vespa/security/tool/securityenv/MainTest.java +++ b/security-tools/src/test/java/com/yahoo/vespa/security/tool/securityenv/MainTest.java @@ -4,11 +4,11 @@ package com.yahoo.vespa.security.tool.securityenv; import com.yahoo.security.tls.MixedMode; import com.yahoo.security.tls.TransportSecurityOptions; import com.yahoo.security.tls.TransportSecurityUtils; -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.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.nio.file.Files; @@ -30,18 +30,18 @@ public class MainTest { private final PrintStream stdOut = new PrintStream(stdOutBytes); private final PrintStream stdError = new PrintStream(stdErrBytes); - @Rule - public TemporaryFolder tmpFolder = new TemporaryFolder(); + @TempDir + public File tmpFolder; @Test - public void prints_help_page_on_help_option() throws IOException { + void prints_help_page_on_help_option() throws IOException { int exitCode = runMain(List.of("--help"), Map.of()); assertThat(exitCode).isEqualTo(0); assertThat(stdOut()).isEqualTo(readTestResource("expected-help-output.txt")); } @Test - public void unsets_all_variables_when_no_security_config() throws IOException { + void unsets_all_variables_when_no_security_config() throws IOException { int exitCode = runMain(List.of(), Map.of()); assertThat(exitCode).isEqualTo(0); assertThat(stdErr()).isEmpty(); @@ -49,7 +49,7 @@ public class MainTest { } @Test - public void prints_security_variables_with_specified_shell() throws IOException { + void prints_security_variables_with_specified_shell() throws IOException { Path configFile = generateConfigFile(); Map<String, String> env = Map.of(TransportSecurityUtils.CONFIG_FILE_ENVIRONMENT_VARIABLE, configFile.toString()); int exitCode = runMain(List.of(), env); @@ -58,7 +58,7 @@ public class MainTest { } @Test - public void prints_security_variables_with_auto_detected_shell() throws IOException { + void prints_security_variables_with_auto_detected_shell() throws IOException { Path configFile = generateConfigFile(); Map<String, String> env = Map.of( TransportSecurityUtils.CONFIG_FILE_ENVIRONMENT_VARIABLE, configFile.toString(), @@ -71,14 +71,14 @@ public class MainTest { @Test - public void prints_error_message_on_unknown_shell_name() { + void prints_error_message_on_unknown_shell_name() { int exitCode = runMain(List.of("--shell", "invalid-shell-name"), Map.of()); assertThat(exitCode).isEqualTo(1); assertThat(stdErr()).isEqualTo("Invalid command line arguments: Unknown shell: invalid-shell-name\n"); } @Test - public void prints_error_message_on_unknown_command_line_parameter() { + void prints_error_message_on_unknown_command_line_parameter() { int exitCode = runMain(List.of("--unknown-parameter"), Map.of()); assertThat(exitCode).isEqualTo(1); assertThat(stdErr()).isEqualTo("Failed to parse command line arguments: Unrecognized option: --unknown-parameter\n"); @@ -108,7 +108,7 @@ public class MainTest { .withCaCertificates(Paths.get("/path/to/cacerts")) .withHostnameValidationDisabled(true) .build(); - Path configFile = tmpFolder.newFile().toPath(); + Path configFile = File.createTempFile("junit", null, tmpFolder).toPath(); options.toJsonFile(configFile); return configFile; } |