use of com.microsoft.jenkins.keyvault.SecretStringCredentials in project azure-credentials-plugin by jenkinsci.
the class ITSecretStringCredentials method getSecretNotFound.
@Test
public void getSecretNotFound() {
final String secretIdentifier = vaultUri + "/secrets/not-found/869660651aa3436994bd7290704c9394";
// Verify configuration
final SecretStringCredentials.DescriptorImpl descriptor = new SecretStringCredentials.DescriptorImpl();
final FormValidation result = descriptor.doVerifyConfiguration(jenkinsAzureCredentialsId, secretIdentifier);
Assert.assertEquals(FormValidation.Kind.ERROR, result.kind);
// Get secret
final SecretStringCredentials credentials = new SecretStringCredentials(CredentialsScope.SYSTEM, "", "", jenkinsAzureCredentialsId, secretIdentifier);
try {
final Secret secret = credentials.getSecret();
Assert.fail("Should throw exception but not");
} catch (Exception e) {
// Expect exception
}
}
use of com.microsoft.jenkins.keyvault.SecretStringCredentials in project azure-credentials-plugin by jenkinsci.
the class ITSecretStringCredentials method getSecret.
@Test
public void getSecret() {
final KeyVaultSecret secretBundle = createSecret("secret-string", "I'm secret");
final String secretIdentifier = secretBundle.getId();
// Verify configuration
final SecretStringCredentials.DescriptorImpl descriptor = new SecretStringCredentials.DescriptorImpl();
final FormValidation result = descriptor.doVerifyConfiguration(jenkinsAzureCredentialsId, secretIdentifier);
Assert.assertEquals(FormValidation.Kind.OK, result.kind);
// Get secret
final SecretStringCredentials credentials = new SecretStringCredentials(CredentialsScope.SYSTEM, "", "", jenkinsAzureCredentialsId, secretIdentifier);
final Secret secret = credentials.getSecret();
Assert.assertEquals("I'm secret", secret.getPlainText());
}
Aggregations