Search in sources :

Example 1 with PREFIX_ADDRESS

use of tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.PREFIX_ADDRESS in project signers by ConsenSys.

the class SigningMetadataTomlConfigLoaderTest method loadAvailableConfigsReturnsAllValidMetadataFilesInDirectory.

@Test
void loadAvailableConfigsReturnsAllValidMetadataFilesInDirectory() {
    final Filter<Path> filter = entry -> true;
    final FileBasedSigningMetadataFile metadataFile1 = copyMetadataFileToDirectory(configsDirectory, LOWERCASE_ADDRESS + CONFIG_FILE_EXTENSION, KEY_FILE, PASSWORD_FILE);
    final FileBasedSigningMetadataFile metadataFile2 = copyMetadataFileToDirectory(configsDirectory, "bar_" + PREFIX_ADDRESS + CONFIG_FILE_EXTENSION, KEY_FILE_2, PASSWORD_FILE_2);
    final FileBasedSigningMetadataFile metadataFile3 = copyMetadataFileToDirectory(configsDirectory, PREFIX_LOWERCASE_DUPLICATE_FILENAME_2, KEY_FILE_2, PASSWORD_FILE_2);
    final FileBasedSigningMetadataFile metadataFile4 = copyMetadataFileToDirectory(configsDirectory, PREFIX_LOWERCASE_DUPLICATE_FILENAME_1, KEY_FILE, PASSWORD_FILE);
    // duplicate files are loaded at this stage since addresses aren't checked until signers are
    // created
    final Collection<SigningMetadataFile> metadataFiles = loader.loadAvailableSigningMetadataTomlConfigs(filter);
    assertThat(metadataFiles).hasSize(4);
    assertThat(metadataFiles).containsOnly(metadataFile1, metadataFile2, metadataFile3, metadataFile4);
}
Also used : Path(java.nio.file.Path) Assertions.fail(org.junit.jupiter.api.Assertions.fail) MISSING_KEY_PATH_ADDRESS(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_KEY_PATH_ADDRESS) UNKNOWN_TYPE_SIGNER_FILENAME(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.UNKNOWN_TYPE_SIGNER_FILENAME) BeforeEach(org.junit.jupiter.api.BeforeEach) SUFFIX_ADDRESS(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.SUFFIX_ADDRESS) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) KEY_FILE(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.KEY_FILE) FileBasedSigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.FileBasedSigningMetadataFile) PASSWORD_FILE(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.PASSWORD_FILE) PREFIX_ADDRESS(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.PREFIX_ADDRESS) LOWERCASE_ADDRESS(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.LOWERCASE_ADDRESS) MISSING_KEY_AND_PASSWORD_PATH_FILENAME(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_KEY_AND_PASSWORD_PATH_FILENAME) Filter(java.nio.file.DirectoryStream.Filter) AzureSigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.AzureSigningMetadataFile) CONFIG_FILE_EXTENSION(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.CONFIG_FILE_EXTENSION) Path(java.nio.file.Path) MetadataFileFixture.copyMetadataFileToDirectory(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.copyMetadataFileToDirectory) Files(java.nio.file.Files) Resources(com.google.common.io.Resources) MISSING_KEY_PATH_FILENAME(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_KEY_PATH_FILENAME) Collection(java.util.Collection) PREFIX_LOWERCASE_DUPLICATE_FILENAME_1(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.PREFIX_LOWERCASE_DUPLICATE_FILENAME_1) PREFIX_LOWERCASE_DUPLICATE_FILENAME_2(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.PREFIX_LOWERCASE_DUPLICATE_FILENAME_2) MISSING_KEY_AND_PASSWORD_PATH_ADDRESS(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_KEY_AND_PASSWORD_PATH_ADDRESS) PASSWORD_FILE_2(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.PASSWORD_FILE_2) Test(org.junit.jupiter.api.Test) PREFIX_LOWERCASE_DUPLICATE_ADDRESS(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.PREFIX_LOWERCASE_DUPLICATE_ADDRESS) SigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.SigningMetadataFile) TempDir(org.junit.jupiter.api.io.TempDir) MISSING_PASSWORD_PATH_FILENAME(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_PASSWORD_PATH_FILENAME) Optional(java.util.Optional) KEY_FILE_2(tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.KEY_FILE_2) FileBasedSigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.FileBasedSigningMetadataFile) AzureSigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.AzureSigningMetadataFile) SigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.SigningMetadataFile) FileBasedSigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.FileBasedSigningMetadataFile) Test(org.junit.jupiter.api.Test)

Example 2 with PREFIX_ADDRESS

use of tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.PREFIX_ADDRESS in project signers by ConsenSys.

the class FileBasedSigningMetadataFileTest method matchingMetadataFileWithPrefixShouldHaveExpectedName.

@Test
void matchingMetadataFileWithPrefixShouldHaveExpectedName() {
    final String prefix = "bar_";
    final FileBasedSigningMetadataFile fileBasedSigningMetadataFile = load(prefix + PREFIX_ADDRESS + CONFIG_FILE_EXTENSION, KEY_FILE, PASSWORD_FILE);
    assertThat(fileBasedSigningMetadataFile.getFilename()).matches(prefix + PREFIX_ADDRESS + CONFIG_FILE_EXTENSION);
    assertThat(fileBasedSigningMetadataFile.getConfig().getKeystoreFile().toFile().toString()).matches(KEY_FILE);
    assertThat(fileBasedSigningMetadataFile.getConfig().getKeystorePasswordFile().toFile().toString()).matches(PASSWORD_FILE);
}
Also used : FileBasedSigningMetadataFile(tech.pegasys.signers.secp256k1.multikey.metadata.FileBasedSigningMetadataFile) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 FileBasedSigningMetadataFile (tech.pegasys.signers.secp256k1.multikey.metadata.FileBasedSigningMetadataFile)2 Resources (com.google.common.io.Resources)1 Filter (java.nio.file.DirectoryStream.Filter)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Collection (java.util.Collection)1 Optional (java.util.Optional)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.fail (org.junit.jupiter.api.Assertions.fail)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 TempDir (org.junit.jupiter.api.io.TempDir)1 CONFIG_FILE_EXTENSION (tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.CONFIG_FILE_EXTENSION)1 KEY_FILE (tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.KEY_FILE)1 KEY_FILE_2 (tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.KEY_FILE_2)1 LOWERCASE_ADDRESS (tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.LOWERCASE_ADDRESS)1 MISSING_KEY_AND_PASSWORD_PATH_ADDRESS (tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_KEY_AND_PASSWORD_PATH_ADDRESS)1 MISSING_KEY_AND_PASSWORD_PATH_FILENAME (tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_KEY_AND_PASSWORD_PATH_FILENAME)1 MISSING_KEY_PATH_ADDRESS (tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_KEY_PATH_ADDRESS)1 MISSING_KEY_PATH_FILENAME (tech.pegasys.signers.secp256k1.multikey.MetadataFileFixture.MISSING_KEY_PATH_FILENAME)1