use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.
the class KeyManagerTestBase method setupSignerWithKeyManagerApi.
protected void setupSignerWithKeyManagerApi(final boolean insertSlashingProtectionData) throws URISyntaxException {
final SignerConfigurationBuilder builder = new SignerConfigurationBuilder();
builder.withKeyStoreDirectory(testDirectory).withMode("eth2").withAltairForkEpoch(MINIMAL_ALTAIR_FORK).withSlashingEnabled(true).withSlashingProtectionDbUsername(DB_USERNAME).withSlashingProtectionDbPassword(DB_PASSWORD).withKeyManagerApiEnabled(true);
startSigner(builder.build());
if (insertSlashingProtectionData) {
final SignerConfigurationBuilder importBuilder = new SignerConfigurationBuilder();
importBuilder.withMode("eth2").withSlashingEnabled(true).withSlashingProtectionDbUrl(signer.getSlashingDbUrl()).withSlashingProtectionDbUsername(DB_USERNAME).withSlashingProtectionDbPassword(DB_PASSWORD).withKeyStoreDirectory(testDirectory).withSlashingImportPath(getResourcePath("slashing/slashingImport_two_entries.json")).withHttpPort(// prevent wait for Ports file in AT
12345);
final Signer importSigner = new Signer(importBuilder.build(), null);
importSigner.start();
waitFor(() -> assertThat(importSigner.isRunning()).isFalse());
}
}
use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.
the class AzureKeyVaultAcceptanceTest method invalidVaultParametersFailsToStartSigner.
@Test
void invalidVaultParametersFailsToStartSigner() {
final AzureKeyVaultParameters azureParams = new DefaultAzureKeyVaultParameters("nonExistentVault", CLIENT_ID, TENANT_ID, CLIENT_SECRET);
final SignerConfigurationBuilder configBuilder = new SignerConfigurationBuilder().withMode("eth2").withAzureKeyVaultParameters(azureParams).withHttpPort(// required to prevent waiting for ports file.
9000);
final Signer signer = new Signer(configBuilder.build(), null);
signer.start();
waitFor(30, () -> assertThat(signer.isRunning()).isTrue());
waitFor(30, () -> assertThat(signer.isRunning()).isFalse());
}
use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.
the class DeleteKeystoresAcceptanceTest method deletingDisablesSigningForAllWeb3Signers.
@Test
public void deletingDisablesSigningForAllWeb3Signers() throws URISyntaxException, JsonProcessingException {
final String firstPubkey = createBlsKey("eth2/bls_keystore.json", "somepassword");
final String secondPubKey = createBlsKey("eth2/bls_keystore_2.json", "otherpassword");
setupSignerWithKeyManagerApi(WITH_SLASHING_PROTECTION_DATA);
final SignerConfiguration signer2Configuration = new SignerConfigurationBuilder().withKeyStoreDirectory(testDirectory).withMode("eth2").withNetwork("minimal").withAltairForkEpoch(MINIMAL_ALTAIR_FORK).withSlashingEnabled(true).withSlashingProtectionDbUrl(signer.getSlashingDbUrl()).withSlashingProtectionDbUsername(DB_USERNAME).withSlashingProtectionDbPassword(DB_PASSWORD).withKeyManagerApiEnabled(true).build();
final Signer signer2 = new Signer(signer2Configuration, null);
signer2.start();
signer2.awaitStartupCompletion();
callDeleteKeystores(composeRequestBody()).then().contentType(ContentType.JSON).assertThat().statusCode(200).body("data[0].status", is("deleted")).and().body("slashing_protection", is(singleEntrySlashingData));
callListKeys().then().statusCode(200).contentType(ContentType.JSON).body("data.size()", is(1)).and().body("data[0].validating_pubkey", is(secondPubKey));
callListKeys(signer2).then().statusCode(200).contentType(ContentType.JSON).body("data.size()", is(2)).and().body("data[0].validating_pubkey", is(firstPubkey)).body("data[1].validating_pubkey", is(secondPubKey));
final Eth2SigningRequestBody attestationRequest = Eth2RequestUtils.createCannedRequest(ArtifactType.ATTESTATION);
signer.eth2Sign(firstPubkey, attestationRequest, ContentType.TEXT).then().statusCode(404);
signer2.eth2Sign(firstPubkey, attestationRequest, ContentType.TEXT).then().statusCode(412);
final Eth2SigningRequestBody blockRequest = Eth2RequestUtils.createCannedRequest(ArtifactType.BLOCK_V2);
signer.eth2Sign(firstPubkey, blockRequest, ContentType.TEXT).then().statusCode(404);
signer2.eth2Sign(firstPubkey, blockRequest, ContentType.TEXT).then().statusCode(412);
}
use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.
the class AzureKeyVaultAcceptanceTest method invalidVaultParametersFailsToStartSigner.
@Test
void invalidVaultParametersFailsToStartSigner() {
final AzureKeyVaultParameters azureParams = new DefaultAzureKeyVaultParameters("nonExistentVault", CLIENT_ID, TENANT_ID, CLIENT_SECRET);
final SignerConfigurationBuilder configBuilder = new SignerConfigurationBuilder().withMode("eth2").withAzureKeyVaultParameters(azureParams).withHttpPort(// required to prevent waiting for ports file.
9000);
final Signer signer = new Signer(configBuilder.build(), null);
signer.start();
waitFor(30, () -> assertThat(signer.isRunning()).isTrue());
waitFor(30, () -> assertThat(signer.isRunning()).isFalse());
}
use of tech.pegasys.web3signer.dsl.signer.Signer in project web3signer by ConsenSys.
the class ServerSideTlsCaClientAcceptanceTest method createSigner.
private Signer createSigner(final TlsCertificateDefinition certInCa, final Path testDir, final boolean useConfigFile) throws Exception {
final Path passwordPath = testDir.resolve("keystore.passwd");
writeString(passwordPath, serverCert.getPassword());
final TlsOptions serverOptions = new BasicTlsOptions(serverCert.getPkcs12File(), passwordPath.toFile(), Optional.of(BasicClientAuthConstraints.caOnly()));
final SignerConfigurationBuilder configBuilder = new SignerConfigurationBuilder().withServerTlsOptions(serverOptions).withOverriddenCA(certInCa).withUseConfigFile(useConfigFile).withMode("eth2");
final ClientTlsConfig clientTlsConfig = new ClientTlsConfig(serverCert, clientCert);
return new Signer(configBuilder.build(), clientTlsConfig);
}
Aggregations