Skip to content

Commit 5762e86

Browse files
committed
Merge pull request #190 from Azure/dev
.
2 parents 4263ca5 + e03d5d8 commit 5762e86

File tree

75 files changed

+51653
-25363
lines changed

Some content is hidden

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

75 files changed

+51653
-25363
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@
236236
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVaultByNameAndResourceGroupPositionalParams.json">
237237
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
238238
</None>
239+
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVaultByNameCapitalized.json">
240+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
241+
</None>
239242
<None Include="SessionRecords\Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests\TestGetVaultFromUnknownResourceGroupFails.json">
240243
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
241244
</None>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ public void TestGetVaultByName()
164164
);
165165
}
166166

167+
[Fact]
168+
[Trait(Category.AcceptanceType, Category.CheckIn)]
169+
public void TestGetVaultByNameCapitalized()
170+
{
171+
KeyVaultManagementController.NewInstance.RunPsTestWorkflow(
172+
() => new[] { string.Format("{0} {1}", "Test-GetVaultByName", _data.preCreatedVault.ToUpper()) },
173+
env => Initialize(),
174+
null,
175+
TestUtilities.GetCallingClass(),
176+
TestUtilities.GetCurrentMethodName()
177+
);
178+
}
179+
167180
[Fact]
168181
[Trait(Category.AcceptanceType, Category.CheckIn)]
169182
public void TestGetUnknownVaultFails()

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

Lines changed: 119 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/AddAzureKeyVaultKey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public class AddAzureKeyVaultKey : KeyVaultCmdletBase
112112
[Parameter(Mandatory = false,
113113
ParameterSetName = ImportParameterSet,
114114
HelpMessage = "Specifies whether to add the key as a software-protected key or an HSM-protected key in the Key Vault service. Valid values are: HSM and Software. ")]
115-
[ValidateSetAttribute(new string[] { HsmDestination, SoftwareDestination })]
115+
[ValidateSetAttribute(HsmDestination, SoftwareDestination)]
116116
public string Destination { get; set; }
117117

118118
/// <summary>

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/Constants.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
1+

72
namespace Microsoft.Azure.Commands.KeyVault
83
{
94
public static class Constants

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/GetAzureKeyVault.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System.Collections;
1717
using System.Collections.Generic;
1818
using System.Management.Automation;
19-
using Microsoft.Azure.Management.KeyVault;
2019
using PSKeyVaultModels = Microsoft.Azure.Commands.KeyVault.Models;
2120
using PSKeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
2221

@@ -89,8 +88,7 @@ protected override void ProcessRecord()
8988
ActiveDirectoryClient);
9089
if (vault == null)
9190
throw new ArgumentException(string.Format(PSKeyVaultProperties.Resources.VaultNotFound, VaultName, ResourceGroupName));
92-
else
93-
WriteObject(vault);
91+
WriteObject(vault);
9492
break;
9593

9694
case ListVaultsByRGParameterSet:

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/GetAzureKeyVaultKey.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ protected override void ProcessRecord()
105105
WriteObject(keyBundle);
106106
break;
107107
case ByKeyVersionsParameterSet:
108-
keyBundle = DataServiceClient.GetKey(VaultName, Name, null);
108+
keyBundle = DataServiceClient.GetKey(VaultName, Name, null);
109109
if (keyBundle != null)
110+
{
110111
WriteObject(new KeyIdentityItem(keyBundle));
111-
GetAndWriteKeyVersions(VaultName, Name, keyBundle.Version);
112+
GetAndWriteKeyVersions(VaultName, Name, keyBundle.Version);
113+
}
112114
break;
113115
case ByVaultNameParameterSet:
114116
GetAndWriteKeys(VaultName);
@@ -123,7 +125,7 @@ private void GetAndWriteKeys(string vaultName)
123125
{
124126
KeyVaultObjectFilterOptions options = new KeyVaultObjectFilterOptions
125127
{
126-
VaultName = VaultName,
128+
VaultName = vaultName,
127129
NextLink = null
128130
};
129131

@@ -138,7 +140,7 @@ private void GetAndWriteKeyVersions(string vaultName, string name, string curren
138140
{
139141
KeyVaultObjectFilterOptions options = new KeyVaultObjectFilterOptions
140142
{
141-
VaultName = VaultName,
143+
VaultName = vaultName,
142144
NextLink = null,
143145
Name = name
144146
};

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/GetAzureKeyVaultSecret.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ protected override void ProcessRecord()
105105
case BySecretVersionsParameterSet:
106106
secret = DataServiceClient.GetSecret(VaultName, Name, null);
107107
if (secret != null)
108+
{
108109
WriteObject(new SecretIdentityItem(secret));
109-
GetAndWriteSecretVersions(VaultName, Name, secret.Version);
110+
GetAndWriteSecretVersions(VaultName, Name, secret.Version);
111+
}
110112
break;
111113
case ByVaultNameParameterSet:
112114
GetAndWriteSecrets(VaultName);
@@ -119,9 +121,9 @@ protected override void ProcessRecord()
119121

120122
private void GetAndWriteSecrets(string vaultName)
121123
{
122-
KeyVaultObjectFilterOptions options = new KeyVaultObjectFilterOptions
124+
var options = new KeyVaultObjectFilterOptions
123125
{
124-
VaultName = VaultName,
126+
VaultName = vaultName,
125127
NextLink = null
126128
};
127129
do
@@ -132,9 +134,9 @@ private void GetAndWriteSecrets(string vaultName)
132134

133135
private void GetAndWriteSecretVersions(string vaultName, string name, string currentSecretVersion)
134136
{
135-
KeyVaultObjectFilterOptions options = new KeyVaultObjectFilterOptions
137+
var options = new KeyVaultObjectFilterOptions
136138
{
137-
VaultName = VaultName,
139+
VaultName = vaultName,
138140
Name = name,
139141
NextLink = null
140142
};

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/NewAzureKeyVault.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System;
1616
using System.Collections;
1717
using System.Management.Automation;
18-
using Microsoft.Azure.Management.KeyVault;
1918
using PSKeyVaultModels = Microsoft.Azure.Commands.KeyVault.Models;
2019
using PSKeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
2120

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RemoveAzureKeyVault.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System;
1616
using System.Globalization;
1717
using System.Management.Automation;
18-
using Microsoft.Azure.Management.KeyVault;
1918
using PSKeyVaultModels = Microsoft.Azure.Commands.KeyVault.Models;
2019
using PSKeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
2120

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RemoveAzureKeyVaultAccessPolicy.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System;
1616
using System.Linq;
1717
using System.Management.Automation;
18-
using Microsoft.Azure.Management.KeyVault;
1918
using PSKeyVaultModels = Microsoft.Azure.Commands.KeyVault.Models;
2019
using PSKeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
2120

@@ -152,7 +151,7 @@ protected override void ProcessRecord()
152151

153152
// Update vault policies
154153
var updatedPolicies = existingVault.AccessPolicies;
155-
if (!string.IsNullOrEmpty(UserPrincipalName) || !string.IsNullOrEmpty(ServicePrincipalName) || (ObjectId != null && ObjectId != Guid.Empty))
154+
if (!string.IsNullOrEmpty(UserPrincipalName) || !string.IsNullOrEmpty(ServicePrincipalName) || (ObjectId != Guid.Empty))
156155
{
157156
Guid objId = GetObjectId(this.ObjectId, this.UserPrincipalName, this.ServicePrincipalName);
158157

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RemoveAzureKeyVaultKey.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
1615
using System.Management.Automation;
1716
using Microsoft.Azure.Commands.KeyVault.Models;
1817
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RemoveAzureKeyVaultSecret.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
1615
using System.Management.Automation;
1716
using Microsoft.Azure.Commands.KeyVault.Models;
1817
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RestoreAzureKeyVaultKey.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.KeyVault.Models;
16-
using System;
1716
using System.IO;
1817
using System.Management.Automation;
1918
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/SetAzureKeyVaultAccessPolicy.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System;
1616
using System.Linq;
1717
using System.Management.Automation;
18-
using Microsoft.Azure.Management.KeyVault;
1918
using PSKeyVaultModels = Microsoft.Azure.Commands.KeyVault.Models;
2019
using PSKeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
2120

@@ -199,17 +198,15 @@ protected override void ProcessRecord()
199198
throw new ArgumentException(string.Format(PSKeyVaultProperties.Resources.PermissionSetIncludesAllPlusOthers, "secrets"));
200199

201200
//Is there an existing policy for this policy identity?
202-
var existingPolicy = vault.AccessPolicies.Where(ap => MatchVaultAccessPolicyIdentity(ap, objId, ApplicationId)).FirstOrDefault();
201+
var existingPolicy = vault.AccessPolicies.FirstOrDefault(ap => MatchVaultAccessPolicyIdentity(ap, objId, ApplicationId));
203202

204203
//New policy will have permission arrays that are either from cmdlet input
205204
//or if that's null, then from the old policy for this object ID if one existed
206-
var keys = PermissionsToKeys != null ? PermissionsToKeys :
207-
(existingPolicy != null && existingPolicy.PermissionsToKeys != null ?
205+
var keys = PermissionsToKeys ?? (existingPolicy != null && existingPolicy.PermissionsToKeys != null ?
208206
existingPolicy.PermissionsToKeys.ToArray() : null);
209207

210-
var secrets = PermissionsToSecrets != null ? PermissionsToSecrets :
211-
(existingPolicy != null && existingPolicy.PermissionsToSecrets != null ?
212-
existingPolicy.PermissionsToSecrets.ToArray() : null);
208+
var secrets = PermissionsToSecrets ?? (existingPolicy != null && existingPolicy.PermissionsToSecrets != null ?
209+
existingPolicy.PermissionsToSecrets.ToArray() : null);
213210

214211
//Remove old policies for this policy identity and add a new one with the right permissions, iff there were some non-empty permissions
215212
updatedListOfAccessPolicies = vault.AccessPolicies.Where(ap => !MatchVaultAccessPolicyIdentity(ap, objId, this.ApplicationId)).ToArray();
@@ -224,7 +221,7 @@ protected override void ProcessRecord()
224221

225222
// Update the vault
226223
var updatedVault = KeyVaultManagementClient.UpdateVault(vault, updatedListOfAccessPolicies,
227-
this.EnabledForDeployment.IsPresent ? true : vault.EnabledForDeployment,
224+
EnabledForDeployment.IsPresent || vault.EnabledForDeployment,
228225
EnabledForTemplateDeployment.IsPresent ? true : vault.EnabledForTemplateDeployment,
229226
EnabledForDiskEncryption.IsPresent ? true : vault.EnabledForDiskEncryption,
230227
ActiveDirectoryClient);

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/SetAzureKeyVaultSecretAttribute.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
using System;
1616
using System.Collections;
17-
using System.Security;
1817
using System.Management.Automation;
1918
using Microsoft.Azure.Commands.KeyVault.Models;
2019

src/ResourceManager/KeyVault/Commands.KeyVault/Models/DataServiceCredential.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public DataServiceCredential(IAuthenticationFactory authFactory, AzureContext co
3232

3333
var bundle = GetToken(authFactory, context);
3434
this.token = bundle.Item1;
35-
this.resourceId = bundle.Item2;
3635
}
3736

3837
/// <summary>
@@ -82,8 +81,6 @@ private Tuple<IAccessToken, string> GetToken(IAuthenticationFactory authFactory,
8281
}
8382

8483
private IAccessToken token;
85-
private string resourceId;
86-
8784
private const AzureEnvironment.Endpoint ResourceIdEndpoint = AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId;
8885
}
8986
}

src/ResourceManager/KeyVault/Commands.KeyVault/Models/IWebKeyConverter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
1615
using System.IO;
1716
using System.Security;
1817
using Microsoft.Azure.KeyVault.WebKey;

src/ResourceManager/KeyVault/Commands.KeyVault/Models/KeyAttributes.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System;
1616
using System.Collections;
1717
using System.Collections.Generic;
18-
using Microsoft.Azure.KeyVault;
1918

2019
namespace Microsoft.Azure.Commands.KeyVault.Models
2120
{
@@ -82,9 +81,9 @@ public Dictionary<string, string> TagsDirectionary
8281
}
8382
}
8483

85-
public static explicit operator Microsoft.Azure.KeyVault.KeyAttributes(KeyAttributes attr)
84+
public static explicit operator Azure.KeyVault.KeyAttributes(KeyAttributes attr)
8685
{
87-
return new Microsoft.Azure.KeyVault.KeyAttributes()
86+
return new Azure.KeyVault.KeyAttributes()
8887
{
8988
Enabled = attr.Enabled,
9089
NotBefore = attr.NotBefore,

src/ResourceManager/KeyVault/Commands.KeyVault/Models/KeyBundle.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
using System;
1616
using Microsoft.Azure.KeyVault.WebKey;
17-
using Microsoft.Azure.KeyVault;
1817
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
1918

2019
namespace Microsoft.Azure.Commands.KeyVault.Models
@@ -24,7 +23,7 @@ public class KeyBundle : ObjectIdentifier
2423
public KeyBundle()
2524
{ }
2625

27-
internal KeyBundle(Microsoft.Azure.KeyVault.KeyBundle keyBundle, VaultUriHelper vaultUriHelper)
26+
internal KeyBundle(Azure.KeyVault.KeyBundle keyBundle, VaultUriHelper vaultUriHelper)
2827
{
2928
if (keyBundle == null)
3029
throw new ArgumentNullException("keyBundle");

src/ResourceManager/KeyVault/Commands.KeyVault/Models/KeyIdentityItem.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
using System;
1616
using System.Collections;
17-
using Microsoft.Azure.KeyVault.WebKey;
18-
using Microsoft.Azure.KeyVault;
1917
using KeyVaultProperties = Microsoft.Azure.Commands.KeyVault.Properties;
2018

2119
namespace Microsoft.Azure.Commands.KeyVault.Models
2220
{
2321
public class KeyIdentityItem : ObjectIdentifier
2422
{
25-
internal KeyIdentityItem(Microsoft.Azure.KeyVault.KeyItem keyItem, VaultUriHelper vaultUriHelper)
23+
internal KeyIdentityItem(Azure.KeyVault.KeyItem keyItem, VaultUriHelper vaultUriHelper)
2624
{
2725
if (keyItem == null)
2826
throw new ArgumentNullException("keyItem");

src/ResourceManager/KeyVault/Commands.KeyVault/Models/KeyVaultCmdletBase.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,13 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Common.Authentication;
16-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
17-
using System;
18-
using System.IO;
1916
using System.Net.Http;
2017
using Microsoft.Azure.Commands.ResourceManager.Common;
2118

2219
namespace Microsoft.Azure.Commands.KeyVault.Models
2320
{
2421
public class KeyVaultCmdletBase : AzureRMCmdlet
25-
{
26-
public KeyVaultCmdletBase()
27-
{
28-
}
29-
22+
{
3023
internal IKeyVaultDataServiceClient DataServiceClient
3124
{
3225
get

0 commit comments

Comments
 (0)