diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2022-11-01 16:22:21 +0100 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@yahooinc.com> | 2022-11-01 16:25:31 +0100 |
commit | 32c0d9eb1cce9fdf97137617f32c011fa7851363 (patch) | |
tree | 949e69a85da5645dc3761e239fff4a55b7e82724 /vespaclient-java/src/test/java | |
parent | 2e0be2e608099793b98bb008ca14c3d60595b64f (diff) |
Add simple token info dumping tool
Dumps key version, ID and HPKE components
Diffstat (limited to 'vespaclient-java/src/test/java')
-rw-r--r-- | vespaclient-java/src/test/java/com/yahoo/vespa/security/tool/CryptoToolsTest.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespa/security/tool/CryptoToolsTest.java b/vespaclient-java/src/test/java/com/yahoo/vespa/security/tool/CryptoToolsTest.java index a3651888441..8ba24d2cccc 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespa/security/tool/CryptoToolsTest.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespa/security/tool/CryptoToolsTest.java @@ -72,6 +72,11 @@ public class CryptoToolsTest { } @Test + void token_info_help_printed_if_help_option_given_to_subtool() throws IOException { + verifyStdoutMatchesFile(List.of("token-info", "--help"), "expected-token-info-help-output.txt"); + } + + @Test void missing_required_parameter_prints_error_message() throws IOException { // We don't test all possible input arguments to all tools, since it'd be too closely // bound to the order in which the implementation checks for argument presence. @@ -108,6 +113,16 @@ public class CryptoToolsTest { .formatted(absPathOf(pubKeyFile))); } + @Test + void keygen_fails_if_priv_and_pub_paths_equal() throws IOException { + Path keyFile = pathInTemp("foo.txt"); + + verifyStderrEquals(List.of("keygen", + "--private-out-file", absPathOf(keyFile), + "--public-out-file", absPathOf(keyFile)), + "Invalid command line arguments: Private and public key output files must be different\n"); + } + // ... but we'll allow it if someone enables the foot-gun option. @Test void keygen_allowed_if_output_file_exists_and_explicit_overwrite_option_specified() throws IOException { @@ -214,6 +229,17 @@ public class CryptoToolsTest { } @Test + void token_info_fails_with_error_message_if_no_token_string_given() throws IOException { + verifyStderrEquals(List.of("token-info"), + "Invalid command line arguments: Expected exactly 1 token string argument\n"); + } + + @Test + void token_info_is_printed_to_stdout() throws IOException { + verifyStdoutMatchesFile(List.of("token-info", TEST_TOKEN), "expected-token-info-output.txt"); + } + + @Test void can_end_to_end_keygen_encrypt_and_decrypt_via_files() throws IOException { String greatSecret = "Dogs can't look up"; |