Skip to content

Commit e1c4b71

Browse files
authored
* Get-AzPolicyAlias: optmize common path for single namespace * Update changelog. * Fox for Azure#15828 * Update changelog
1 parent 62607fa commit e1c4b71

File tree

4 files changed

+510
-440
lines changed

4 files changed

+510
-440
lines changed

src/Resources/ResourceManager/Implementation/Policy/SetAzurePolicyAssignment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class SetAzurePolicyAssignmentCmdlet : PolicyCmdletBase
5858
/// Gets or sets the policy assignment not scopes parameter.
5959
/// </summary>
6060
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = PolicyHelpStrings.SetPolicyAssignmentNotScopesHelp)]
61-
[ValidateNotNullOrEmpty]
61+
[ValidateNotNull]
6262
public string[] NotScope { get; set; }
6363

6464
/// <summary>

src/Resources/Resources.Test/ScenarioTests/PolicyTests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,7 @@ $someDisplayName = "Some display name"
17351735

17361736
# exception strings
17371737
$parameterSetError = 'Parameter set cannot be resolved using the specified named parameters.'
1738+
$parameterNullError = '. The argument is null. Provide a valid value for the argument, and then try running the command again.'
17381739
$missingParameters = 'Cannot process command because of one or more missing mandatory parameters:'
17391740
$onlyDefinitionOrSetDefinition = 'Only one of PolicyDefinition or PolicySetDefinition can be specified, not both.'
17401741
$policyAssignmentNotFound = 'PolicyAssignmentNotFound : '
@@ -1877,6 +1878,7 @@ function Test-SetPolicyAssignmentParameters
18771878
$someParameters = '{ "someKindaParameter": { "value": [ "Mmmm", "Doh!" ] } }'
18781879
$someLocation = 'west us'
18791880
$someNotScope = 'not scope'
1881+
$emptyNotScope = @()
18801882

18811883
# validate with no parameters
18821884
Assert-ThrowsContains { Set-AzPolicyAssignment } $missingParameters
@@ -1885,6 +1887,8 @@ function Test-SetPolicyAssignmentParameters
18851887
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName } $policyAssignmentNotFound
18861888
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -Scope $goodScope } $policyAssignmentNotFound
18871889
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -NotScope $someNotScope } $policyAssignmentNotFound
1890+
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -NotScope $emptyNotScope } $policyAssignmentNotFound
1891+
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -NotScope $null } $parameterNullError
18881892
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -Id $someId } $parameterSetError
18891893
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -DisplayName $someDisplayName } $policyAssignmentNotFound
18901894
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -Description $description } $policyAssignmentNotFound

0 commit comments

Comments
 (0)