Search in sources :

Example 1 with Vault

use of com.azure.resourcemanager.keyvault.models.Vault in project azure-credentials-plugin by jenkinsci.

the class KeyVaultIntegrationTestBase method setUp.

@Before
public void setUp() throws InterruptedException {
    // Create Azure KeyVault
    final AzureResourceManager azureClient = IntegrationTestBase.getAzureClient();
    vaultName = "tst-vault-" + TestEnvironment.GenerateRandomString(5);
    final Vault vault = azureClient.vaults().define(vaultName).withRegion(testEnv.region).withNewResourceGroup(testEnv.resourceGroup).defineAccessPolicy().forServicePrincipal(testEnv.clientId).allowSecretAllPermissions().attach().create();
    vaultUri = vault.vaultUri();
    waitForKeyVaultAvailable();
    // Create Jenkins Azure Credentials
    final AzureCredentials credentials = new AzureCredentials(CredentialsScope.SYSTEM, jenkinsAzureCredentialsId, "", testEnv.subscriptionId, testEnv.clientId, Secret.fromString(testEnv.clientSecret));
    credentials.setTenant(testEnv.tenantId);
    final CredentialsStore store = CredentialsProvider.lookupStores(j.jenkins).iterator().next();
    try {
        store.addCredentials(Domain.global(), credentials);
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : AzureCredentials(com.microsoft.azure.util.AzureCredentials) CredentialsStore(com.cloudbees.plugins.credentials.CredentialsStore) Vault(com.azure.resourcemanager.keyvault.models.Vault) IOException(java.io.IOException) AzureResourceManager(com.azure.resourcemanager.AzureResourceManager) Before(org.junit.Before)

Aggregations

AzureResourceManager (com.azure.resourcemanager.AzureResourceManager)1 Vault (com.azure.resourcemanager.keyvault.models.Vault)1 CredentialsStore (com.cloudbees.plugins.credentials.CredentialsStore)1 AzureCredentials (com.microsoft.azure.util.AzureCredentials)1 IOException (java.io.IOException)1 Before (org.junit.Before)1