Skip to content

Commit eccbcfb

Browse files
author
Maddie Clayton
authored
Merge pull request #6925 from maddieclayton/mergkvpreview
Merge keyvault branch into preview
2 parents 0a9ed94 + 0e00cd3 commit eccbcfb

File tree

43 files changed

+4293
-1827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4293
-1827
lines changed

ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 6.7.0 - August 2018
1+
## 6.7.0 - August 2018
22
#### AzureRM.Profile
33
* Updated to the latest version of the Azure ClientRuntime.
44
* Add user id to default context name to avoid context clashing

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.Netcore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<ItemGroup>
2929
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
3030
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="21.0.0" />
31-
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.1-alpha" />
31+
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.1" />
3232
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.1.0-preview" />
3333
<PackageReference Include="Moq" Version="4.7.145" />
3434
</ItemGroup>

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.Netcore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<ItemGroup>
3434
<PackageReference Include="AutoMapper" Version="6.2.2" />
3535
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="21.0.0" />
36-
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.1-alpha" />
36+
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.1" />
3737
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="7.1.0-preview" />
3838
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
3939
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.1" />

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<Private>True</Private>
5858
</Reference>
5959
<Reference Include="Microsoft.Azure.Management.KeyVault, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
60-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.KeyVault.2.4.1-alpha\lib\net452\Microsoft.Azure.Management.KeyVault.dll</HintPath>
60+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.KeyVault.2.4.1\lib\net452\Microsoft.Azure.Management.KeyVault.dll</HintPath>
6161
<Private>True</Private>
6262
</Reference>
6363
<Reference Include="Microsoft.Azure.Management.Storage">

src/ResourceManager/Compute/Commands.Compute/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<packages>
33
<package id="AutoMapper" version="6.0.2" targetFramework="net452" />
44
<package id="Microsoft.Azure.Management.Compute" version="21.0.0" targetFramework="net452" />
5-
<package id="Microsoft.Azure.Management.KeyVault" version="2.4.1-alpha" targetFramework="net452" />
5+
<package id="Microsoft.Azure.Management.KeyVault" version="2.4.1" targetFramework="net452" />
66
<package id="Microsoft.Azure.Management.Storage" version="4.1.0-preview" targetFramework="net45" />
77
<package id="WindowsAzure.Storage" version="8.1.1" targetFramework="net452" />
88
</packages>

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Commands.KeyVault.Test.Netcore.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
</PropertyGroup>
2727

2828
<ItemGroup>
29-
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.0-alpha" />
30-
<PackageReference Include="Microsoft.Azure.KeyVault.WebKey" Version="3.0.0-alpha" />
31-
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.1-alpha" />
29+
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.0" />
30+
<PackageReference Include="Microsoft.Azure.KeyVault.WebKey" Version="3.0.0" />
31+
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.1" />
32+
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.0.2-preview" />
3233
</ItemGroup>
3334

3435
<ItemGroup>

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Commands.KeyVault.Test.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@
6363
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.KeyVault">
66-
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.3.0.0-alpha\lib\net452\Microsoft.Azure.KeyVault.dll</HintPath>
66+
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.3.0.0\lib\net452\Microsoft.Azure.KeyVault.dll</HintPath>
6767
</Reference>
6868
<Reference Include="Microsoft.Azure.KeyVault.WebKey">
69-
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.WebKey.3.0.0-alpha\lib\net452\Microsoft.Azure.KeyVault.WebKey.dll</HintPath>
69+
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.WebKey.3.0.0\lib\net452\Microsoft.Azure.KeyVault.WebKey.dll</HintPath>
7070
</Reference>
7171
<Reference Include="Microsoft.Azure.Management.Authorization">
7272
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
@@ -76,7 +76,10 @@
7676
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
7777
</Reference>
7878
<Reference Include="Microsoft.Azure.Management.KeyVault">
79-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.KeyVault.2.4.1-alpha\lib\net452\Microsoft.Azure.Management.KeyVault.dll</HintPath>
79+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.KeyVault.2.4.1\lib\net452\Microsoft.Azure.Management.KeyVault.dll</HintPath>
80+
</Reference>
81+
<Reference Include="Microsoft.Azure.Management.Network, Version=19.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
82+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.2-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
8083
</Reference>
8184
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8285
<SpecificVersion>False</SpecificVersion>
@@ -257,6 +260,9 @@
257260
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestSetRemoveAccessPolicyByUPN.json">
258261
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
259262
</None>
263+
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestNetworkSet.json">
264+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
265+
</None>
260266
</ItemGroup>
261267
<ItemGroup>
262268
<ProjectReference Include="..\..\..\Common\Commands.Common.Authentication.Abstractions\Commands.Common.Authentication.Abstractions.csproj">

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@
4747
// You can specify all the values or you can default the Build and Revision Numbers
4848
// by using the '*' as shown below:
4949

50-
[assembly: AssemblyVersion( "4.0.1.0" )]
51-
[assembly: AssemblyFileVersion("4.0.1")]
50+
[assembly: AssemblyVersion( "5.1.0" )]
51+
[assembly: AssemblyFileVersion("5.1.0")]
5252
[assembly: CollectionBehavior(DisableTestParallelization = true)]

src/ResourceManager/KeyVault/Commands.KeyVault.Test/ScenarioTests/KeyVaultManagementController.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
using Microsoft.Azure.ServiceManagemenet.Common.Models;
1919
using Microsoft.Azure.Test.HttpRecorder;
2020
using Microsoft.WindowsAzure.Commands.ScenarioTest;
21-
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
22-
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2321
using System;
2422
using System.Collections.Generic;
2523
using System.Diagnostics;
2624
using System.IO;
2725
using System.Linq;
2826
using Microsoft.Azure.Management.Internal.Resources;
27+
using Microsoft.Azure.Management.Network;
28+
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
29+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
2930
using RM = Microsoft.Azure.Management.ResourceManager;
3031

3132
namespace Microsoft.Azure.Commands.KeyVault.Test
@@ -40,12 +41,14 @@ public class KeyVaultManagementController
4041

4142
public ResourceManagementClient NewResourceManagementClient { get; private set; }
4243

43-
public RM.ResourceManagementClient ResourceClient { get; private set; }
44-
4544
public KeyVaultManagementClient KeyVaultManagementClient { get; private set; }
4645

4746
public GraphRbacManagementClient GraphClient { get; private set; }
4847

48+
public NetworkManagementClient NetworkManagementClient { get; private set; }
49+
50+
public RM.ResourceManagementClient ResourceClient { get; private set; }
51+
4952
public string UserDomain { get; private set; }
5053

5154
public static KeyVaultManagementController NewInstance => new KeyVaultManagementController();
@@ -105,7 +108,8 @@ public void RunPsTestWorkflow(
105108
"Scripts\\ControlPlane\\" + callingClassName + ".ps1",
106109
_helper.RMProfileModule,
107110
_helper.RMResourceModule,
108-
_helper.GetRMModulePath("AzureRM.KeyVault.psd1"));
111+
_helper.GetRMModulePath("AzureRM.KeyVault.psd1"),
112+
_helper.RMNetworkModule);
109113

110114
try
111115
{
@@ -130,16 +134,23 @@ private void SetupManagementClients(MockContext context)
130134
{
131135
NewResourceManagementClient = GetResourceManagementClient(context);
132136
ResourceClient = GetResourceClient(context);
137+
NetworkManagementClient = GetNetworkManagementClient(context);
133138
GraphClient = GetGraphClient(context);
134139
KeyVaultManagementClient = GetKeyVaultManagementClient(context);
135140
_helper.SetupManagementClients(
136141
NewResourceManagementClient,
137142
ResourceClient,
143+
NetworkManagementClient,
138144
KeyVaultManagementClient,
139145
GraphClient
140146
);
141147
}
142148

149+
private NetworkManagementClient GetNetworkManagementClient(MockContext context)
150+
{
151+
return context.GetServiceClient<NetworkManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
152+
}
153+
143154
private ResourceManagementClient GetResourceManagementClient(MockContext context)
144155
{
145156
return context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
@@ -163,10 +174,8 @@ private GraphRbacManagementClient GetGraphClient(MockContext context)
163174
if (HttpMockServer.Mode == HttpRecorderMode.Record)
164175
{
165176
tenantId = environment.Tenant;
166-
UserDomain = environment.UserName.Split(new[] { "@" }, StringSplitOptions.RemoveEmptyEntries).Last();
167177

168178
HttpMockServer.Variables[TenantIdKey] = tenantId;
169-
HttpMockServer.Variables[DomainKey] = UserDomain;
170179
}
171180
else if (HttpMockServer.Mode == HttpRecorderMode.Playback)
172181
{
@@ -196,4 +205,4 @@ private GraphRbacManagementClient GetGraphClient(MockContext context)
196205
return client;
197206
}
198207
}
199-
}
208+
}

src/ResourceManager/KeyVault/Commands.KeyVault.Test/ScenarioTests/KeyVaultManagementTests.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,35 @@ public void TestRemoveNonExistentAccessPolicyDoesNotThrow()
390390

391391
#endregion
392392

393+
#region Piping
394+
[Fact(Skip = "Graph authentication blocks test passes")]
395+
[Trait(Category.AcceptanceType, Category.CheckIn)]
396+
public void TestCreateDeleteVaultWithPiping()
397+
{
398+
KeyVaultManagementController.NewInstance.RunPsTestWorkflow(
399+
_logger,
400+
() => { return new[] { string.Format("{0} {1} {2}", "Test-CreateDeleteVaultWithPiping", _data.ResourceGroupName, _data.Location) }; },
401+
null,
402+
MethodBase.GetCurrentMethod().ReflectedType?.ToString(),
403+
MethodBase.GetCurrentMethod().Name
404+
);
405+
}
406+
407+
#endregion
408+
409+
[Fact]
410+
[Trait(Category.AcceptanceType, Category.CheckIn)]
411+
public void TestNetworkSet()
412+
{
413+
KeyVaultManagementController.NewInstance.RunPsTestWorkflow(
414+
_logger,
415+
() => { return new[] { "Test-NetworkRuleSet" }; },
416+
null,
417+
MethodBase.GetCurrentMethod().ReflectedType?.ToString(),
418+
MethodBase.GetCurrentMethod().Name
419+
);
420+
}
421+
393422
#region Helper Methods
394423
private string GetUserObjectId(KeyVaultManagementController controllerAdmin, string upn)
395424
{
@@ -451,4 +480,4 @@ private void DeleteAdServicePrincipal(KeyVaultManagementController controllerAdm
451480
}
452481

453482

454-
}
483+
}

src/ResourceManager/KeyVault/Commands.KeyVault.Test/ScenarioTests/KeyVaultTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void ResetPreCreatedVault()
133133
}
134134
public void Dispose()
135135
{
136-
Dispose(true);
136+
Dispose(false);
137137
GC.SuppressFinalize(this);
138138
}
139139

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Scripts/ControlPlane/KeyVaultManagementTests.ps1

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,4 +753,49 @@ function Compare-Vaults
753753
CheckVaultAccessPolicy $vault1 $vault2.AccessPolicies[0].PermissionsToKeys $vault2.AccessPolicies[0].PermissionsToSecrets $vault2.AccessPolicies[0].PermissionsToCertificates $vault2.AccessPolicies[0].PermissionsToStorage
754754
Assert-AreEqual $vault1.AccessPolicies[0].ObjectId $vault2.AccessPolicies[0].ObjectId
755755
}
756+
}
757+
758+
function Test-NetworkRuleSet
759+
{
760+
$resourceGroupName = getAssetName
761+
$resourceGroupLocation = Get-Location "Microsoft.Resources" "resourceGroups" "westus"
762+
$vaultName = getAssetName
763+
$vaultLocation = Get-Location "Microsoft.KeyVault" "vaults" "westus"
764+
$virtualNetworkName = getAssetName
765+
$virtualNetworkLocation = Get-Location "Microsoft.Network" "virtualNetworks" "westus"
766+
767+
try
768+
{
769+
$rg = New-AzureRmResourceGroup -Name $resourceGroupName -Location $resourceGroupLocation
770+
$vault = New-AzureRmKeyVault -VaultName $vaultName -ResourceGroupName $resourceGroupName -Location $vaultLocation
771+
772+
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24" -ServiceEndpoint Microsoft.KeyVault
773+
$virtualNetwork = New-AzureRmVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroupName -Location $virtualNetworkLocation -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet
774+
775+
$myNetworkResId = (Get-AzureRmVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroupName).Subnets[0].Id
776+
Add-AzureRmKeyVaultNetworkRule -VaultName $vaultName -IpAddressRange "10.0.1.0/24" -VirtualNetworkResourceId $myNetworkResId
777+
$vault = Get-AzureRmKeyVault -ResourceGroupName $resourceGroupName -Name $vaultName
778+
Assert-AreEqual $vault.NetworkAcls.IpAddressRanges.Count 1
779+
Assert-AreEqual $vault.NetworkAcls.IpAddressRanges[0] "10.0.1.0/24"
780+
Assert-AreEqual $vault.NetworkAcls.VirtualNetworkResourceIds.Count 1
781+
Assert-AreEqual $vault.NetworkAcls.VirtualNetworkResourceIds[0] $myNetworkResId
782+
Assert-AreEqual $vault.NetworkAcls.Bypass.toString() "AzureServices"
783+
Assert-AreEqual $vault.NetworkAcls.DefaultAction.toString() "Allow"
784+
785+
$networkRule = Update-AzureRmKeyVaultNetworkRuleSet -VaultName $vaultName -ResourceGroupName $resourceGroupName -Bypass None -DefaultAction Deny -PassThru
786+
Assert-AreEqual $networkRule.NetworkAcls.Bypass.toString() "None"
787+
Assert-AreEqual $networkRule.NetworkAcls.DefaultAction.toString() "Deny"
788+
$vault = Get-AzureRmKeyVault -ResourceGroupName $resourceGroupName -Name $vaultName
789+
Assert-AreEqual $vault.NetworkAcls.Bypass.toString() "None"
790+
Assert-AreEqual $vault.NetworkAcls.DefaultAction.toString() "Deny"
791+
792+
Remove-AzureRmKeyVaultNetworkRule -VaultName $vaultName -ResourceGroupName $resourceGroupName -IpAddressRange "10.0.1.0/24" -VirtualNetworkResourceId $myNetworkResId
793+
$vault = Get-AzureRmKeyVault -ResourceGroupName $resourceGroupName -Name $vaultName
794+
Assert-AreEqual $vault.NetworkAcls.IpAddressRanges.Count 0
795+
Assert-AreEqual $vault.NetworkAcls.VirtualNetworkResourceIds.Count 0
796+
}
797+
finally
798+
{
799+
Remove-AzureRmResourceGroup -Name $resourceGroupName -Force
800+
}
756801
}

src/ResourceManager/KeyVault/Commands.KeyVault.Test/SessionRecords/Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests/TestCreateNewVault.json

Lines changed: 327 additions & 332 deletions
Large diffs are not rendered by default.

src/ResourceManager/KeyVault/Commands.KeyVault.Test/SessionRecords/Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests/TestDeleteVault.json

Lines changed: 281 additions & 286 deletions
Large diffs are not rendered by default.

src/ResourceManager/KeyVault/Commands.KeyVault.Test/SessionRecords/Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests/TestGetVault.json

Lines changed: 281 additions & 283 deletions
Large diffs are not rendered by default.

src/ResourceManager/KeyVault/Commands.KeyVault.Test/SessionRecords/Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests/TestListVaults.json

Lines changed: 299 additions & 300 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)