Skip to content

Commit eb5598c

Browse files
authored
Merge pull request #12463 from Azure/revert-12425-master
Revert "Add new attributes to role assignment objects and related cmdlets"
2 parents 7e06e43 + 494a3c6 commit eb5598c

File tree

16 files changed

+9
-2384
lines changed

16 files changed

+9
-2384
lines changed

src/Resources/Resources.Test/Resources.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.5.0-preview" />
15-
<PackageReference Include="Microsoft.Azure.Management.Authorization" Version="2.12.0-preview" />
15+
<PackageReference Include="Microsoft.Azure.Management.Authorization" Version="2.11.0-preview" />
1616
<PackageReference Include="Microsoft.Azure.Management.ManagementGroups" Version="1.1.1-preview" />
1717
</ItemGroup>
1818

src/Resources/Resources.Test/ScenarioTests/Common.ps1

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ function New-AzRoleAssignmentWithId
116116
[string] [Parameter()] $RoleDefinitionName,
117117
[Guid] [Parameter()] $RoleDefinitionId,
118118
[switch] [Parameter()] $AllowDelegation,
119-
[string] [Parameter()] $Description,
120-
[string] [Parameter()] $Condition,
121-
[string] [Parameter()] $ConditionVersion,
122119
[Guid] [Parameter()] $RoleAssignmentId
123120
)
124121

@@ -187,21 +184,6 @@ function New-AzRoleAssignmentWithId
187184
$cmdlet.RoleAssignmentId = $RoleAssignmentId
188185
}
189186

190-
if (-not ([string]::IsNullOrEmpty($Description)))
191-
{
192-
$cmdlet.Description = $Description
193-
}
194-
195-
if (-not ([string]::IsNullOrEmpty($Condition)))
196-
{
197-
$cmdlet.Condition = $Condition
198-
}
199-
200-
if (-not ([string]::IsNullOrEmpty($ConditionVersion)))
201-
{
202-
$cmdlet.ConditionVersion = $ConditionVersion
203-
}
204-
205187
$cmdlet.ExecuteCmdlet()
206188
}
207189

src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -181,34 +181,6 @@ public void RaCreatedBySP()
181181
TestRunner.RunTestScript("Test-RaCreatedBySP");
182182
}
183183

184-
[Fact]
185-
[Trait(Category.AcceptanceType, Category.CheckIn)]
186-
public void RaWithV1Conditions()
187-
{
188-
TestRunner.RunTestScript("Test-RaWithV1Conditions");
189-
}
190-
191-
[Fact]
192-
[Trait(Category.AcceptanceType, Category.CheckIn)]
193-
public void RaWithV2Conditions()
194-
{
195-
TestRunner.RunTestScript("Test-RaWithV2Conditions");
196-
}
197-
198-
[Fact]
199-
[Trait(Category.AcceptanceType, Category.CheckIn)]
200-
public void RaWithV2ConditionsOnly()
201-
{
202-
TestRunner.RunTestScript("Test-RaWithV2ConditionsOnly");
203-
}
204-
205-
[Fact]
206-
[Trait(Category.AcceptanceType, Category.CheckIn)]
207-
public void RaWithV2ConditionVersionOnly()
208-
{
209-
TestRunner.RunTestScript("Test-RaWithV2ConditionVersionOnly");
210-
}
211-
212184
[Fact(Skip = "Fix the flaky test and token error and then re-record the test. Token from admin user is being used even when trying to use newly created user.")]
213185
[Trait(Category.AcceptanceType, Category.CheckIn)]
214186
public void RaUserPermissions()

src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.ps1

Lines changed: 0 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -721,137 +721,4 @@ function Test-RaCreatedBySP
721721
-RoleAssignmentId f0f113bd-7ff9-4eb6-b949-5de18d1b38ca
722722

723723
Assert-NotNull $data
724-
}
725-
726-
<#
727-
.SYNOPSIS
728-
Create role assignment with v1 conditions
729-
#>
730-
function Test-RaWithV1Conditions{
731-
732-
#Given
733-
$RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7"
734-
$PrincipalId = "01072e9b-c4a1-4246-a756-031b529bbf66"
735-
$Scope = '/subscriptions/4e5329a6-39ce-4e13-b12e-11b30f015986/resourceGroups/contoso_rg'
736-
$Description = "This test should not fail"
737-
$Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'"
738-
$ConditionVersion = "1.0"
739-
740-
#When
741-
$data = {New-AzRoleAssignmentWithId `
742-
-ObjectId $PrincipalId `
743-
-Scope $Scope `
744-
-RoleDefinitionId $RoleDefinitionId `
745-
-Description $Description `
746-
-Condition $Condition `
747-
-ConditionVersion $ConditionVersion `
748-
-RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d1}
749-
750-
#Then
751-
Assert-Throws $data "Argument -ConditionVersion must be greater or equal than 2.0"
752-
}
753-
754-
<#
755-
.SYNOPSIS
756-
Create role assignment with v2 conditions
757-
#>
758-
function Test-RaWithV2Conditions{
759-
#Given
760-
$RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7"
761-
$PrincipalId = "01072e9b-c4a1-4246-a756-031b529bbf66"
762-
$Scope = '/subscriptions/4e5329a6-39ce-4e13-b12e-11b30f015986/resourceGroups/contoso_rg'
763-
$Description = "This test should not fail"
764-
$Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:Name] StringEqualsIgnoreCase 'foo_storage_container'"
765-
$ConditionVersion = "2.0"
766-
767-
#When
768-
$data = New-AzRoleAssignmentWithId `
769-
-ObjectId $PrincipalId `
770-
-Scope $Scope `
771-
-RoleDefinitionId $RoleDefinitionId `
772-
-Description $Description `
773-
-Condition $Condition `
774-
-ConditionVersion $ConditionVersion `
775-
-RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2
776-
777-
#Then
778-
Assert-NotNull $data "The role assignment was not created succesfully"
779-
Assert-AreEqual $RoleDefinitionId $data.RoleDefinitionId "Assertion failed because expected RoleDefinitionId '$RoleDefinitionId' does not match actual '$data.RoleDefinitionId'"
780-
Assert-AreEqual $PrincipalId $data.ObjectId "Assertion failed because expected PrincipalId '$PrincipalId' does not match actual '$data.ObjectId'"
781-
Assert-AreEqual $Scope $data.Scope "Assertion failed because expected Scope '$Scope' does not match actual '$data.Scope'"
782-
Assert-AreEqual $Description $data.Description "Assertion failed because expected Description '$Description' does not match actual '$data.Description'"
783-
Assert-AreEqual $Condition $data.Condition "Assertion failed because expected Condition '$Condition' does not match actual '$data.Condition'"
784-
Assert-AreEqual $ConditionVersion $data.ConditionVersion "Assertion failed because expected ConditionVersion '$ConditionVersion' does not match actual '$data.ConditionVersion'"
785-
786-
#Cleanup
787-
$data = Remove-AzRoleAssignment -InputObject $data
788-
Assert-Null $data "Role assignment was not deleted properly"
789-
}
790-
791-
<#
792-
.SYNOPSIS
793-
Create role assignment with v2 conditions
794-
#>
795-
function Test-RaWithV2ConditionsOnly{
796-
#Given
797-
$RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7"
798-
$PrincipalId = "01072e9b-c4a1-4246-a756-031b529bbf66"
799-
$Scope = '/subscriptions/4e5329a6-39ce-4e13-b12e-11b30f015986/resourceGroups/contoso_rg'
800-
#$RoleDefinitionId = "0353ee0a-19ae-4380-ba3d-d54767c75d5b"
801-
#$PrincipalId = "e95fa608-3d49-4438-9f60-35d85d84ca16"
802-
#$Scope = '/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourceGroups/daorozco_bug_repro'
803-
$Description = "This test should not fail"
804-
$Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:Name] StringEqualsIgnoreCase 'foo_storage_container'"
805-
$ConditionVersion = "2.0"
806-
807-
#When
808-
$data = New-AzRoleAssignmentWithId `
809-
-ObjectId $PrincipalId `
810-
-Scope $Scope `
811-
-RoleDefinitionId $RoleDefinitionId `
812-
-Description $Description `
813-
-Condition $Condition `
814-
-RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2
815-
816-
#Then
817-
Assert-NotNull $data "The role assignment was not created succesfully"
818-
Assert-AreEqual $RoleDefinitionId $data.RoleDefinitionId "Assertion failed because expected RoleDefinitionId '$RoleDefinitionId' does not match actual '$data.RoleDefinitionId'"
819-
Assert-AreEqual $PrincipalId $data.ObjectId "Assertion failed because expected PrincipalId '$PrincipalId' does not match actual '$data.ObjectId'"
820-
Assert-AreEqual $Scope $data.Scope "Assertion failed because expected Scope '$Scope' does not match actual '$data.Scope'"
821-
Assert-AreEqual $Description $data.Description "Assertion failed because expected Description '$Description' does not match actual '$data.Description'"
822-
Assert-AreEqual $Condition $data.Condition "Assertion failed because expected Condition '$Condition' does not match actual '$data.Condition'"
823-
Assert-AreEqual $ConditionVersion $data.ConditionVersion "Assertion failed because expected ConditionVersion '$ConditionVersion' does not match actual '$data.ConditionVersion'"
824-
825-
#Cleanup
826-
$data = Remove-AzRoleAssignment -InputObject $data
827-
Assert-Null $data "Role assignment was not deleted properly"
828-
}
829-
830-
<#
831-
.SYNOPSIS
832-
Create role assignment with v2 conditions
833-
#>
834-
function Test-RaWithV2ConditionVersionOnly{
835-
# IMPORTANT this cmdlet gets interrupted before any network call in this scenario, no session record is needed
836-
#Given
837-
#$RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7"
838-
#$PrincipalId = "01072e9b-c4a1-4246-a756-031b529bbf66"
839-
#$Scope = '/subscriptions/4e5329a6-39ce-4e13-b12e-11b30f015986/resourceGroups/contoso_rg'
840-
$RoleDefinitionId = "0353ee0a-19ae-4380-ba3d-d54767c75d5b"
841-
$PrincipalId = "e95fa608-3d49-4438-9f60-35d85d84ca16"
842-
$Scope = '/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourceGroups/daorozco_bug_repro'
843-
$Description = "This test should not fail"
844-
$ConditionVersion = "2.0"
845-
846-
#When
847-
$data = {New-AzRoleAssignmentWithId `
848-
-ObjectId $PrincipalId `
849-
-Scope $Scope `
850-
-RoleDefinitionId $RoleDefinitionId `
851-
-Description $Description `
852-
-ConditionVersion $ConditionVersion `
853-
-RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2}
854-
855-
#Then
856-
Assert-Throws $data "If -ConditionVersion is set -Condition can not be empty."
857724
}

0 commit comments

Comments
 (0)