forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackupProtectionContainerTests.cs
More file actions
68 lines (61 loc) · 3.06 KB
/
BackupProtectionContainerTests.cs
File metadata and controls
68 lines (61 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.TestFramework;
using Azure.ResourceManager.RecoveryServices;
using Azure.ResourceManager.RecoveryServices.Models;
using Azure.ResourceManager.RecoveryServicesBackup.Models;
using Azure.ResourceManager.Storage;
using Azure.ResourceManager.Storage.Models;
using NUnit.Framework;
namespace Azure.ResourceManager.RecoveryServicesBackup.Tests
{
[NonParallelizable]
public class BackupProtectionContainerTests : RecoveryServicesBackupManagementTestBase
{
public BackupProtectionContainerTests(bool isAsnyc)
: base(isAsnyc)//, RecordedTestMode.Record)
{
}
[RecordedTest]
public async Task CreateTest()
{
var sub = await Client.GetDefaultSubscriptionAsync();
var rg = await CreateResourceGroup(sub, "sdktest", AzureLocation.EastUS);
var storageName = Recording.GenerateAssetName("teststorage");
var storageData = new StorageAccountCreateOrUpdateContent(
new StorageSku(StorageSkuName.StandardGrs), StorageKind.StorageV2, AzureLocation.EastUS);
var storage = (await rg.GetStorageAccounts()
.CreateOrUpdateAsync(WaitUntil.Completed, storageName, storageData)).Value;
var vaultName = Recording.GenerateAssetName("testvalut");
var vaultData = new RecoveryServicesVaultData(AzureLocation.EastUS)
{
Sku = new RecoveryServicesSku(RecoveryServicesSkuName.RS0) { Tier = "Standard" },
Properties = new RecoveryServicesVaultProperties()
{
PublicNetworkAccess = VaultPublicNetworkAccess.Enabled
}
};
var vault = (await rg.GetRecoveryServicesVaults().CreateOrUpdateAsync(WaitUntil.Completed, vaultName, vaultData)).Value;
var containerName = $"StorageContainer;Storage;{rg.Data.Name};{storageName}";
var containerData = new BackupProtectionContainerData(AzureLocation.EastUS)
{
Properties = new StorageContainer()
{
FriendlyName = storageName,
BackupManagementType = BackupManagementType.AzureStorage,
SourceResourceId = storage.Id,
AcquireStorageAccountLock = AcquireStorageAccountLock.Acquire
}
};
var container = (await rg.GetBackupProtectionContainers()
.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, "Azure", containerName, containerData)).Value;
Assert.AreEqual(container.Data.Properties.RegistrationStatus, "Registered");
Assert.AreEqual(container.Data.Name, containerName);
// Remove the auto-lock before we delete the resource group
var deleteLock = (await storage.GetManagementLocks().GetAsync("AzureBackupProtectionLock")).Value;
await deleteLock.DeleteAsync(WaitUntil.Completed);
}
}
}