use of com.microsoft.azure.keyvault.requests.UpdateSecretRequest in project azure-sdk-for-java by Azure.
the class AsyncOperationsTest method secretAsync.
@Test
public void secretAsync() throws Exception {
String vault = getVaultUri();
String secretname = "mySecret";
String password = "password";
SetSecretRequest setSecretRequest = new SetSecretRequest.Builder(vault, secretname, password).build();
SecretBundle secretBundle = keyVaultClient.setSecretAsync(setSecretRequest, null).get();
Assert.assertNotNull(secretBundle);
UpdateSecretRequest updateSecretRequest = new UpdateSecretRequest.Builder(secretBundle.id()).build();
secretBundle = keyVaultClient.updateSecretAsync(updateSecretRequest, null).get();
Assert.assertNotNull(secretBundle);
secretBundle = keyVaultClient.getSecretAsync(secretBundle.id(), null).get();
Assert.assertNotNull(secretBundle);
List<SecretItem> secretItems = keyVaultClient.listSecretsAsync(vault, 2, null).get();
Assert.assertNotNull(secretItems);
List<SecretItem> secretVersionItems = keyVaultClient.listSecretVersionsAsync(vault, secretname, 2, null).get();
Assert.assertNotNull(secretVersionItems);
secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get();
Assert.assertNotNull(secretBundle);
try {
keyVaultClient.deleteSecretAsync(vault, secretname, null).get();
} catch (ExecutionException ex) {
Throwable t = ex.getCause();
if (t instanceof KeyVaultErrorException) {
Assert.assertEquals("SecretNotFound", ((KeyVaultErrorException) t).body().error().code());
} else
throw ex;
}
}
Aggregations