use of tech.pegasys.web3signer.signing.BlsArtifactSigner in project web3signer by ConsenSys.
the class YamlSignerParserTest method azureSecretMetadataInfoReturnsMetadata.
@Test
void azureSecretMetadataInfoReturnsMetadata() throws IOException {
final BlsArtifactSigner artifactSigner = new BlsArtifactSigner(new BLSKeyPair(BLSSecretKey.fromBytes(Bytes32.fromHexString(PRIVATE_KEY))), SignerOrigin.AZURE);
when(blsArtifactSignerFactory.create(any(AzureSecretSigningMetadata.class))).thenReturn(artifactSigner);
final Map<String, String> azureMetaDataMap = new HashMap<>();
azureMetaDataMap.put("type", "azure-secret");
azureMetaDataMap.put("clientId", "sample-client-id");
azureMetaDataMap.put("clientSecret", "sample-client-secret");
azureMetaDataMap.put("tenantId", "sample-tenant-id");
azureMetaDataMap.put("vaultName", "sample-vault-name");
azureMetaDataMap.put("secretName", "TEST-KEY");
azureMetaDataMap.put("keyType", "BLS");
final String yamlMetadata = YAML_OBJECT_MAPPER.writeValueAsString(azureMetaDataMap);
final List<ArtifactSigner> result = signerParser.parse(yamlMetadata);
assertThat(result).containsOnly(artifactSigner);
verify(blsArtifactSignerFactory).create(hasCorrectAzureMetadataArguments(AzureAuthenticationMode.CLIENT_SECRET));
}
use of tech.pegasys.web3signer.signing.BlsArtifactSigner in project web3signer by ConsenSys.
the class YamlSignerParserTest method unencryptedMetaDataInfoWithPrivateKeyReturnsMetadata.
@Test
void unencryptedMetaDataInfoWithPrivateKeyReturnsMetadata() throws IOException {
final ArtifactSigner artifactSigner = new BlsArtifactSigner(new BLSKeyPair(BLSSecretKey.fromBytes(Bytes32.fromHexString(PRIVATE_KEY))), SignerOrigin.FILE_RAW);
when(blsArtifactSignerFactory.create(any(FileRawSigningMetadata.class))).thenReturn(artifactSigner);
final Map<String, String> unencryptedKeyMetadataFile = new HashMap<>();
unencryptedKeyMetadataFile.put("type", "file-raw");
unencryptedKeyMetadataFile.put("privateKey", PRIVATE_KEY);
final String yamlMetadata = YAML_OBJECT_MAPPER.writeValueAsString(unencryptedKeyMetadataFile);
final List<ArtifactSigner> result = signerParser.parse(yamlMetadata);
assertThat(result).containsOnly(artifactSigner);
verify(blsArtifactSignerFactory).create(hasPrivateKey(PRIVATE_KEY));
}
use of tech.pegasys.web3signer.signing.BlsArtifactSigner in project web3signer by ConsenSys.
the class YamlSignerParserTest method keyStoreMetaDataInfoReturnsMetadata.
@Test
void keyStoreMetaDataInfoReturnsMetadata() throws IOException {
final BlsArtifactSigner artifactSigner = new BlsArtifactSigner(new BLSKeyPair(BLSSecretKey.fromBytes(Bytes32.fromHexString(PRIVATE_KEY))), SignerOrigin.FILE_KEYSTORE);
when(blsArtifactSignerFactory.create(any(FileKeyStoreMetadata.class))).thenReturn(artifactSigner);
final Path keystoreFile = configDir.resolve("keystore.json");
final Path passwordFile = configDir.resolve("keystore.password");
final Map<String, String> keystoreMetadataFile = new HashMap<>();
keystoreMetadataFile.put("type", "file-keystore");
keystoreMetadataFile.put("keystoreFile", keystoreFile.toString());
keystoreMetadataFile.put("keystorePasswordFile", passwordFile.toString());
final String yamlMetadata = YAML_OBJECT_MAPPER.writeValueAsString(keystoreMetadataFile);
final List<ArtifactSigner> result = signerParser.parse(yamlMetadata);
assertThat(result).containsOnly(artifactSigner);
verify(blsArtifactSignerFactory).create(hasKeystoreAndPasswordFile(keystoreFile, passwordFile));
}
use of tech.pegasys.web3signer.signing.BlsArtifactSigner in project web3signer by ConsenSys.
the class BlsArtifactSignerFactoryTest method setup.
@BeforeEach
void setup() throws IOException {
vertx = Vertx.vertx();
interlockKeyProvider = new InterlockKeyProvider(vertx);
yubiHsmOpaqueDataProvider = new YubiHsmOpaqueDataProvider();
awsSecretsManagerProvider = new AwsSecretsManagerProvider(100);
artifactSignerFactory = new BlsArtifactSignerFactory(configDir, new NoOpMetricsSystem(), new HashicorpConnectionFactory(vertx), interlockKeyProvider, yubiHsmOpaqueDataProvider, awsSecretsManagerProvider, (args) -> new BlsArtifactSigner(args.getKeyPair(), args.getOrigin()));
}
Aggregations