Skip to content

Commit 35d3645

Browse files
committed
Merge pull request Azure#49 from huangpf/crp2
Crp2
2 parents 32f15a7 + 681fb93 commit 35d3645

File tree

27 files changed

+300
-37
lines changed

27 files changed

+300
-37
lines changed

setup/azurecmdfiles.wxi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,9 @@
11181118
<Component Id="cmp93A93C29B2093AFCB0348F2C5B999E64" Guid="*">
11191119
<File Id="fil3D666DBAA021AB26520C7A0308E583D4" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Storage\Newtonsoft.Json.dll" />
11201120
</Component>
1121+
<Component Id="cmp61DDE2E3D2FBB80AA9CED6F33128035D" Guid="*">
1122+
<File Id="fil7149B5FE830ECDCE2EACA3B4E8289AAF" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Storage\PostBuild.ps1" />
1123+
</Component>
11211124
<Component Id="cmp7985D9505A461C04CC38A8D7F341EBC2" Guid="*">
11221125
<File Id="fil12F263F6FC0E5DBC1B0BCA1887AFD846" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Storage\System.Net.Http.Extensions.dll" />
11231126
</Component>
@@ -2764,6 +2767,9 @@
27642767
<Component Id="cmpA10291DA4F33CEBFB790A935E68C763C" Guid="*">
27652768
<File Id="filF5A4A20E3A90049515A936CA24C18514" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Sql\Newtonsoft.Json.dll" />
27662769
</Component>
2770+
<Component Id="cmp8839023EABF68726F33F2E22907EE5CA" Guid="*">
2771+
<File Id="fil7E09EF4FC96DB53F9DCD865B90E854B6" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Sql\PostBuild.ps1" />
2772+
</Component>
27672773
<Component Id="cmp0B5A5E6BA5861771073ED88DCAB35DCC" Guid="*">
27682774
<File Id="fil7399EB9870646ED4FE533B1842E6CE84" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Sql\ServiceManagementStartup.ps1" />
27692775
</Component>
@@ -2859,6 +2865,9 @@
28592865
<Component Id="cmp6ECD97BC8B820C8F075B08C926EE8E18" Guid="*">
28602866
<File Id="fil327F23A245CA0317EFF25FB727CC237C" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Storage\Newtonsoft.Json.dll" />
28612867
</Component>
2868+
<Component Id="cmp2788656715EE90B002A2DF2A355A4B7C" Guid="*">
2869+
<File Id="fil255776871423D5F544B74A1AA9926B3C" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Storage\PostBuild.ps1" />
2870+
</Component>
28622871
<Component Id="cmpDE403EAE6FDC0C14D1EC077F2D9DCDF6" Guid="*">
28632872
<File Id="fil63C9BDB6186929AAA2E72F85AA3A4558" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Storage\System.Net.Http.Extensions.dll" />
28642873
</Component>
@@ -3366,6 +3375,7 @@
33663375
<ComponentRef Id="cmp8CC873DBE9230381C5CDCADC4920348E" />
33673376
<ComponentRef Id="cmp1E206A516CD1793516989E02475DED35" />
33683377
<ComponentRef Id="cmp93A93C29B2093AFCB0348F2C5B999E64" />
3378+
<ComponentRef Id="cmp61DDE2E3D2FBB80AA9CED6F33128035D" />
33693379
<ComponentRef Id="cmp7985D9505A461C04CC38A8D7F341EBC2" />
33703380
<ComponentRef Id="cmp02ACACBB96C5AF339C3EF0B3D748D59D" />
33713381
<ComponentRef Id="cmpADC075B4FA9AC22F9AA7C27E98D28FBE" />
@@ -3894,6 +3904,7 @@
38943904
<ComponentRef Id="cmpB559FF7BECE247BF0FB2DEE533E5A820" />
38953905
<ComponentRef Id="cmp2DA9A48FC4B479D897435D7DCFA6DDE3" />
38963906
<ComponentRef Id="cmpA10291DA4F33CEBFB790A935E68C763C" />
3907+
<ComponentRef Id="cmp8839023EABF68726F33F2E22907EE5CA" />
38973908
<ComponentRef Id="cmp0B5A5E6BA5861771073ED88DCAB35DCC" />
38983909
<ComponentRef Id="cmp8FDC59E62622D98C6BE19E68ABC2666F" />
38993910
<ComponentRef Id="cmpE8892E4AE524E10FC9808A04A8A7D4BE" />
@@ -3925,6 +3936,7 @@
39253936
<ComponentRef Id="cmp294C3C7148D92CE8D41B74464DF7DEBD" />
39263937
<ComponentRef Id="cmpD77395F69A94BA2E235B63510FA5ACE2" />
39273938
<ComponentRef Id="cmp6ECD97BC8B820C8F075B08C926EE8E18" />
3939+
<ComponentRef Id="cmp2788656715EE90B002A2DF2A355A4B7C" />
39283940
<ComponentRef Id="cmpDE403EAE6FDC0C14D1EC077F2D9DCDF6" />
39293941
<ComponentRef Id="cmp558B809B6B758A29CA1CD1B340943369" />
39303942
<ComponentRef Id="cmp2D8EAF351C80F628AB412FA578D5DA1F" />

src/ResourceManager/Batch/Commands.Batch.Test/Commands.Batch.Test.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
6161
</Reference>
6262
<Reference Include="Microsoft.Azure.Management.Authorization">
63-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.1-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
63+
<SpecificVersion>False</SpecificVersion>
64+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6465
</Reference>
6566
<Reference Include="Microsoft.Azure.Management.Batch">
6667
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Batch.1.3.0-preview\lib\net40\Microsoft.Azure.Management.Batch.dll</HintPath>

src/ResourceManager/Batch/Commands.Batch.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<package id="Microsoft.Azure.Common.Authentication" version="1.0.22-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
88
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
9-
<package id="Microsoft.Azure.Management.Authorization" version="0.18.1-preview" targetFramework="net45" />
9+
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Batch" version="1.3.0-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />

src/ResourceManager/DataFactories/Commands.DataFactories.Test/Commands.DataFactories.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Management.Authorization">
6262
<SpecificVersion>False</SpecificVersion>
63-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.1-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
63+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6464
</Reference>
6565
<Reference Include="Microsoft.Azure.Management.DataFactories">
6666
<HintPath>..\..\..\packages\Microsoft.Azure.Management.DataFactories.0.15.6-preview\lib\net40\Microsoft.Azure.Management.DataFactories.dll</HintPath>

src/ResourceManager/DataFactories/Commands.DataFactories.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<package id="Microsoft.Azure.Common.Authentication" version="1.0.22-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
8-
<package id="Microsoft.Azure.Management.Authorization" version="0.18.1-preview" targetFramework="net45" />
8+
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.DataFactories" version="0.15.6-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />

src/ResourceManager/Resources/Commands.Resources.Test/Commands.Resources.Test.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Management.Authorization">
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.1-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
67+
<SpecificVersion>False</SpecificVersion>
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6869
</Reference>
6970
<Reference Include="Microsoft.Azure.ResourceManager">
7071
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -246,6 +247,7 @@
246247
<Content Include="ScenarioTests\AuthorizationTests.ps1">
247248
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
248249
</Content>
250+
<None Include="Resources\NewRoleDefinition.json" />
249251
<None Include="Resources\RoleDefinition.json" />
250252
<None Include="ScenarioTests\ActiveDirectoryTests.ps1">
251253
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Name": "CustomRole Test Role",
3+
"Description": "Test role",
4+
"Actions": [
5+
"Microsoft.Authorization/*/read",
6+
"Microsoft.Support/*"
7+
],
8+
"NotActions": [],
9+
"AssignableScopes": ["Scope1" , "Scope2"]
10+
}

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleDefinitionTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests
2020
{
2121
public class RoleDefinitionTests
2222
{
23+
// TODO: Add [Trait(Category.AcceptanceType, Category.CheckIn)] attribute for each test once it gets implemented fully
24+
25+
[Fact(Skip = "Not implemented")]
26+
public void RoleDefinitionCreateTests()
27+
{
28+
ResourcesController.NewInstance.RunPsTest("Test-RoleDefinitionCreateTests");
29+
}
30+
2331
[Fact(Skip="Not implemented")]
24-
[Trait(Category.AcceptanceType, Category.CheckIn)]
2532
public void RdNegativeScenarios()
2633
{
2734
ResourcesController.NewInstance.RunPsTest("Test-RdNegativeScenarios");
2835
}
2936

3037
[Fact(Skip = "Not implemented")]
31-
[Trait(Category.AcceptanceType, Category.CheckIn)]
3238
public void RdPositiveScenarios()
3339
{
3440
ResourcesController.NewInstance.RunPsTest("Test-RDPositiveScenarios");

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleDefinitionTests.ps1

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,43 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
<#
16+
.SYNOPSIS
17+
Tests verify scenarios for RoleDefinitions creation.
18+
#>
19+
function Test-RoleDefinitionCreateTests
20+
{
21+
# Basic positive case - read from file
22+
$rdName = 'CustomRole Test Role'
23+
New-AzureRoleDefinition -InputFile .\Resources\NewRoleDefinition.json
24+
$rd = Get-AzureRoleDefinition -Name $rdName
25+
Assert-NotNull $rd
26+
Assert-AreEqual "Test role" $rd.Description
27+
Assert-AreEqual $true $rd.IsCustom
28+
Assert-NotNull $rd.Actions
29+
Assert-AreEqual "Microsoft.Authorization/*/read" $rd.Actions[0]
30+
Assert-AreEqual "Microsoft.Support/*" $rd.Actions[1]
31+
Assert-NotNull $rd.AssignableScopes
32+
# The below scopes may need to be changed to actual scope values like /subscriptions/.... to satisfy the ARM access checks for PUT requests
33+
Assert-AreEqual "Scope1" $rd.AssignableScopes[0]
34+
Assert-AreEqual "Scope2" $rd.AssignableScopes[1]
35+
36+
# Basic positive case - read from object
37+
$roleDef = Get-AzureRoleDefinition -Name "Virtual Machine Contributor"
38+
$roleDef.Id = $null
39+
$roleDef.Name = "Virtual machine restarter"
40+
$roleDef.Actions.Add("Microsoft.ClassicCompute/virtualMachines/restart/action")
41+
$roleDef.Description = "Can monitor and restart virtual machines"
42+
43+
New-AzureRoleDefinition -Role $roleDef
44+
$addedRoleDef = Get-AzureRoleDefinition -Name "Virtual machine restarter"
45+
46+
Assert-AreEqual $roleDef.Actions $addedRoleDef.Actions
47+
Assert-AreEqual $roleDef.Description $addedRoleDef.Description
48+
Assert-AreEqual $roleDef.AssignableScopes $addedRoleDef.AssignableScopes
49+
Assert-AreEqual $true $roleDef.IsCustom
50+
}
51+
1552
<#
1653
.SYNOPSIS
1754
Tests verify negative scenarios for RoleDefinitions
@@ -34,7 +71,7 @@ function Test-RdNegativeScenarios
3471
$rdNull = Get-AzureRoleDefinition -Name $rdName
3572

3673
# Create a role definition
37-
# $rd = New-AzureRoleDefinition -InputFile .Resources\RoleDefinition.json
74+
$rd = New-AzureRoleDefinition -InputFile .Resources\RoleDefinition.json
3875

3976
# Role Defintion not provided.
4077
$roleDefNotProvided = "Role definition not provided."
@@ -59,7 +96,7 @@ function Test-RDPositiveScenarios
5996
{
6097
# Create a role definition with Name rdNamme.
6198
$rdName = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
62-
# $rd = New-AzureRoleDefinition -InputFile .\Resources\RoleDefinition.json
99+
$rd = New-AzureRoleDefinition -InputFile .\Resources\RoleDefinition.json
63100
$rd = Get-AzureRoleDefinition -Name $rdName
64101

65102
# Update the role definition with name $rdName that was created in the step above.
@@ -78,6 +115,6 @@ function Test-RDPositiveScenarios
78115
$readRd = Get-AzureRoleDefinition -Name $rd.Name
79116
Assert-Null $readRd
80117

81-
# $rdReCreated = New-AzureRoleDefinition -Role $rd
118+
$rdReCreated = New-AzureRoleDefinition -Role $rd
82119
$rdReDeleted = Get-AzureRoleDefinition -Name $rd.Name | Remove-AzureRoleDefinition -Force
83-
}
120+
}

src/ResourceManager/Resources/Commands.Resources.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
9-
<package id="Microsoft.Azure.Management.Authorization" version="0.18.1-preview" targetFramework="net45" />
9+
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5571.32271-prerelease" targetFramework="net45" />

src/ResourceManager/Resources/Commands.Resources/Commands.Resources.csproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@
6868
<SpecificVersion>False</SpecificVersion>
6969
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
7070
</Reference>
71-
<Reference Include="Microsoft.Azure.Management.Authorization">
72-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.1-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
71+
<Reference Include="Microsoft.Azure.Management.Authorization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
72+
<SpecificVersion>False</SpecificVersion>
73+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
7374
</Reference>
7475
<Reference Include="Microsoft.Azure.ResourceManager">
7576
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -132,6 +133,11 @@
132133
<Compile Include="ActiveDirectory\RemoveAzureADServicePrincipalCommand.cs" />
133134
<Compile Include="ActiveDirectory\NewAzureADServicePrincipalCommand.cs" />
134135
<Compile Include="Models.ResourceGroups\PSResourceProviderOperation.cs" />
136+
<Compile Include="Properties\Resources.Designer.cs">
137+
<AutoGen>True</AutoGen>
138+
<DesignTime>True</DesignTime>
139+
<DependentUpon>Resources.resx</DependentUpon>
140+
</Compile>
135141
<Compile Include="ProviderFeatures\AzureProviderFeatureCmdletsBase.cs" />
136142
<Compile Include="ProviderFeatures\GetAzureProviderFeatureCmdlet.cs" />
137143
<Compile Include="Models.ActiveDirectory\ActiveDirectoryBaseCmdlet.cs" />
@@ -198,6 +204,7 @@
198204
<Compile Include="RoleAssignments\GetAzureRoleAssignmentCommand.cs" />
199205
<Compile Include="RoleAssignments\NewAzureRoleAssignmentCommand.cs" />
200206
<Compile Include="RoleDefinitions\GetAzureRoleDefinitionCommand.cs" />
207+
<Compile Include="RoleDefinitions\NewAzureRoleDefinitionCommand.cs" />
201208
<Compile Include="RoleDefinitions\RemoveAzureRoleDefinitionCommand.cs" />
202209
<Compile Include="RoleDefinitions\SetAzureRoleDefinitionCommand.cs" />
203210
<Compile Include="Templates\TestAzureResourceGroupTemplateCommand.cs" />
@@ -215,11 +222,6 @@
215222
<Compile Include="Models.ResourceGroups\SetResourceMode.cs" />
216223
<Compile Include="Models.ResourceGroups\TemplateFile.cs" />
217224
<Compile Include="Models.ResourceGroups\TemplateFileParameterV1.cs" />
218-
<Compile Include="Properties\Resources.Designer.cs">
219-
<AutoGen>True</AutoGen>
220-
<DesignTime>True</DesignTime>
221-
<DependentUpon>Resources.resx</DependentUpon>
222-
</Compile>
223225
<Compile Include="Models.ResourceGroups\ResourceClient.ResourceManager.cs" />
224226
<Compile Include="Properties\AssemblyInfo.cs" />
225227
<Compile Include="ResourceGroupDeployments\StopAzureResourceGroupDeploymentCommand.cs" />
@@ -268,8 +270,8 @@
268270
<ItemGroup>
269271
<EmbeddedResource Include="Properties\Resources.resx">
270272
<Generator>ResXFileCodeGenerator</Generator>
271-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
272273
<SubType>Designer</SubType>
274+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
273275
</EmbeddedResource>
274276
</ItemGroup>
275277
<ItemGroup />

0 commit comments

Comments
 (0)