use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project lowkey-vault by nagyesta.
the class SecretsStepDefs method theLastVersionOfTheSecretIsPreparedForAnUpdate.
@When("the last version of the secret is prepared for an update")
public void theLastVersionOfTheSecretIsPreparedForAnUpdate() {
final KeyVaultSecret lastResult = context.getLastResult();
final SecretProperties updatedProperties = context.getClient(context.getSecretServiceVersion()).getSecret(lastResult.getName(), lastResult.getProperties().getVersion()).getProperties();
context.setUpdateProperties(updatedProperties);
}
use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project lowkey-vault by nagyesta.
the class SecretsStepDefs method versionsCountVersionOfTheSecretIsCreated.
@Given("{int} version of the secret is created")
public void versionsCountVersionOfTheSecretIsCreated(final int versionsCount) {
final KeyVaultSecret secretCreateInfo = context.getCreateSecretOptions();
IntStream.range(0, versionsCount).forEach(i -> {
final KeyVaultSecret secret = context.getClient(context.getSecretServiceVersion()).setSecret(secretCreateInfo);
context.addCreatedEntity(secretCreateInfo.getName(), secret);
});
}
use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project lowkey-vault by nagyesta.
the class AbstractLowkeyVaultContainerTest method verifyConnectionIsWorking.
protected void verifyConnectionIsWorking(final String vaultUrl, final HttpClient httpClient, final TokenCredential credential) {
final SecretClient secretClient = new SecretClientBuilder().vaultUrl(vaultUrl).credential(credential).httpClient(httpClient).serviceVersion(SecretServiceVersion.V7_2).retryPolicy(new RetryPolicy(new FixedDelay(0, Duration.ZERO))).buildClient();
final KeyVaultSecret secret = secretClient.setSecret(NAME, VALUE);
Assertions.assertNotNull(secret);
}
use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project tessera by ConsenSys.
the class AzureKeyVaultService method getSecret.
@Override
public String getSecret(Map<String, String> azureGetSecretData) {
final String secretName = azureGetSecretData.get(SECRET_NAME_KEY);
final String secretVersion = azureGetSecretData.get(SECRET_VERSION_KEY);
final KeyVaultSecret secret;
try {
LOGGER.debug("SecretName : {} , SecretVersion: {}", secretName, secretVersion);
secret = secretClient.getSecret(secretName, secretVersion);
LOGGER.debug("secret.id {}", secret.getId());
} catch (ResourceNotFoundException e) {
throw new VaultSecretNotFoundException("Azure Key Vault secret " + secretName + " was not found in vault " + secretClient.getVaultUrl());
}
return secret.getValue();
}
use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project tessera by ConsenSys.
the class AzureKeyVaultServiceTest method setSecret.
@Test
public void setSecret() {
final String secretName = "secret-name";
final String secret = "secret-value";
final Map<String, String> setSecretData = Map.of(AzureKeyVaultService.SECRET_NAME_KEY, secretName, AzureKeyVaultService.SECRET_KEY, secret);
final KeyVaultSecret newSecret = mock(KeyVaultSecret.class);
when(secretClient.setSecret(secretName, secret)).thenReturn(newSecret);
final Object result = keyVaultService.setSecret(setSecretData);
assertThat(result).isSameAs(newSecret);
verify(secretClient).setSecret("secret-name", "secret-value");
}
Aggregations