Search in sources :

Example 16 with KeyVaultSecret

use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project lowkey-vault by nagyesta.

the class SecretsStepDefs method secretIsRecovered.

@When("secret is recovered")
public void secretIsRecovered() {
    final DeletedSecret deleted = context.getLastDeleted();
    final KeyVaultSecret secret = context.getClient(context.getSecretServiceVersion()).beginRecoverDeletedSecret(deleted.getName()).waitForCompletion().getValue();
    context.addFetchedSecret(secret.getName(), secret);
}
Also used : KeyVaultSecret(com.azure.security.keyvault.secrets.models.KeyVaultSecret) DeletedSecret(com.azure.security.keyvault.secrets.models.DeletedSecret) When(io.cucumber.java.en.When)

Example 17 with KeyVaultSecret

use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project lowkey-vault by nagyesta.

the class SecretsStepDefs method fetchFirstSecretVersion.

@When("the first secret version of {name} is fetched with providing a version")
public void fetchFirstSecretVersion(final String name) {
    final List<KeyVaultSecret> versionsCreated = context.getCreatedEntities().get(name);
    final String version = versionsCreated.get(0).getProperties().getVersion();
    final KeyVaultSecret secret = context.getClient(context.getSecretServiceVersion()).getSecret(name, version);
    context.addFetchedSecret(name, secret);
    assertEquals(version, secret.getProperties().getVersion());
}
Also used : KeyVaultSecret(com.azure.security.keyvault.secrets.models.KeyVaultSecret) When(io.cucumber.java.en.When)

Example 18 with KeyVaultSecret

use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project lowkey-vault by nagyesta.

the class SecretsStepDefs method secretCreationRequestIsSent.

@When("the secret is created")
public void secretCreationRequestIsSent() {
    final KeyVaultSecret secretCreateInfo = context.getCreateSecretOptions();
    final KeyVaultSecret secret = context.getClient(context.getSecretServiceVersion()).setSecret(secretCreateInfo);
    context.addCreatedEntity(secretCreateInfo.getName(), secret);
}
Also used : KeyVaultSecret(com.azure.security.keyvault.secrets.models.KeyVaultSecret) When(io.cucumber.java.en.When)

Example 19 with KeyVaultSecret

use of com.azure.security.keyvault.secrets.models.KeyVaultSecret in project tessera by ConsenSys.

the class AzureKeyVaultServiceTest method getSecret.

@Test
public void getSecret() {
    final String secretName = "secret-name";
    final String secretVersion = "secret-version";
    final Map<String, String> getSecretData = Map.of(AzureKeyVaultService.SECRET_NAME_KEY, secretName, AzureKeyVaultService.SECRET_VERSION_KEY, secretVersion);
    final String expectedSecretValue = "secret-value";
    final KeyVaultSecret gotSecret = mock(KeyVaultSecret.class);
    when(gotSecret.getValue()).thenReturn(expectedSecretValue);
    when(secretClient.getSecret(anyString(), anyString())).thenReturn(gotSecret);
    final String result = keyVaultService.getSecret(getSecretData);
    assertThat(result).isEqualTo(expectedSecretValue);
    verify(secretClient).getSecret(secretName, secretVersion);
}
Also used : KeyVaultSecret(com.azure.security.keyvault.secrets.models.KeyVaultSecret) Test(org.junit.Test)

Aggregations

KeyVaultSecret (com.azure.security.keyvault.secrets.models.KeyVaultSecret)19 Test (org.junit.Test)6 When (io.cucumber.java.en.When)5 SecretClient (com.azure.security.keyvault.secrets.SecretClient)4 FormValidation (hudson.util.FormValidation)3 Secret (hudson.util.Secret)3 ResourceNotFoundException (com.azure.core.exception.ResourceNotFoundException)2 SecretCertificateCredentials (com.microsoft.jenkins.keyvault.SecretCertificateCredentials)2 KeyStore (java.security.KeyStore)2 TokenCredential (com.azure.core.credential.TokenCredential)1 FixedDelay (com.azure.core.http.policy.FixedDelay)1 RetryPolicy (com.azure.core.http.policy.RetryPolicy)1 ClientSecretCredential (com.azure.identity.ClientSecretCredential)1 ClientSecretCredentialBuilder (com.azure.identity.ClientSecretCredentialBuilder)1 SecretClientBuilder (com.azure.security.keyvault.secrets.SecretClientBuilder)1 DeletedSecret (com.azure.security.keyvault.secrets.models.DeletedSecret)1 SecretProperties (com.azure.security.keyvault.secrets.models.SecretProperties)1 SecretStringCredentials (com.microsoft.jenkins.keyvault.SecretStringCredentials)1 VaultSecretNotFoundException (com.quorum.tessera.key.vault.VaultSecretNotFoundException)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1