Skip to content

Commit

Permalink
adding tests for restore point with securityprofile (#28949)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshulsolanki21 authored Jun 1, 2022
1 parent 0d49632 commit f054262
Show file tree
Hide file tree
Showing 2 changed files with 3,945 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,62 @@ public void CreateRpcAndRestorePoints()
}
}

/// <summary>
/// Create restore point for VM with SecurityType as TrustedLaunch
/// Verify SecurityType of DiskRestorePoint
/// </summary>
[Fact]
[Trait("Name", "CreateLocalRestorePointWithSecurityProfile")]
public void CreateLocalRestorePointWithSecurityProfile()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
string location = "southcentralus";
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", location);
EnsureClientsInitialized(context);
var rgName = ComputeManagementTestUtilities.GenerateName(TestPrefix);
ImageReference imageRef = new ImageReference(publisher: "MICROSOFTWINDOWSDESKTOP", offer: "WINDOWS-10", version: "latest", sku: "20H2-ENT-G2");
VirtualMachine inputVM;
string storageAccountForDisks = TestUtilities.GenerateName(TestPrefix);
string availabilitySetName = TestUtilities.GenerateName(TestPrefix);

try
{
// PUT VM with SecurityType = TrustedLaunch
VirtualMachine createdVM = CreateVM(rgName, availabilitySetName, storageAccountForDisks, imageRef, out inputVM, hasManagedDisks: true,
vmSize: VirtualMachineSizeTypes.StandardD2sV3, securityType: "TrustedLaunch");

string rpcName = ComputeManagementTestUtilities.GenerateName("rpcClientTest");
string rpName = ComputeManagementTestUtilities.GenerateName("rpClientTest");

// Create Restore Point Collection
string vmId = createdVM.Id;
string vmSize = createdVM.HardwareProfile.VmSize;
Dictionary<string, string> tags = new Dictionary<string, string>() { { "testTag", "testTagValue" } };
RestorePointCollection createdRpc = CreateRpc(vmId, rpcName, rgName, location, tags);

// Create Restore Point
RestorePoint createdRP = CreateRestorePoint(rgName, rpcName, rpName, diskToExclude: null, sourceRestorePointId: null);

// GET Disk Restore Point
IPage<DiskRestorePoint> listDiskRestorePoint = m_CrpClient.DiskRestorePoint.ListByRestorePoint(rgName, rpcName, rpName);
var getDrp = m_CrpClient.DiskRestorePoint.Get(rgName, rpcName, rpName, listDiskRestorePoint.First().Name);

Assert.Equal("TrustedLaunch",getDrp.SecurityProfile.SecurityType);
}
catch (Exception e)
{
throw e;
}
finally
{
m_ResourcesClient.ResourceGroups.Delete(rgName);
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", originalTestLocation);
}
}
}

// Verify that the two rpcs created by this test are in the GET restorePointCollections response.
private void VerifyReturnedRpcs(IEnumerable<RestorePointCollection> rpcs, string rpcName1, string rpcName2, string remoteRcpName, string location,
string remoteLocation, string sourceVMId, string sourceRpcId)
Expand Down
Loading

0 comments on commit f054262

Please sign in to comment.