Skip to content

Commit

Permalink
Version 4.0.0 for Azure.Batch management (Azure#2836)
Browse files Browse the repository at this point in the history
* Regenerate management for Batch

* Regenerate Batch management with latest spec

* C# Batch management versioning and changelog

* Tests for new Batch management plane operations
  • Loading branch information
matthchr authored and shahabhijeet committed Feb 22, 2017
1 parent cc601fb commit e288264
Show file tree
Hide file tree
Showing 46 changed files with 3,412 additions and 1,846 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ public void AccountDeleteNotFoundValidateMessage()
}

[Fact]
public void AccountDeleteNoContentValidateMessage()
public void AccountDeleteOkValidateMessage()
{
var noContentResponse = new HttpResponseMessage(HttpStatusCode.NoContent)
var noContentResponse = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(@"")
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,84 @@ public async Task BatchAccountEndToEndAsync()
}
}
}

[Fact]
public async Task BatchAccountCanCreateWithBYOSEnabled()
{
using (MockContext context = StartMockContextAndInitializeClients(this.GetType().FullName))
{
string resourceGroupName = TestUtilities.GenerateName();
string batchAccountName = TestUtilities.GenerateName();
string keyvaultName = TestUtilities.GenerateName();
ResourceGroup group = new ResourceGroup(this.Location);
await this.ResourceManagementClient.ResourceGroups.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, group);

try
{
//Register with keyvault just in case we haven't already
await this.ResourceManagementClient.Providers.RegisterWithHttpMessagesAsync("Microsoft.KeyVault");

var result = await this.ResourceManagementClient.Resources.CreateOrUpdateWithHttpMessagesAsync(
resourceGroupName,
"Microsoft.KeyVault",
"",
"vaults",
keyvaultName,
"2015-06-01",
new GenericResource(this.Location)
{
Properties = new Dictionary<string, object>
{
{"tenantId", "72f988bf-86f1-41af-91ab-2d7cd011db47"},
{"sku", new Dictionary<string, object>{{"family", "A"}, {"name", "standard"}}},
{"accessPolicies", new []
{
new Dictionary<string, object>
{
{"objectId", "f520d84c-3fd3-4cc8-88d4-2ed25b00d27a"},
{"tenantId", "72f988bf-86f1-41af-91ab-2d7cd011db47"},
{"permissions", new Dictionary<string, object>
{
{"secrets", new [] { "All" }},
{"keys", new [] { "All" }},
}
}
}
}
},
{"enabledForDeployment", true},
{"enabledForTemplateDeployment", true},
{"enabledForDiskEncryption", true}
}
});

var keyVaultReferenceId =
$"/subscriptions/{this.BatchManagementClient.SubscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{keyvaultName}";
var keyVaultReferenceUrl = ((Newtonsoft.Json.Linq.JObject)result.Body.Properties)["vaultUri"] + "/";
// Create an account
BatchAccountCreateParameters createParams = new BatchAccountCreateParameters(
this.Location,
poolAllocationMode: PoolAllocationMode.UserSubscription,
keyVaultReference: new KeyVaultReference(
keyVaultReferenceId,
keyVaultReferenceUrl));

await this.BatchManagementClient.BatchAccount.CreateAsync(resourceGroupName, batchAccountName, createParams);

// Get the account and verify some properties
BatchAccount batchAccount = await this.BatchManagementClient.BatchAccount.GetAsync(resourceGroupName, batchAccountName);
Assert.Equal(batchAccountName, batchAccount.Name);
Assert.True(batchAccount.CoreQuota > 0);
Assert.Equal(PoolAllocationMode.UserSubscription, batchAccount.PoolAllocationMode);
Assert.Equal(keyVaultReferenceId, batchAccount.KeyVaultReference.Id);
Assert.Equal(keyVaultReferenceUrl, batchAccount.KeyVaultReference.Url);
}
finally
{
await this.ResourceManagementClient.ResourceGroups.DeleteWithHttpMessagesAsync(resourceGroupName);
}
}
}

}
}
Loading

0 comments on commit e288264

Please sign in to comment.