Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote/network june fix #12853

Merged
merged 14 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# To make sure Network PRs go to the right branch, e.g. network-april
/src/Network/ @number213

/src/Network/ @MikhailTryakhov
/src/Compute/ @bilaakpan-ms @sandido @dkulkarni-ms @haagha @madewithsmiles @MS-syh2qs @grizzlytheodore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static bool HasProperty(this PSObject source, string name)
/// </summary>
/// <typeparam name="T">The type of the property to look for</typeparam>
/// <param name="source">The PSObject to check</param>
/// <param name="name">The name of the proeprty to look for</param>
/// <param name="name">The name of the property to look for</param>
/// <returns>true if the PSObject has a property with the given name, otherwise false</returns>
public static bool HasProperty<T>(this PSObject source, string name)
{
Expand Down Expand Up @@ -211,7 +211,7 @@ public static void Populate(this IDictionary<string, string> dictionary, string
/// Populate a list from a proprty of the given PSObject
/// </summary>
/// <param name="list">The list to populate</param>
/// <param name="name">The name of the proeprty contiaing the list</param>
/// <param name="name">The name of the property contiaing the list</param>
/// <param name="other">The PSObject to populate the list from</param>
public static void Populate(this IList<string> list, string name, PSObject other)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Accounts/Authentication.Test/PSSerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ IAzureContext GetDefaultContext()
VersionProfile = "2017_09_25"
};

context.SetProperty("ContextProeprty1", "ContextProperty1Value1", "ContextProperty1Value2");
context.SetProperty("ContextProeprty2", "ContextProperty2Value1", "ContextProperty2Value2");
context.SetProperty("ContextProperty1", "ContextProperty1Value1", "ContextProperty1Value2");
context.SetProperty("ContextProperty2", "ContextProperty2Value1", "ContextProperty2Value2");

return context;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Accounts/Authentication/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Batch/Batch.Test/Batch.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.Azure.Batch" Version="13.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="11.0.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.0.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.CognitiveServices" Version="7.3.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.0.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Compute/Compute.Test/Compute.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="38.1.0" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.0.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
29 changes: 29 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,34 @@ public void TestDiskEncryptionSet()
{
TestRunner.RunTestScript("Test-DiskEncryptionSet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDiskEncryptionSetConfigEncryptionType()
{
TestRunner.RunTestScript("Test-DiskEncryptionSetConfigEncryptionType");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDiskAccessObject()
{
TestRunner.RunTestScript("Test-DiskAccessObject");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDiskConfigDiskAccessNetworkAccess()
{
TestRunner.RunTestScript("Test-DiskConfigDiskAccessNetworkAccess");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSnapshotConfigDiskAccessNetworkPolicy()
{
TestRunner.RunTestScript("Test-SnapshotConfigDiskAccessNetworkPolicy");
}

}
}
247 changes: 247 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,250 @@ function Test-DiskEncryptionSet
$encSet | Remove-AzDiskEncryptionSet -Force;
}
}

<#
.SYNOPSIS
Testing the EncryptionType parameter passed to the Config obejct is inherited by an associated DiskEncryptionSet object.
#>
function Test-DiskEncryptionSetConfigEncryptionType
{
# Setup
$loc = 'centraluseuap';
$rgname = 'adamGroupDES7';
$encryptionName = "enc" + $rgname;

$vaultName1 = 'kv15' + $rgname ;
$vaultName2 = 'kv16' + $rgname ;

try
{
<#
#
# Note: In order to record this test, you need to run the following commands to create KeyValut key and KeyVault secret in a separate Powershell window.
#
Note: In order to record this test, you need to run the following commands to create KeyValut key and KeyVault secret in a separate Powershell window.
$vaultName1 = 'kv15' + $rgname ;
$kekName1 = 'kek15' + $rgname;
$secretname1 = 'mysecret15';
$secretdata1 = 'mysecretvalue15';
$securestring1 = ConvertTo-SecureString $secretdata1 -Force -AsPlainText;

$vaultName2 = 'kv16' + $rgname;
$kekName2 = 'kek15' + $rgname; #not a typo
$secretname2 = 'mysecret16';
$secretdata2 = 'mysecretvalue16';
$securestring2 = ConvertTo-SecureString $secretdata1 -Force -AsPlainText;

New-AzResourceGroup -Name $rgname -Location $loc -Force;
$vault1 = New-AzKeyVault -VaultName $vaultName1 -ResourceGroupName $rgname -Location $loc -Sku Standard;
$vault2 = New-AzKeyVault -VaultName $vaultName2 -ResourceGroupName $rgname -Location $loc -Sku Standard;
$mocksourcevault1 = $vault1.ResourceId;
$mocksourcevault2 = $vault2.ResourceId;
$userPrincipalName = (Get-AzContext).Account.Id;
Set-AzKeyVaultAccessPolicy -VaultName $vaultName1 -ResourceGroupName $rgname -EnabledForDiskEncryption;
Set-AzKeyVaultAccessPolicy -VaultName $vaultName2 -ResourceGroupName $rgname -EnabledForDiskEncryption;
$kek1 = Add-AzKeyVaultKey -VaultName $vaultName1 -Name $kekName1 -Destination "Software";
$kek2 = Add-AzKeyVaultKey -VaultName $vaultName2 -Name $kekName2 -Destination "Software";
$secret1 = Set-AzKeyVaultSecret -VaultName $vaultName1 -Name $secretname1 -SecretValue $securestring1;
$secret2 = Set-AzKeyVaultSecret -VaultName $vaultName2 -Name $secretname2 -SecretValue $securestring2;
$mockkey1 = $kek1.Id
$mockkey2 = $kek2.Id
#>

$mockkey1 = "https://kv15adamgroupdes7.vault.azure.net/keys/kek15adamGroupDES7/74332f302a0e48999415f6f9bbf7430c";
$mockkey2 = "https://kv16adamgroupdes7.vault.azure.net/keys/kek15adamGroupDES7/84412eaa63f344bf8a1b15612f2b36cb";
$subId = Get-SubscriptionIdFromResourceGroup $rgname;
$mocksourcevault1 = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.KeyVault/vaults/' + $vaultName1;
$mocksourcevault2 = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.KeyVault/vaults/' + $vaultName2;

$encryptionType = "EncryptionAtRestWithPlatformAndCustomerKeys";

$encSetConfig = New-AzDiskEncryptionSetConfig -Location $loc -EncryptionType $encryptionType;

$encSetConfigValues = New-AzDiskEncryptionSetConfig -Location $loc -KeyUrl $mockkey1 -SourceVaultId $mocksourcevault1 -EncryptionType $encryptionType -IdentityType "SystemAssigned" `

$encSet = New-AzDiskEncryptionSet -ResourceGroupName $rgname -Name $encryptionName -DiskEncryptionSet $encSetConfigValues;

Assert-NotNull $encSetConfig;
Assert-AreEqual $encSetConfig.EncryptionType $encryptionType;

Assert-NotNull $encSet;
Assert-AreEqual $encryptionType $encSet.EncryptionType;

# Test default EncryptionType value
$encSetConfigDefault = New-AzDiskEncryptionSetConfig -Location $loc -KeyUrl $mockkey2 -SourceVaultId $mocksourcevault2 -IdentityType "SystemAssigned";
Assert-NotNull $encSetConfigDefault;
Assert-AreEqual $encSetDefaultConfig.EncryptionType $null;

$encryptionNameDefault = $encryptionName + "Default";
$encryptionTypeDefault = "EncryptionAtRestWithCustomerKey";

$encSetDefault = New-AzDiskEncryptionSet -ResourceGroupName $rgname -Name $encryptionNameDefault -DiskEncryptionSet $encSetConfigDefault;
Assert-NotNull $encSetDefault;
Assert-AreEqual $encSetDefault.EncryptionType $encryptionTypeDefault;

}
finally
{
# Cleanup
$encSet | Remove-AzDiskEncryptionSet -Force;
$encSetDefault | Remove-AzDiskEncryptionSet -Force;
}
}

<#
.SYNOPSIS
Testing diskAssess object
#>
function Test-DiskAccessObject
{
$rgname = Get-ComputeTestResourceName;
$rgname2 = $rgname + '2';
$diskname1Rg1 = 'diskaccess1' + $rgname;
$diskName2Rg1 = 'diskAccess2' + $rgname;
$diskName3Rg2 = 'diskAccess1' + $rgname2;

try
{
# Common
$loc = "northcentralus";
New-AzResourceGroup -Name $rgname -Location $loc -Force;
New-AzResourceGroup -Name $rgname2 -Location $loc -Force;

#Create DiskAccess1 in ResourceGroup1
New-AzDiskAccess -ResourceGroupName $rgname -Name $diskname1Rg1 -location $loc

#Use Get-AzDiskAccess on DiskAccess1 using Default ParameterSet
$diskAccess1 = Get-AzDiskAccess -ResourceGroupName $rgname -Name $diskname1Rg1
#Use Get-AzDiskAccess on DiskAccess1 using resourceId
$diskAccess1check = Get-AzDiskAccess -resourceId $diskAccess1.id

#check if diskAccess1 is good
Assert-NotNull $diskAccess1
Assert-AreEqual $diskAccess1.Name $diskname1Rg1

#ASSERT check if diskaccess1 and diskaccess1check are same
Assert-AreEqual $diskAccess1.id $diskAccess1check.id

#Create DiskAccess2 in ResourceGroup1
New-AzDiskAccess -ResourceGroupName $rgname -Name $diskname2Rg1 -location $loc

#Use Get-AzDiskAccess by resourceGroupName
$rg1Result = Get-AzDiskAccess -ResourceGroupName $rgname

Assert-AreEqual $rg1Result.count 2

#add DiskAccess3 to ResourceGroup2
New-AzDiskAccess -ResourceGroupName $rgname2 -Name $diskname3Rg2 -location $loc

#use get-azdiskaccess with no parameters. count should be >= 3
$allResult = Get-AzDiskAccess

Assert-True {$allResult.Count -gt 2;}

#remove-AzDiskAccess to DiskAccess1 by resourceId
Remove-AzDiskAccess -resourceid $diskAccess1.id

#Remove-AzDiskAccess to DiskAccess2 by default parameter set
Remove-AzDiskAccess -ResourceGroupName $rgname -Name $diskname2Rg1

#Get-AzDiskAccess by resource group. Count should be 0
$allResult = Get-AzDiskAccess -ResourceGroupName $rgname

Assert-AreEqual $allResult.count 0

}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
Clean-ResourceGroup $rgname2
}
}

<#
.SYNOPSIS
Testing DiskConfig property NetworkAccessPolicy
#>
function Test-DiskConfigDiskAccessNetworkAccess
{
# Setup
$rgname = Get-ComputeTestResourceName;
$diskname0 = 'disk0' + $rgname;

try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzResourceGroup -Name $rgname -Location $loc -Force;

#Testing disk access
$diskAccess = New-AzDiskAccess -ResourceGroupName $rgname -Name "diskaccessname" -location $loc
$diskconfig = New-AzDiskConfig -Location $loc -SkuName 'Standard_LRS' -OsType 'Windows' `
-UploadSizeInBytes 35183298347520 -CreateOption 'Upload' -DiskAccessId $diskAccess.Id;
New-AzDisk -ResourceGroupName $rgname -DiskName $diskname0 -Disk $diskconfig;
$disk = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskname0;

Assert-AreEqual $diskAccess.Id $disk.DiskAccessId;

Remove-AzDisk -ResourceGroupName $rgname -DiskName $diskname0 -Force;

$diskconfig2 = New-AzDiskConfig -Location $loc -SkuName 'Standard_LRS' -OsType 'Windows' `
-UploadSizeInBytes 35183298347520 -CreateOption 'Upload' -NetworkAccessPolicy "AllowAll";
New-AzDisk -ResourceGroupName $rgname -DiskName $diskname0 -Disk $diskconfig2;
$disk2 = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskname0;
Assert-AreEqual "AllowAll" $disk2.NetworkAccessPolicy;

}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Testing SnapshotConfig property NetworkAccessPolicy
#>
function Test-SnapshotConfigDiskAccessNetworkPolicy
{
# Setup
$rgname = Get-ComputeTestResourceName;
$snapshotname = 'snapshot' + $rgname;

try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzResourceGroup -Name $rgname -Location $loc -Force;

# Config and create test
$diskAccess = New-AzDiskAccess -ResourceGroupName $rgname -Name "diskaccessname" -location $loc

$snapshotconfig = New-AzSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty `
-EncryptionSettingsEnabled $true -HyperVGeneration "V2" -DiskAccessId $diskAccess.Id;

$snapshotconfig.EncryptionSettingsCollection.Enabled = $false;
$snapshotconfig.EncryptionSettingsCollection.EncryptionSettings = $null;
$snapshotconfig.CreationData.ImageReference = $null;
$job = New-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -Snapshot $snapshotconfig -AsJob;
$result = $job | Wait-Job;
Assert-AreEqual "Completed" $result.State;

$snapshot = Get-AzSnapshot -ResourceGroupName $rgname
Assert-AreEqual $diskAccess.Id $snapshot.DiskAccessId

# Remove test
$job = Remove-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -Force -AsJob;
$result = $job | Wait-Job;
Assert-AreEqual "Completed" $result.State;
$st = $job | Receive-Job;
Verify-PSOperationStatusResponse $st;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,14 @@ public void TestInvokeAzVmPatchAssessment()
{
TestRunner.RunTestScript("Test-InvokeAzVmPatchAssessment");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestPatchStatusGetAzVMinstanceview()
{
TestRunner.RunTestScript("Test-PatchStatusGetAzVMinstanceview");
}


}
}
Loading