Skip to content

Commit 9f55160

Browse files
committed
Rename KeyVault Mail parameter to EmailAddress
1 parent e86b3e9 commit 9f55160

File tree

7 files changed

+44
-40
lines changed

7 files changed

+44
-40
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,22 +440,23 @@ function Test-SetRemoveAccessPolicyByUPN
440440
Assert-AreEqual 0 $vault.AccessPolicies.Count
441441
}
442442

443-
function Test-SetRemoveAccessPolicyByEmail
443+
function Test-SetRemoveAccessPolicyByEmailAddress
444444
{
445445
Param($existingVaultName, $rgName, $email, $upn)
446446

447447
$PermToKeys = @("encrypt", "decrypt", "unwrapKey", "wrapKey", "verify", "sign", "get", "list", "update", "create", "import", "delete", "backup", "restore")
448448
$PermToSecrets = @("get", "list", "set", "delete")
449449
$PermToCertificates = @("get", "list", "create", "delete")
450+
$PermToStorage = @("get", "list", "delete")
450451

451-
$vault = Set-AzureRmKeyVaultAccessPolicy -VaultName $existingVaultName -ResourceGroupName $rgName -Mail $email -PermissionsToKeys $PermToKeys -PermissionsToSecrets $PermToSecrets -PermissionsToCertificates $PermToCertificates -PassThru
452+
$vault = Set-AzureRmKeyVaultAccessPolicy -VaultName $existingVaultName -ResourceGroupName $rgName -EmailAddress $email -PermissionsToKeys $PermToKeys -PermissionsToSecrets $PermToSecrets -PermissionsToCertificates $PermToCertificates -PermissionsToStorage $PermToStorage -PassThru
452453

453-
CheckVaultAccessPolicy $vault $PermToKeys $PermToSecrets $PermToCertificates
454+
CheckVaultAccessPolicy $vault $PermToKeys $PermToSecrets $PermToCertificates $PermToStorage
454455
if (-not $global:noADCmdLetMode) {
455456
Assert-AreEqual $vault.AccessPolicies[0].ObjectId (Get-AzureRmADUser -Mail $upn).Id
456457
}
457458

458-
$vault = Remove-AzureRmKeyVaultAccessPolicy -VaultName $existingVaultName -ResourceGroupName $rgName -Mail $email -PassThru
459+
$vault = Remove-AzureRmKeyVaultAccessPolicy -VaultName $existingVaultName -ResourceGroupName $rgName -EmailAddress $email -PassThru
459460
Assert-AreEqual 0 $vault.AccessPolicies.Count
460461
}
461462

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Scripts/RunKeyVaultTests.ps1

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ function Run-AllControlPlaneTests
183183
{
184184
Run-TestProtected { Run-VaultTest { Test_CreateNewPremiumVaultEnabledForDeployment } "Test_CreateNewPremiumVaultEnabledForDeployment" } "Test_CreateNewPremiumVaultEnabledForDeployment"
185185
}
186+
186187
Run-TestProtected { Run-VaultTest { Test_CreateNewVault } "Test_CreateNewVault" } "Test_CreateNewVault"
187188
Run-TestProtected { Run-VaultTest { Test_RecreateVaultFails } "Test_RecreateVaultFails" } "Test_RecreateVaultFails"
188189
Run-TestProtected { Run-VaultTest { Test_CreateVaultInUnknownResGrpFails } "Test_CreateVaultInUnknownResGrpFails" } "Test_CreateVaultInUnknownResGrpFails"
@@ -212,10 +213,8 @@ function Run-AllControlPlaneTests
212213
# Set-AzureRmKeyVaultAccessPolicy & Remove-AzureRmKeyVaultAccessPolicy tests.
213214
Run-TestProtected { Run-VaultTest { Test_SetRemoveAccessPolicyByUPN } "Test_SetRemoveAccessPolicyByUPN" } "Test_SetRemoveAccessPolicyByUPN"
214215

215-
<#
216-
This test is disabled because it requires a user with an email address that matches their UPN.
217-
Run-TestProtected { Run-VaultTest { Test_SetRemoveAccessPolicyByEmail } "Test_SetRemoveAccessPolicyByEmail" } "Test_SetRemoveAccessPolicyByEmail"
218-
#>
216+
# This test will fail for users that do not have the same email address as their UPN.
217+
Run-TestProtected { Run-VaultTest { Test_SetRemoveAccessPolicyByEmailAddress } "Test_SetRemoveAccessPolicyByEmailAddress" } "Test_SetRemoveAccessPolicyByEmailAddress"
219218

220219
Run-TestProtected { Run-VaultTest { Test_SetRemoveAccessPolicyBySPN } "Test_SetRemoveAccessPolicyBySPN" } "Test_SetRemoveAccessPolicyBySPN"
221220
Run-TestProtected { Run-VaultTest { Test_SetRemoveAccessPolicyByObjectId } "Test_SetRemoveAccessPolicyByObjectId" } "Test_SetRemoveAccessPolicyByObjectId"
@@ -228,7 +227,7 @@ function Run-AllControlPlaneTests
228227
Run-TestProtected { Run-VaultTest { Test_ModifyAccessPolicyNegativeCases } "Test_ModifyAccessPolicyNegativeCases" } "Test_ModifyAccessPolicyNegativeCases"
229228
Run-TestProtected { Run-VaultTest { Test_RemoveNonExistentAccessPolicyDoesNotThrow } "Test_RemoveNonExistentAccessPolicyDoesNotThrow" } "Test_RemoveNonExistentAccessPolicyDoesNotThrow"
230229
Run-TestProtected { Run-VaultTest { Test_AllPermissionExpansion } "Test_AllPermissionExpansion" } "Test_AllPermissionExpansion"
231-
230+
232231

233232
# Piping tests.
234233
Run-TestProtected { Run-VaultTest { Test_CreateDeleteVaultWithPiping } "Test_CreateDeleteVaultWithPiping" } "Test_CreateDeleteVaultWithPiping"
@@ -243,7 +242,7 @@ function Run-AllDataPlaneTests
243242
Write-Host "Starting the data plane tests..."
244243

245244
# All operations that invlove soft delete
246-
if($global:softDeleteEnabled -eq $true)
245+
if($global:softDeleteEnabled -eq $true)
247246
{
248247
# Key soft delete tests
249248
Run-TestProtected { Run-KeyTest {Test_GetDeletedKey} "Test_GetDeletedKey" } "Test_GetDeletedKey"
@@ -274,7 +273,7 @@ function Run-AllDataPlaneTests
274273
Run-TestProtected { Run-KeyTest {Test_ImportPfxAsHsmWithDefaultAttributes} "Test_ImportPfxAsHsmWithDefaultAttributes" } "Test_ImportPfxAsHsmWithDefaultAttributes"
275274
Run-TestProtected { Run-KeyTest {Test_ImportPfxAsHsmWithCustomAttributes} "Test_ImportPfxAsHsmWithCustomAttributes" } "Test_ImportPfxAsHsmWithCustomAttributes"
276275

277-
# All operations involving BYOK keys. For these tests to run correctly, the user running the tests
276+
# All operations involving BYOK keys. For these tests to run correctly, the user running the tests
278277
# must have a subscription ID that matches the subscription ID of the person who initially
279278
# generated the dummy *.byok files located in the proddata folder.
280279
#
@@ -484,7 +483,7 @@ try
484483
Restore-VaultResource $oldVaultResource
485484
}
486485
}
487-
486+
488487
if (@('DataPlane', 'All') -contains $TestMode)
489488
{
490489
$oldVaultResource = Get-VaultResource

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Scripts/VaultManagementTests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ function Test_SetRemoveAccessPolicyByUPN
126126
Test-SetRemoveAccessPolicyByUPN $global:testVault $global:resourceGroupName $user
127127
}
128128

129-
function Test_SetRemoveAccessPolicyByEmail
129+
function Test_SetRemoveAccessPolicyByEmailAddress
130130
{
131131
# ASSUMPTION: The logged in users UPN is the same as their email address.
132132
$user = (Get-AzureRmContext).Account.Id
133133
Reset-PreCreatedVault
134-
Test-SetRemoveAccessPolicyByEmail $global:testVault $global:resourceGroupName $user $user
134+
Test-SetRemoveAccessPolicyByEmailAddress $global:testVault $global:resourceGroupName $user $user
135135
}
136136

137137
function Test_SetRemoveAccessPolicyBySPN
@@ -238,7 +238,7 @@ function Test_AllPermissionExpansion
238238
{
239239
Reset-PreCreatedVault
240240
$user = (Get-AzureRmContext).Account.Id
241-
Test-AllPermissionExpansion $global:testVault $global:resourceGroupName $user
241+
Test-AllPermissionExpansion $global:testVault $global:resourceGroupName $user
242242
}
243243

244244
#-------------------------------------------------------------------------------------
@@ -454,7 +454,7 @@ function Cleanup-TemporaryState([bool]$tempResourceGroup, [bool]$tempVault)
454454
elseif ($tempVault)
455455
{
456456
Write-Host "Starting the deletion of the temporary vault. This can take a minute or so..."
457-
$vaultRemoved = Remove-AzureRmKeyVault -VaultName $global:testVault -Force -Confirm:$false
457+
$vaultRemoved = Remove-AzureRmKeyVault -VaultName $global:testVault -ResourceGroupName $global:resourceGroupname -Force -Confirm:$false
458458
if ($vaultRemoved)
459459
{
460460
$global:testVault = ""

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public class RemoveAzureKeyVaultAccessPolicy : KeyVaultManagementCmdletBase
9898
ValueFromPipelineByPropertyName = true,
9999
HelpMessage = "Specifies the email address of the user in Azure Active Directory for which to grant permissions.")]
100100
[ValidateNotNullOrEmpty()]
101-
public string Mail { get; set; }
101+
public string EmailAddress { get; set; }
102102

103103
/// <summary>
104104
/// Id of the application to which a user delegate to
@@ -174,11 +174,11 @@ public override void ExecuteCmdlet()
174174
if (!string.IsNullOrEmpty(UserPrincipalName)
175175
|| !string.IsNullOrEmpty(ServicePrincipalName)
176176
|| !string.IsNullOrWhiteSpace(this.ObjectId)
177-
|| !string.IsNullOrWhiteSpace(this.Mail))
177+
|| !string.IsNullOrWhiteSpace(this.EmailAddress))
178178
{
179179
if (string.IsNullOrWhiteSpace(this.ObjectId))
180180
{
181-
ObjectId = GetObjectId(this.ObjectId, this.UserPrincipalName, this.Mail, this.ServicePrincipalName);
181+
ObjectId = GetObjectId(this.ObjectId, this.UserPrincipalName, this.EmailAddress, this.ServicePrincipalName);
182182
}
183183
updatedPolicies = existingVault.AccessPolicies.Where(ap => !ShallBeRemoved(ap, ObjectId, this.ApplicationId)).ToArray();
184184
}

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class SetAzureKeyVaultAccessPolicy : KeyVaultManagementCmdletBase
9191
private const string ByObjectId = "ByObjectId";
9292
private const string ByServicePrincipalName = "ByServicePrincipalName";
9393
private const string ByUserPrincipalName = "ByUserPrincipalName";
94-
private const string ByEmail = "ByEmail";
94+
private const string ByEmailAddress = "ByEmailAddress";
9595
private const string ForVault = "ForVault";
9696

9797
#endregion
@@ -154,11 +154,11 @@ public class SetAzureKeyVaultAccessPolicy : KeyVaultManagementCmdletBase
154154
/// Email address
155155
/// </summary>
156156
[Parameter(Mandatory = true,
157-
ParameterSetName = ByEmail,
157+
ParameterSetName = ByEmailAddress,
158158
ValueFromPipelineByPropertyName = true,
159159
HelpMessage = "Specifies the email address of the user in Azure Active Directory for which to grant permissions.")]
160160
[ValidateNotNullOrEmpty()]
161-
public string Mail { get; set; }
161+
public string EmailAddress { get; set; }
162162

163163
/// <summary>
164164
/// Id of the application to which a user delegate to
@@ -185,7 +185,7 @@ public class SetAzureKeyVaultAccessPolicy : KeyVaultManagementCmdletBase
185185
ValueFromPipelineByPropertyName = true,
186186
HelpMessage = "Specifies key operation permissions to grant to a user or service principal.")]
187187
[Parameter(Mandatory = false,
188-
ParameterSetName = ByEmail,
188+
ParameterSetName = ByEmailAddress,
189189
ValueFromPipelineByPropertyName = true,
190190
HelpMessage = "Specifies key operation permissions to grant to a user or service principal.")]
191191
[ValidateSet("decrypt", "encrypt", "unwrapKey", "wrapKey", "verify", "sign", "get", "list", "update", "create", "import", "delete", "backup", "restore", "recover", "purge", "all")]
@@ -207,9 +207,9 @@ public class SetAzureKeyVaultAccessPolicy : KeyVaultManagementCmdletBase
207207
ValueFromPipelineByPropertyName = true,
208208
HelpMessage = "Specifies secret operation permissions to grant to a user or service principal.")]
209209
[Parameter(Mandatory = false,
210-
ParameterSetName = ByEmail,
210+
ParameterSetName = ByEmailAddress,
211211
ValueFromPipelineByPropertyName = true,
212-
HelpMessage = "Specifies key operation permissions to grant to a user or service principal.")]
212+
HelpMessage = "Specifies secret operation permissions to grant to a user or service principal.")]
213213
[ValidateSet("get", "list", "set", "delete", "backup", "restore", "recover", "purge", "all")]
214214
public string[] PermissionsToSecrets { get; set; }
215215

@@ -229,9 +229,9 @@ public class SetAzureKeyVaultAccessPolicy : KeyVaultManagementCmdletBase
229229
ValueFromPipelineByPropertyName = true,
230230
HelpMessage = "Specifies certificate operation permissions to grant to a user or service principal.")]
231231
[Parameter(Mandatory = false,
232-
ParameterSetName = ByEmail,
232+
ParameterSetName = ByEmailAddress,
233233
ValueFromPipelineByPropertyName = true,
234-
HelpMessage = "Specifies key operation permissions to grant to a user or service principal.")]
234+
HelpMessage = "Specifies certificate operation permissions to grant to a user or service principal.")]
235235
[ValidateSet("get", "list", "delete", "create", "import", "update", "managecontacts", "getissuers", "listissuers", "setissuers", "deleteissuers", "manageissuers", "all")]
236236
public string[] PermissionsToCertificates { get; set; }
237237

@@ -250,6 +250,10 @@ public class SetAzureKeyVaultAccessPolicy : KeyVaultManagementCmdletBase
250250
ParameterSetName = ByUserPrincipalName,
251251
ValueFromPipelineByPropertyName = true,
252252
HelpMessage = "Specifies managed storage account and sas definition operation permissions to grant to a user or service principal." )]
253+
[Parameter(Mandatory = false,
254+
ParameterSetName = ByEmailAddress,
255+
ValueFromPipelineByPropertyName = true,
256+
HelpMessage = "Specifies managed storage account and sas definition operation permissions to grant to a user or service principal.")]
253257
[ValidateSet( "get", "list", "delete", "set", "update", "regeneratekey", "getsas", "listsas", "deletesas", "setsas", "all" )]
254258
public string[] PermissionsToStorage { get; set; }
255259

@@ -319,12 +323,12 @@ public override void ExecuteCmdlet()
319323
if (!string.IsNullOrEmpty(UserPrincipalName)
320324
|| !string.IsNullOrEmpty(ServicePrincipalName)
321325
|| !string.IsNullOrWhiteSpace(this.ObjectId)
322-
|| !string.IsNullOrWhiteSpace(this.Mail))
326+
|| !string.IsNullOrWhiteSpace(this.EmailAddress))
323327
{
324328
var objId = this.ObjectId;
325329
if (!this.BypassObjectIdValidation.IsPresent)
326330
{
327-
objId = GetObjectId(this.ObjectId, this.UserPrincipalName, this.Mail, this.ServicePrincipalName);
331+
objId = GetObjectId(this.ObjectId, this.UserPrincipalName, this.EmailAddress, this.ServicePrincipalName);
328332
}
329333

330334
if (ApplicationId.HasValue && ApplicationId.Value == Guid.Empty)

src/ResourceManager/KeyVault/Commands.KeyVault/help/Remove-AzureRmKeyVaultAccessPolicy.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Remove-AzureRmKeyVaultAccessPolicy [-VaultName] <String> [[-ResourceGroupName] <
2424
-UserPrincipalName <String> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
2525
```
2626

27-
### ByUserMail
27+
### ByUserEmailAddress
2828
```
2929
Remove-AzureRmKeyVaultAccessPolicy [-VaultName] <String> [[-ResourceGroupName] <String>]
30-
-Mail <String> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
30+
-EmailAddress <String> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
3131
```
3232

3333
### ByObjectId
@@ -236,12 +236,12 @@ Accept pipeline input: True (ByPropertyName)
236236
Accept wildcard characters: False
237237
```
238238
239-
### -Mail
240-
Specifies the user email of the user whose access you want to remove.
239+
### -EmailAddress
240+
Specifies the user email address of the user whose access you want to remove.
241241
242242
```yaml
243243
Type: String
244-
Parameter Sets: ByUserMail
244+
Parameter Sets: ByUserEmailAddress
245245

246246
Required: True
247247
Position: Named

src/ResourceManager/KeyVault/Commands.KeyVault/help/Set-AzureRmKeyVaultAccessPolicy.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Set-AzureRmKeyVaultAccessPolicy [-VaultName] <String> [[-ResourceGroupName] <Str
2828
[<CommonParameters>]
2929
```
3030

31-
### ByUserMail
31+
### ByUserEmailAddress
3232
```
3333
Set-AzureRmKeyVaultAccessPolicy [-VaultName] <String> [[-ResourceGroupName] <String>]
34-
-Mail <String> [-PermissionsToKeys <String[]>] [-PermissionsToSecrets <String[]>]
34+
-EmailAddress <String> [-PermissionsToKeys <String[]>] [-PermissionsToSecrets <String[]>]
3535
[-PermissionsToCertificates <String[]>] [-PermissionsToStorage <String[]>] [-PassThru] [-WhatIf] [-Confirm]
3636
[<CommonParameters>]
3737
@@ -427,13 +427,13 @@ Accept pipeline input: True (ByPropertyName)
427427
Accept wildcard characters: False
428428
```
429429
430-
### -Mail
431-
Specifies the user email of the user to whom to grant permissions.
432-
This email must exist in the directory associated with the current subscription and be unique.
430+
### -EmailAddress
431+
Specifies the user email address of the user to whom to grant permissions.
432+
This email address must exist in the directory associated with the current subscription and be unique.
433433
434434
```yaml
435435
Type: String
436-
Parameter Sets: ByUserMail
436+
Parameter Sets: ByUserEmailAddress
437437

438438
Required: True
439439
Position: Named

0 commit comments

Comments
 (0)