Beispiel #1
0
        protected async Task DiskEncryptionSet_CreateDisk_Execute(string methodName, string location = null)
        {
            EnsureClientsInitialized(DefaultLocation);
            var  rgName   = Recording.GenerateAssetName(TestPrefix);
            var  diskName = Recording.GenerateAssetName(DiskNamePrefix);
            var  desName  = "longlivedSwaggerDES";
            Disk disk     = await GenerateDefaultDisk(DiskCreateOption.Empty.ToString(), rgName, 10);

            disk.Location = location;

            await ResourceGroupsOperations.CreateOrUpdateAsync(rgName, new ResourceGroup(location));

            // Get DiskEncryptionSet
            DiskEncryptionSet desOut = await DiskEncryptionSetsOperations.GetAsync("longrunningrg-southeastasia", desName);

            Assert.NotNull(desOut);
            disk.Encryption = new Encryption
            {
                Type = EncryptionType.EncryptionAtRestWithCustomerKey.ToString(),
                DiskEncryptionSetId = desOut.Id
            };
            //Put Disk
            await WaitForCompletionAsync(await DisksOperations.StartCreateOrUpdateAsync(rgName, diskName, disk));

            Disk diskOut = await DisksOperations.GetAsync(rgName, diskName);

            Validate(disk, diskOut, disk.Location);
            Assert.AreEqual(desOut.Id.ToLower(), diskOut.Encryption.DiskEncryptionSetId.ToLower());
            Assert.AreEqual(EncryptionType.EncryptionAtRestWithCustomerKey, diskOut.Encryption.Type);

            await WaitForCompletionAsync(await DisksOperations.StartDeleteAsync(rgName, diskName));
        }
Beispiel #2
0
        protected async Task DiskEncryptionSet_CRUD_Execute(string methodName, string location = null)
        {
            EnsureClientsInitialized(DefaultLocation);
            DiskRPLocation = location ?? DiskRPLocation;

            // Data
            var rgName            = Recording.GenerateAssetName(TestPrefix);
            var desName           = Recording.GenerateAssetName(DiskNamePrefix);
            DiskEncryptionSet des = GenerateDefaultDiskEncryptionSet(DiskRPLocation);
            await ResourceGroupsOperations.CreateOrUpdateAsync(rgName, new ResourceGroup(DiskRPLocation));

            // Put DiskEncryptionSet
            DiskEncryptionSet desOut = await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartCreateOrUpdateAsync(rgName, desName, des));

            Validate(des, desOut, desName);

            // Get DiskEncryptionSet
            desOut = await DiskEncryptionSetsOperations.GetAsync(rgName, desName);

            Validate(des, desOut, desName);

            // Patch DiskEncryptionSet
            const string tagKey    = "tageKey";
            var          updateDes = new DiskEncryptionSetUpdate();

            updateDes.Tags = new Dictionary <string, string>()
            {
                { tagKey, "tagvalue" }
            };
            desOut = await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartUpdateAsync(rgName, desName, updateDes));

            Validate(des, desOut, desName);
            Assert.AreEqual(1, desOut.Tags.Count);

            // Delete DiskEncryptionSet
            await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartDeleteAsync(rgName, desName));

            try
            {
                // Ensure it was really deleted
                await DiskEncryptionSetsOperations.GetAsync(rgName, desName);

                Assert.False(true);
            }
            catch (Exception ex)
            {
                Assert.NotNull(ex);
                //Assert.AreEqual(HttpStatusCode.NotFound, ex.Response.StatusCode);
            }
        }