Skip to content

Fix for https://github.com/Azure/azure-powershell/issues/15828 #16796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class SetAzurePolicyAssignmentCmdlet : PolicyCmdletBase
/// Gets or sets the policy assignment not scopes parameter.
/// </summary>
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = PolicyHelpStrings.SetPolicyAssignmentNotScopesHelp)]
[ValidateNotNullOrEmpty]
[ValidateNotNull]
public string[] NotScope { get; set; }

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/Resources.Test/ScenarioTests/PolicyTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,7 @@ $someDisplayName = "Some display name"

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

# validate with no parameters
Assert-ThrowsContains { Set-AzPolicyAssignment } $missingParameters
Expand All @@ -1885,6 +1887,8 @@ function Test-SetPolicyAssignmentParameters
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName } $policyAssignmentNotFound
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -Scope $goodScope } $policyAssignmentNotFound
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -NotScope $someNotScope } $policyAssignmentNotFound
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -NotScope $emptyNotScope } $policyAssignmentNotFound
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -NotScope $null } $parameterNullError
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -Id $someId } $parameterSetError
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -DisplayName $someDisplayName } $policyAssignmentNotFound
Assert-ThrowsContains { Set-AzPolicyAssignment -Name $someName -Description $description } $policyAssignmentNotFound
Expand Down
Loading