Skip to content

Commit c3e3bed

Browse files
author
Maddie Clayton
authored
Merge pull request Azure#5799 from maddieclayton/KeyVault2
Key Vault breaking changes
2 parents d310ccb + f279b8b commit c3e3bed

File tree

86 files changed

+1610
-926
lines changed

Some content is hidden

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

86 files changed

+1610
-926
lines changed

src/ResourceManager/KeyVault/AzureRM.KeyVault.psd1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 3/20/2018
6+
# Generated on: 3/27/2018
77
#
88

99
@{
@@ -77,8 +77,7 @@ NestedModules = @('.\Microsoft.Azure.Commands.KeyVault.dll')
7777
FunctionsToExport = @()
7878

7979
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
80-
CmdletsToExport = 'Add-AzureKeyVaultCertificate',
81-
'Set-AzureKeyVaultCertificateAttribute',
80+
CmdletsToExport = 'Add-AzureKeyVaultCertificate', 'Update-AzureKeyVaultCertificate',
8281
'Stop-AzureKeyVaultCertificateOperation',
8382
'Get-AzureKeyVaultCertificateOperation',
8483
'Import-AzureKeyVaultCertificate',
@@ -100,9 +99,8 @@ CmdletsToExport = 'Add-AzureKeyVaultCertificate',
10099
'Undo-AzureKeyVaultKeyRemoval', 'Undo-AzureKeyVaultSecretRemoval',
101100
'Add-AzureKeyVaultKey', 'Remove-AzureKeyVaultKey',
102101
'Remove-AzureKeyVaultSecret', 'Restore-AzureKeyVaultKey',
103-
'Set-AzureKeyVaultKeyAttribute', 'Set-AzureKeyVaultSecret',
104-
'Set-AzureKeyVaultSecretAttribute',
105-
'Get-AzureKeyVaultCertificatePolicy',
102+
'Update-AzureKeyVaultKey', 'Set-AzureKeyVaultSecret',
103+
'Update-AzureKeyVaultSecret', 'Get-AzureKeyVaultCertificatePolicy',
106104
'New-AzureKeyVaultCertificateAdministratorDetails',
107105
'New-AzureKeyVaultCertificateOrganizationDetails',
108106
'Backup-AzureKeyVaultSecret', 'Restore-AzureKeyVaultSecret',
@@ -126,7 +124,9 @@ CmdletsToExport = 'Add-AzureKeyVaultCertificate',
126124
# VariablesToExport = @()
127125

128126
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
129-
AliasesToExport = 'Set-AzureKeyVaultKey'
127+
AliasesToExport = 'Set-AzureKeyVaultKey', 'Set-AzureKeyVaultSecretAttribute',
128+
'Set-AzureKeyVaultKeyAttribute',
129+
'Set-AzureKeyVaultCertificateAttribute'
130130

131131
# DSC resources to export from this module
132132
# DscResourcesToExport = @()

src/ResourceManager/KeyVault/Commands.KeyVault.Test/UnitTests/SetKeyVaultKeyAttributeTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.KeyVault.Test.UnitTests
2323
{
2424
public class SetKeyVaultKeyAttributeTests : KeyVaultUnitTestBase
2525
{
26-
private SetAzureKeyVaultKeyAttribute cmdlet;
26+
private UpdateAzureKeyVaultKey cmdlet;
2727
private PSKeyVaultKeyAttributes keyAttributes;
2828
private WebKey.JsonWebKey webKey;
2929
private PSKeyVaultKey keyBundle;
@@ -36,7 +36,7 @@ public SetKeyVaultKeyAttributeTests()
3636
webKey = new WebKey.JsonWebKey();
3737
keyBundle = new PSKeyVaultKey() { Attributes = keyAttributes, Key = webKey, Name = KeyName, VaultName = VaultName, Version = KeyVersion };
3838

39-
cmdlet = new SetAzureKeyVaultKeyAttribute()
39+
cmdlet = new UpdateAzureKeyVaultKey()
4040
{
4141
CommandRuntime = commandRuntimeMock.Object,
4242
DataServiceClient = keyVaultClientMock.Object,

src/ResourceManager/KeyVault/Commands.KeyVault.Test/UnitTests/SetKeyVaultSecretAttributeTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Microsoft.Azure.Commands.KeyVault.Test.UnitTests
2424
{
2525
public class SetKeyVaultSecretAttributeTests : KeyVaultUnitTestBase
2626
{
27-
private SetAzureKeyVaultSecretAttribute cmdlet;
27+
private UpdateAzureKeyVaultSecret cmdlet;
2828
private PSKeyVaultSecretAttributes secretAttributes;
2929
private PSKeyVaultSecret secret;
3030
public SetKeyVaultSecretAttributeTests()
@@ -34,7 +34,7 @@ public SetKeyVaultSecretAttributeTests()
3434
secretAttributes = new PSKeyVaultSecretAttributes(true, DateTime.UtcNow.AddYears(2), DateTime.UtcNow, "contenttype", null);
3535
secret = new PSKeyVaultSecret() { VaultName = VaultName, Name = SecretName, Version = SecretVersion, SecretValue = null, Attributes = secretAttributes };
3636

37-
cmdlet = new SetAzureKeyVaultSecretAttribute()
37+
cmdlet = new UpdateAzureKeyVaultSecret()
3838
{
3939
CommandRuntime = commandRuntimeMock.Object,
4040
DataServiceClient = keyVaultClientMock.Object,

src/ResourceManager/KeyVault/Commands.KeyVault.Test/UnitTests/SetKeyVaultSecretTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public SetKeyVaultSecretTests()
5050
ContentType = secretAttributes.ContentType,
5151
Tag = secretAttributes.Tags
5252
};
53+
cmdlet.MyInvocation.BoundParameters.Add("SecretValue", secret.SecretValue);
5354
}
5455

5556
[Fact]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<Compile Include="Commands\ManagedStorageAccounts\SetAzureKeyVaultManagedStorageSasDefinition.Service.Share.cs" />
7878
<Compile Include="Commands\ManagedStorageAccounts\SetAzureKeyVaultManagedStorageSasDefinition.Service.Share.File.cs" />
7979
<Compile Include="Commands\ManagedStorageAccounts\SetAzureKeyVaultManagedStorageSasDefinition.Service.Table.cs" />
80-
<Compile Include="Commands\SetAzureKeyVaultCertificateAttribute.cs" />
80+
<Compile Include="Commands\UpdateAzureKeyVaultCertificate.cs" />
8181
<Compile Include="Commands\StopAzureKeyVaultCertificateOperation.cs" />
8282
<Compile Include="Commands\GetAzureKeyVaultCertificateOperation.cs" />
8383
<Compile Include="Commands\ImportAzureKeyVaultCertificate.cs" />
@@ -99,6 +99,7 @@
9999
<Compile Include="Commands\UndoAzureKeyVaultRemoval.cs" />
100100
<Compile Include="Commands\UndoAzureKeyVaultKeyRemoval.cs" />
101101
<Compile Include="Commands\UndoAzureKeyVaultSecretRemoval.cs" />
102+
<Compile Include="Commands\UpdateAzureKeyVaultSecret.cs" />
102103
<Compile Include="Models\ManagedStorageAccounts\PSDeletedKeyVaultManagedStorageAccount.cs" />
103104
<Compile Include="Models\ManagedStorageAccounts\PSDeletedKeyVaultManagedStorageAccountIdentityItem.cs" />
104105
<Compile Include="Models\ManagedStorageAccounts\PSDeletedKeyVaultManagedStorageSasDefinition.cs" />
@@ -156,7 +157,7 @@
156157
<SubType>Designer</SubType>
157158
</None>
158159
<None Include="StartupScripts\*.ps1">
159-
<!-- <CopyToOutputDirectory>Always</CopyToOutputDirectory> -->
160+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
160161
</None>
161162
<Compile Include="Commands\BackupAzureKeyVaultKey.cs" />
162163
<Compile Include="Commands\GetAzureKeyVaultKey.cs" />
@@ -165,9 +166,8 @@
165166
<Compile Include="Commands\RemoveAzureKeyVaultKey.cs" />
166167
<Compile Include="Commands\RemoveAzureKeyVaultSecret.cs" />
167168
<Compile Include="Commands\RestoreAzureKeyVaultKey.cs" />
168-
<Compile Include="Commands\SetAzureKeyVaultKeyAttribute.cs" />
169+
<Compile Include="Commands\UpdateAzureKeyVaultKey.cs" />
169170
<Compile Include="Commands\SetAzureKeyVaultSecret.cs" />
170-
<Compile Include="Commands\SetAzureKeyVaultSecretAttribute.cs" />
171171
<Compile Include="Models\ByokWebKeyConverter.cs" />
172172
<Compile Include="Models\DataServiceCredential.cs" />
173173
<Compile Include="Models\IKeyVaultDataServiceClient.cs" />

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/AddAzureKeyVaultCertificate.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class AddAzureKeyVaultCertificate : KeyVaultCmdletBase
3333
/// </summary>
3434
[Parameter(Mandatory = true,
3535
Position = 0,
36-
ValueFromPipelineByPropertyName = true,
3736
HelpMessage = "Vault name. Cmdlet constructs the FQDN of a vault based on the name and currently selected environment.")]
3837
[ValidateNotNullOrEmpty]
3938
public string VaultName { get; set; }
@@ -43,7 +42,6 @@ public class AddAzureKeyVaultCertificate : KeyVaultCmdletBase
4342
/// </summary>
4443
[Parameter(Mandatory = true,
4544
Position = 1,
46-
ValueFromPipelineByPropertyName = true,
4745
HelpMessage = "Certificate name. Cmdlet constructs the FQDN of a certificate from vault name, currently selected environment and certificate name.")]
4846
[ValidateNotNullOrEmpty]
4947
[Alias(Constants.CertificateName)]
@@ -52,9 +50,8 @@ public class AddAzureKeyVaultCertificate : KeyVaultCmdletBase
5250
/// <summary>
5351
/// CertificatePolicy
5452
/// </summary>
55-
[Parameter(Mandatory = false,
53+
[Parameter(Mandatory = true,
5654
ValueFromPipeline = true,
57-
ValueFromPipelineByPropertyName = true,
5855
Position = 2,
5956
HelpMessage = "Specifies the certificate policy.")]
6057
[ValidateNotNull]
@@ -64,7 +61,6 @@ public class AddAzureKeyVaultCertificate : KeyVaultCmdletBase
6461
/// Certificate tags
6562
/// </summary>
6663
[Parameter(Mandatory = false,
67-
ValueFromPipelineByPropertyName = true,
6864
HelpMessage = "A hashtable representing certificate tags.")]
6965
[Alias(Constants.TagsAlias)]
7066
public Hashtable Tag { get; set; }
@@ -74,8 +70,7 @@ public override void ExecuteCmdlet()
7470
{
7571
if (ShouldProcess(Name, Properties.Resources.AddCertificate)) {
7672
var certificateOperation = this.DataServiceClient.EnrollCertificate(VaultName, Name, CertificatePolicy == null ? null : CertificatePolicy.ToCertificatePolicy(), Tag == null ? null : Tag.ConvertToDictionary());
77-
var kvCertificateOperation = PSKeyVaultCertificateOperation.FromCertificateOperation(certificateOperation);
78-
this.WriteObject(kvCertificateOperation);
73+
this.WriteObject(certificateOperation);
7974
}
8075
}
8176
}

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/AddAzureKeyVaultCertificateContact.cs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class AddAzureKeyVaultCertificateContact : KeyVaultCmdletBase
3737

3838
private const string InteractiveParameterSet = "Interactive";
3939
private const string InputObjectParameterSet = "ByObject";
40+
private const string ResourceIdParameterSet = "ByResourceId";
4041

4142
#endregion
4243

@@ -45,7 +46,6 @@ public class AddAzureKeyVaultCertificateContact : KeyVaultCmdletBase
4546
/// </summary>
4647
[Parameter(Mandatory = true,
4748
ParameterSetName = InteractiveParameterSet,
48-
ValueFromPipelineByPropertyName = true,
4949
Position = 0,
5050
HelpMessage = "Vault name. Cmdlet constructs the FQDN of a vault based on the name and currently selected environment.")]
5151
[ValidateNotNullOrEmpty]
@@ -62,12 +62,22 @@ public class AddAzureKeyVaultCertificateContact : KeyVaultCmdletBase
6262
[ValidateNotNullOrEmpty]
6363
public PSKeyVault InputObject { get; set; }
6464

65+
/// <summary>
66+
/// VaultResourceId
67+
/// </summary>
68+
[Parameter(Mandatory = true,
69+
ParameterSetName = ResourceIdParameterSet,
70+
Position = 0,
71+
ValueFromPipelineByPropertyName = true,
72+
HelpMessage = "KeyVault Resource Id.")]
73+
[ValidateNotNullOrEmpty]
74+
public string ResourceId { get; set; }
75+
6576
/// <summary>
6677
/// EmailAddress
6778
/// </summary>
6879
[Parameter(Mandatory = true,
6980
Position = 1,
70-
ValueFromPipelineByPropertyName = true,
7181
HelpMessage = "Specifies the email address of the contact.")]
7282
[ValidateNotNullOrEmpty]
7383
public string[] EmailAddress { get; set; }
@@ -84,14 +94,19 @@ public override void ExecuteCmdlet()
8494
{
8595
VaultName = InputObject.VaultName.ToString();
8696
}
97+
else if (ParameterSetName.Equals(ResourceIdParameterSet))
98+
{
99+
var resourceIdentifier = new ResourceIdentifier(ResourceId);
100+
VaultName = resourceIdentifier.ResourceName;
101+
}
87102

88103
if (ShouldProcess(VaultName, Properties.Resources.AddCertificateContact))
89104
{
90-
Contacts existingContacts;
105+
List<PSKeyVaultCertificateContact> existingContacts;
91106

92107
try
93108
{
94-
existingContacts = this.DataServiceClient.GetCertificateContacts(VaultName);
109+
existingContacts = this.DataServiceClient.GetCertificateContacts(VaultName)?.ToList();
95110
}
96111
catch (KeyVaultErrorException exception)
97112
{
@@ -103,32 +118,31 @@ public override void ExecuteCmdlet()
103118
existingContacts = null;
104119
}
105120

106-
List<Contact> newContactList;
121+
List<PSKeyVaultCertificateContact> newContactList;
107122

108-
if (existingContacts == null ||
109-
existingContacts.ContactList == null)
123+
if (existingContacts == null)
110124
{
111-
newContactList = new List<Contact>();
125+
newContactList = new List<PSKeyVaultCertificateContact>();
112126
}
113127
else
114128
{
115-
newContactList = new List<Contact>(existingContacts.ContactList);
129+
newContactList = new List<PSKeyVaultCertificateContact>(existingContacts);
116130
}
117131

118132
foreach (var email in EmailAddress)
119133
{
120134
if (newContactList.FindIndex(
121-
contact => (string.Compare(contact.EmailAddress, email, StringComparison.OrdinalIgnoreCase) == 0)) == -1)
135+
contact => (string.Compare(contact.Email, email, StringComparison.OrdinalIgnoreCase) == 0)) == -1)
122136
{
123-
newContactList.Add(new Contact { EmailAddress = email });
137+
newContactList.Add(new PSKeyVaultCertificateContact { Email = email });
124138
}
125139
}
126140

127-
var resultantContacts = this.DataServiceClient.SetCertificateContacts(VaultName, new Contacts { ContactList = newContactList });
141+
var resultantContacts = this.DataServiceClient.SetCertificateContacts(VaultName, newContactList);
128142

129143
if (PassThru.IsPresent)
130144
{
131-
this.WriteObject(PSKeyVaultCertificateContact.FromKVCertificateContacts(resultantContacts, VaultName), true);
145+
this.WriteObject(resultantContacts, true);
132146
}
133147
}
134148
}

0 commit comments

Comments
 (0)