Skip to content

Null reference bug #11136

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 4 commits into from
Feb 19, 2020
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
13 changes: 10 additions & 3 deletions src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -131,14 +131,14 @@ public void RaDeletionByScope()
TestRunner.RunTestScript("Test-RaDeletionByScope");
}

[Fact(Skip = "Need AD team to re-record")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaDeletionByScopeAtRootScope()
{
TestRunner.RunTestScript("Test-RaDeletionByScopeAtRootScope");
}

[Fact(Skip = "Need AD team to re-record")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaDelegation()
{
Expand All @@ -159,6 +159,13 @@ public void RaGetByScope()
TestRunner.RunTestScript("Test-RaGetByScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaGetOnlyByRoleDefinitionName()
{
TestRunner.RunTestScript("Test-RaGetOnlyByRoleDefinitionName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RaGetByUPNWithExpandPrincipalGroups()
Expand Down
15 changes: 15 additions & 0 deletions src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,21 @@ function Test-RaGetByScope
VerifyRoleAssignmentDeleted $newAssignment1
}

<#
.SYNOPSIS
Tests verifies get of RoleAssignment using only the role definition name
#>
function Test-RaGetOnlyByRoleDefinitionName
{
# Setup
$definitionName = 'Owner'

$ras = Get-AzRoleAssignment -RoleDefinitionName $definitionName

Assert-NotNull $ras
Assert-AreEqual $definitionName $ras[0].RoleDefinitionName
}

<#
.SYNOPSIS
Creates role assignment
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Resources/Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Fix for null reference bug in GetAzureRoleAssignmentCommand

## Version 1.11.0
* Refactored template deployment cmdlets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions

if (!string.IsNullOrEmpty(options.RoleDefinitionName))
{
result = result.Where(r => r.RoleDefinitionName.Equals(options.RoleDefinitionName, StringComparison.OrdinalIgnoreCase)).ToList();
result = result.Where(r => r.RoleDefinitionName?.Equals(options.RoleDefinitionName, StringComparison.OrdinalIgnoreCase) ?? false).ToList();
}

if (options.IncludeClassicAdministrators)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Microsoft.Azure.Commands.Resources
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleAssignment", DefaultParameterSetName = ParameterSet.Empty), OutputType(typeof(PSRoleAssignment))]
public class GetAzureRoleAssignmentCommand : ResourcesBaseCmdlet
{
#region Cmdlet Parameters

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId,
HelpMessage = "The user or group object id.")]
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ResourceGroupWithObjectId,
Expand Down Expand Up @@ -214,6 +216,9 @@ public class GetAzureRoleAssignmentCommand : ResourcesBaseCmdlet
HelpMessage = "If specified, also returns the subscription classic administrators as role assignments.")]
public SwitchParameter IncludeClassicAdministrators { get; set; }

#endregion


public override void ExecuteCmdlet()
{
FilterRoleAssignmentsOptions options = new FilterRoleAssignmentsOptions()
Expand Down