Skip to content

Commit dc4027b

Browse files
author
Maddie Clayton
authored
Merge pull request #6357 from maddieclayton/kvcall
Fix for KeyVault issue 5159 and tests
2 parents 4c2d8a9 + 18b0f50 commit dc4027b

30 files changed

+6889
-3150
lines changed

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Common.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,3 +602,12 @@ function Get-Location
602602
return $location
603603
}
604604
}
605+
606+
function Normalize-Location
607+
{
608+
param([string]$location)
609+
$outputLocation = $location.ToLower()
610+
$outputLocation = $outputLocation -replace '\s', ''
611+
$outputLocation = $outputLocation -replace '-', ''
612+
$outputLocation = $outputLocation -replace '_', ''
613+
}

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

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
<Reference Include="Microsoft.Azure.Management.KeyVault">
7979
<HintPath>..\..\..\packages\Microsoft.Azure.Management.KeyVault.2.4.1-alpha\lib\net452\Microsoft.Azure.Management.KeyVault.dll</HintPath>
8080
</Reference>
81+
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
82+
<SpecificVersion>False</SpecificVersion>
83+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.6.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
84+
</Reference>
8185
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8286
<SpecificVersion>False</SpecificVersion>
8387
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.20.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -86,8 +90,8 @@
8690
<SpecificVersion>False</SpecificVersion>
8791
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.6179.26854-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
8892
</Reference>
89-
<Reference Include="Microsoft.Azure.Test.HttpRecorder">
90-
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.7-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
93+
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
94+
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.8.1\lib\net452\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
9195
<Private>True</Private>
9296
</Reference>
9397
<Reference Include="Microsoft.CSharp" />
@@ -103,8 +107,8 @@
103107
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
104108
<Private>True</Private>
105109
</Reference>
106-
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
107-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.1-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
110+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
111+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.7.2\lib\net452\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
108112
<Private>True</Private>
109113
</Reference>
110114
<Reference Include="Microsoft.Threading.Tasks">
@@ -190,7 +194,6 @@
190194
<None Include="Scripts\bvtdata\pfxtest.pfx" />
191195
<None Include="Scripts\bvtdata\pfxtest1024.pfx" />
192196
<None Include="Scripts\Common.ps1" />
193-
<None Include="Scripts\ControlPlane\Common.ps1" />
194197
<None Include="Scripts\ControlPlane\KeyVaultManagementTests.ps1">
195198
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
196199
</None>
@@ -206,55 +209,16 @@
206209
<None Include="Scripts\VaultManagementTests.ps1" />
207210
<None Include="Scripts\VaultSecretTests.ps1" />
208211
<None Include="Scripts\VaultUITests.ps1" />
209-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestCreateDeleteVaultWithPiping.json">
210-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
211-
</None>
212-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestCreateNewPremiumVaultEnabledForDeployment.json">
213-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
214-
</None>
215212
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestCreateNewVault.json">
216213
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
217214
</None>
218-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestCreateVaultInUnknownResGrpFails.json">
219-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
220-
</None>
221-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestCreateVaultPositionalParams.json">
222-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
223-
</None>
224-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestDeleteUnknownVaultFails.json">
225-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
226-
</None>
227-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestDeleteVaultByName.json">
228-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
229-
</None>
230-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetUnknownVaultFails.json">
231-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
232-
</None>
233-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVaultByName.json">
234-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
235-
</None>
236-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVaultByNameAndResourceGroup.json">
237-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
238-
</None>
239-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVaultByNameAndResourceGroupPositionalParams.json">
240-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
241-
</None>
242-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVaultByNameCapitalized.json">
215+
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestDeleteVault.json">
243216
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
244217
</None>
245-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVaultFromUnknownResourceGroupFails.json">
218+
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVault.json">
246219
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
247220
</None>
248-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestListAllVaultsInSubscription.json">
249-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
250-
</None>
251-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestListVaultsByResourceGroup.json">
252-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
253-
</None>
254-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestListVaultsByTag.json">
255-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
256-
</None>
257-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestListVaultsByUnknownResourceGroupFails.json">
221+
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestListVaults.json">
258222
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
259223
</None>
260224
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestModifyAccessPolicy.json">
@@ -269,9 +233,6 @@
269233
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestModifyAccessPolicyEnabledForTemplateDeployment.json">
270234
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
271235
</None>
272-
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestRecreateVaultFails.json">
273-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
274-
</None>
275236
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestRemoveAccessPolicyWithCompoundIdPolicies.json">
276237
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
277238
</None>

src/ResourceManager/KeyVault/Commands.KeyVault.Test/ScenarioTests/Common.ps1

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,6 @@ function Get-KeyVaultTestMode {
4949
return $testMode
5050
}
5151

52-
<#
53-
.SYNOPSIS
54-
Gets the location for the Vault. Default to West US if none found.
55-
#>
56-
function Get-Location
57-
{
58-
if ((Get-KeyVaultTestMode) -ne 'Playback')
59-
{
60-
$namespace = "Microsoft.KeyVault"
61-
$type = "vaults"
62-
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
63-
64-
if ($location -eq $null)
65-
{
66-
return "East US"
67-
}
68-
else
69-
{
70-
return $location.Locations[0]
71-
}
72-
}
73-
74-
return "East US"
75-
}
76-
7752
<#
7853
.SYNOPSIS
7954
Gets the default location for a provider

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using System.IO;
2727
using System.Linq;
2828
using Microsoft.Azure.Management.Internal.Resources;
29+
using RM = Microsoft.Azure.Management.ResourceManager;
2930

3031
namespace Microsoft.Azure.Commands.KeyVault.Test
3132
{
@@ -39,6 +40,8 @@ public class KeyVaultManagementController
3940

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

43+
public RM.ResourceManagementClient ResourceClient { get; private set; }
44+
4245
public KeyVaultManagementClient KeyVaultManagementClient { get; private set; }
4346

4447
public GraphRbacManagementClient GraphClient { get; private set; }
@@ -123,19 +126,27 @@ public void RunPsTestWorkflow(
123126
private void SetupManagementClients(MockContext context)
124127
{
125128
NewResourceManagementClient = GetResourceManagementClient(context);
129+
ResourceClient = GetResourceClient(context);
126130
GraphClient = GetGraphClient(context);
127131
KeyVaultManagementClient = GetKeyVaultManagementClient(context);
128132
_helper.SetupManagementClients(
129133
NewResourceManagementClient,
134+
ResourceClient,
130135
KeyVaultManagementClient,
131-
GraphClient);
136+
GraphClient
137+
);
132138
}
133139

134140
private ResourceManagementClient GetResourceManagementClient(MockContext context)
135141
{
136142
return context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
137143
}
138144

145+
private RM.ResourceManagementClient GetResourceClient(MockContext context)
146+
{
147+
return context.GetServiceClient<RM.ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
148+
}
149+
139150
private KeyVaultManagementClient GetKeyVaultManagementClient(MockContext context)
140151
{
141152
return context.GetServiceClient<KeyVaultManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
@@ -182,4 +193,4 @@ private GraphRbacManagementClient GetGraphClient(MockContext context)
182193
return client;
183194
}
184195
}
185-
}
196+
}

0 commit comments

Comments
 (0)