Search in sources :

Example 11 with FilesystemKeyPair

use of com.quorum.tessera.config.keypairs.FilesystemKeyPair in project tessera by ConsenSys.

the class FileKeyGeneratorTest method providingNoPathSavesToFileInSameDirectory.

@Test
public void providingNoPathSavesToFileInSameDirectory() throws IOException {
    Files.deleteIfExists(Paths.get(".pub"));
    Files.deleteIfExists(Paths.get(".key"));
    doReturn(keyPair).when(encryptor).generateNewKeys();
    final FilesystemKeyPair generated = generator.generate("", null, null);
    assertThat(Files.exists(Paths.get(".pub"))).isTrue();
    assertThat(Files.exists(Paths.get(".key"))).isTrue();
    verify(encryptor).generateNewKeys();
    Files.deleteIfExists(Paths.get(".pub"));
    Files.deleteIfExists(Paths.get(".key"));
}
Also used : FilesystemKeyPair(com.quorum.tessera.config.keypairs.FilesystemKeyPair) Test(org.junit.Test)

Aggregations

FilesystemKeyPair (com.quorum.tessera.config.keypairs.FilesystemKeyPair)11 Test (org.junit.Test)10 Path (java.nio.file.Path)8 CliResult (com.quorum.tessera.cli.CliResult)6 KeyEncryptor (com.quorum.tessera.config.keys.KeyEncryptor)3 HashMap (java.util.HashMap)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 CliException (com.quorum.tessera.cli.CliException)2 KeyDataConfig (com.quorum.tessera.config.KeyDataConfig)2 PrivateKeyData (com.quorum.tessera.config.PrivateKeyData)2 ConstraintViolationException (jakarta.validation.ConstraintViolationException)2 UncheckedIOException (java.io.UncheckedIOException)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 ArgonOptions (com.quorum.tessera.config.ArgonOptions)1 KeyData (com.quorum.tessera.config.KeyData)1 KeyPair (com.quorum.tessera.encryption.KeyPair)1 PrivateKey (com.quorum.tessera.encryption.PrivateKey)1