Skip to content

Commit

Permalink
Merge pull request Azure#49 from huangpf/crp2
Browse files Browse the repository at this point in the history
Crp2
  • Loading branch information
AzureRT committed Apr 14, 2015
2 parents 32f15a7 + 681fb93 commit 35d3645
Show file tree
Hide file tree
Showing 27 changed files with 300 additions and 37 deletions.
12 changes: 12 additions & 0 deletions setup/azurecmdfiles.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,9 @@
<Component Id="cmp93A93C29B2093AFCB0348F2C5B999E64" Guid="*">
<File Id="fil3D666DBAA021AB26520C7A0308E583D4" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Storage\Newtonsoft.Json.dll" />
</Component>
<Component Id="cmp61DDE2E3D2FBB80AA9CED6F33128035D" Guid="*">
<File Id="fil7149B5FE830ECDCE2EACA3B4E8289AAF" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Storage\PostBuild.ps1" />
</Component>
<Component Id="cmp7985D9505A461C04CC38A8D7F341EBC2" Guid="*">
<File Id="fil12F263F6FC0E5DBC1B0BCA1887AFD846" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Storage\System.Net.Http.Extensions.dll" />
</Component>
Expand Down Expand Up @@ -2764,6 +2767,9 @@
<Component Id="cmpA10291DA4F33CEBFB790A935E68C763C" Guid="*">
<File Id="filF5A4A20E3A90049515A936CA24C18514" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Sql\Newtonsoft.Json.dll" />
</Component>
<Component Id="cmp8839023EABF68726F33F2E22907EE5CA" Guid="*">
<File Id="fil7E09EF4FC96DB53F9DCD865B90E854B6" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Sql\PostBuild.ps1" />
</Component>
<Component Id="cmp0B5A5E6BA5861771073ED88DCAB35DCC" Guid="*">
<File Id="fil7399EB9870646ED4FE533B1842E6CE84" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Sql\ServiceManagementStartup.ps1" />
</Component>
Expand Down Expand Up @@ -2859,6 +2865,9 @@
<Component Id="cmp6ECD97BC8B820C8F075B08C926EE8E18" Guid="*">
<File Id="fil327F23A245CA0317EFF25FB727CC237C" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Storage\Newtonsoft.Json.dll" />
</Component>
<Component Id="cmp2788656715EE90B002A2DF2A355A4B7C" Guid="*">
<File Id="fil255776871423D5F544B74A1AA9926B3C" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Storage\PostBuild.ps1" />
</Component>
<Component Id="cmpDE403EAE6FDC0C14D1EC077F2D9DCDF6" Guid="*">
<File Id="fil63C9BDB6186929AAA2E72F85AA3A4558" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Storage\System.Net.Http.Extensions.dll" />
</Component>
Expand Down Expand Up @@ -3366,6 +3375,7 @@
<ComponentRef Id="cmp8CC873DBE9230381C5CDCADC4920348E" />
<ComponentRef Id="cmp1E206A516CD1793516989E02475DED35" />
<ComponentRef Id="cmp93A93C29B2093AFCB0348F2C5B999E64" />
<ComponentRef Id="cmp61DDE2E3D2FBB80AA9CED6F33128035D" />
<ComponentRef Id="cmp7985D9505A461C04CC38A8D7F341EBC2" />
<ComponentRef Id="cmp02ACACBB96C5AF339C3EF0B3D748D59D" />
<ComponentRef Id="cmpADC075B4FA9AC22F9AA7C27E98D28FBE" />
Expand Down Expand Up @@ -3894,6 +3904,7 @@
<ComponentRef Id="cmpB559FF7BECE247BF0FB2DEE533E5A820" />
<ComponentRef Id="cmp2DA9A48FC4B479D897435D7DCFA6DDE3" />
<ComponentRef Id="cmpA10291DA4F33CEBFB790A935E68C763C" />
<ComponentRef Id="cmp8839023EABF68726F33F2E22907EE5CA" />
<ComponentRef Id="cmp0B5A5E6BA5861771073ED88DCAB35DCC" />
<ComponentRef Id="cmp8FDC59E62622D98C6BE19E68ABC2666F" />
<ComponentRef Id="cmpE8892E4AE524E10FC9808A04A8A7D4BE" />
Expand Down Expand Up @@ -3925,6 +3936,7 @@
<ComponentRef Id="cmp294C3C7148D92CE8D41B74464DF7DEBD" />
<ComponentRef Id="cmpD77395F69A94BA2E235B63510FA5ACE2" />
<ComponentRef Id="cmp6ECD97BC8B820C8F075B08C926EE8E18" />
<ComponentRef Id="cmp2788656715EE90B002A2DF2A355A4B7C" />
<ComponentRef Id="cmpDE403EAE6FDC0C14D1EC077F2D9DCDF6" />
<ComponentRef Id="cmp558B809B6B758A29CA1CD1B340943369" />
<ComponentRef Id="cmp2D8EAF351C80F628AB412FA578D5DA1F" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Authorization">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.1-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Batch">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Batch.1.3.0-preview\lib\net40\Microsoft.Azure.Management.Batch.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Azure.Common.Authentication" version="1.0.22-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Batch" version="1.3.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.Authorization">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.1-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.DataFactories">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.DataFactories.0.15.6-preview\lib\net40\Microsoft.Azure.Management.DataFactories.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<package id="Microsoft.Azure.Common.Authentication" version="1.0.22-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.DataFactories" version="0.15.6-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Authorization">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.1-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
Expand Down Expand Up @@ -246,6 +247,7 @@
<Content Include="ScenarioTests\AuthorizationTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Resources\NewRoleDefinition.json" />
<None Include="Resources\RoleDefinition.json" />
<None Include="ScenarioTests\ActiveDirectoryTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Name": "CustomRole Test Role",
"Description": "Test role",
"Actions": [
"Microsoft.Authorization/*/read",
"Microsoft.Support/*"
],
"NotActions": [],
"AssignableScopes": ["Scope1" , "Scope2"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests
{
public class RoleDefinitionTests
{
// TODO: Add [Trait(Category.AcceptanceType, Category.CheckIn)] attribute for each test once it gets implemented fully

[Fact(Skip = "Not implemented")]
public void RoleDefinitionCreateTests()
{
ResourcesController.NewInstance.RunPsTest("Test-RoleDefinitionCreateTests");
}

[Fact(Skip="Not implemented")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RdNegativeScenarios()
{
ResourcesController.NewInstance.RunPsTest("Test-RdNegativeScenarios");
}

[Fact(Skip = "Not implemented")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RdPositiveScenarios()
{
ResourcesController.NewInstance.RunPsTest("Test-RDPositiveScenarios");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,43 @@
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Tests verify scenarios for RoleDefinitions creation.
#>
function Test-RoleDefinitionCreateTests
{
# Basic positive case - read from file
$rdName = 'CustomRole Test Role'
New-AzureRoleDefinition -InputFile .\Resources\NewRoleDefinition.json
$rd = Get-AzureRoleDefinition -Name $rdName
Assert-NotNull $rd
Assert-AreEqual "Test role" $rd.Description
Assert-AreEqual $true $rd.IsCustom
Assert-NotNull $rd.Actions
Assert-AreEqual "Microsoft.Authorization/*/read" $rd.Actions[0]
Assert-AreEqual "Microsoft.Support/*" $rd.Actions[1]
Assert-NotNull $rd.AssignableScopes
# The below scopes may need to be changed to actual scope values like /subscriptions/.... to satisfy the ARM access checks for PUT requests
Assert-AreEqual "Scope1" $rd.AssignableScopes[0]
Assert-AreEqual "Scope2" $rd.AssignableScopes[1]

# Basic positive case - read from object
$roleDef = Get-AzureRoleDefinition -Name "Virtual Machine Contributor"
$roleDef.Id = $null
$roleDef.Name = "Virtual machine restarter"
$roleDef.Actions.Add("Microsoft.ClassicCompute/virtualMachines/restart/action")
$roleDef.Description = "Can monitor and restart virtual machines"

New-AzureRoleDefinition -Role $roleDef
$addedRoleDef = Get-AzureRoleDefinition -Name "Virtual machine restarter"

Assert-AreEqual $roleDef.Actions $addedRoleDef.Actions
Assert-AreEqual $roleDef.Description $addedRoleDef.Description
Assert-AreEqual $roleDef.AssignableScopes $addedRoleDef.AssignableScopes
Assert-AreEqual $true $roleDef.IsCustom
}

<#
.SYNOPSIS
Tests verify negative scenarios for RoleDefinitions
Expand All @@ -34,7 +71,7 @@ function Test-RdNegativeScenarios
$rdNull = Get-AzureRoleDefinition -Name $rdName

# Create a role definition
# $rd = New-AzureRoleDefinition -InputFile .Resources\RoleDefinition.json
$rd = New-AzureRoleDefinition -InputFile .Resources\RoleDefinition.json

# Role Defintion not provided.
$roleDefNotProvided = "Role definition not provided."
Expand All @@ -59,7 +96,7 @@ function Test-RDPositiveScenarios
{
# Create a role definition with Name rdNamme.
$rdName = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
# $rd = New-AzureRoleDefinition -InputFile .\Resources\RoleDefinition.json
$rd = New-AzureRoleDefinition -InputFile .\Resources\RoleDefinition.json
$rd = Get-AzureRoleDefinition -Name $rdName

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

# $rdReCreated = New-AzureRoleDefinition -Role $rd
$rdReCreated = New-AzureRoleDefinition -Role $rd
$rdReDeleted = Get-AzureRoleDefinition -Name $rd.Name | Remove-AzureRoleDefinition -Force
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5571.32271-prerelease" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Authorization">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.1-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Authorization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
Expand Down Expand Up @@ -132,6 +133,11 @@
<Compile Include="ActiveDirectory\RemoveAzureADServicePrincipalCommand.cs" />
<Compile Include="ActiveDirectory\NewAzureADServicePrincipalCommand.cs" />
<Compile Include="Models.ResourceGroups\PSResourceProviderOperation.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ProviderFeatures\AzureProviderFeatureCmdletsBase.cs" />
<Compile Include="ProviderFeatures\GetAzureProviderFeatureCmdlet.cs" />
<Compile Include="Models.ActiveDirectory\ActiveDirectoryBaseCmdlet.cs" />
Expand Down Expand Up @@ -198,6 +204,7 @@
<Compile Include="RoleAssignments\GetAzureRoleAssignmentCommand.cs" />
<Compile Include="RoleAssignments\NewAzureRoleAssignmentCommand.cs" />
<Compile Include="RoleDefinitions\GetAzureRoleDefinitionCommand.cs" />
<Compile Include="RoleDefinitions\NewAzureRoleDefinitionCommand.cs" />
<Compile Include="RoleDefinitions\RemoveAzureRoleDefinitionCommand.cs" />
<Compile Include="RoleDefinitions\SetAzureRoleDefinitionCommand.cs" />
<Compile Include="Templates\TestAzureResourceGroupTemplateCommand.cs" />
Expand All @@ -215,11 +222,6 @@
<Compile Include="Models.ResourceGroups\SetResourceMode.cs" />
<Compile Include="Models.ResourceGroups\TemplateFile.cs" />
<Compile Include="Models.ResourceGroups\TemplateFileParameterV1.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Models.ResourceGroups\ResourceClient.ResourceManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResourceGroupDeployments\StopAzureResourceGroupDeploymentCommand.cs" />
Expand Down Expand Up @@ -268,8 +270,8 @@
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
Expand Down
Loading

0 comments on commit 35d3645

Please sign in to comment.