Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -2,10 +2,10 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyKey>MSFT</AssemblyKey>
<IsNETCoreApp>true</IsNETCoreApp>
<IsNETCoreAppRef>false</IsNETCoreAppRef>
<IsDesktopFacade>true</IsDesktopFacade>
<IsUAP>true</IsUAP>
<ISUAPRef>false</ISUAPRef>
</PropertyGroup>

View File

@@ -3,12 +3,18 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<ProjectReference Include="..\ref\System.Security.AccessControl.csproj">
<SupportedFramework>net463;netcoreapp2.0</SupportedFramework>
<SupportedFramework>net461;netcoreapp2.0;uap10.1;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.Security.AccessControl.csproj" />
<NotSupportedOnTargetFramework Include="netcore50">
<PackageTargetRuntime>win</PackageTargetRuntime>
</NotSupportedOnTargetFramework>
<HarvestIncludePaths Include="ref/net46;lib/net46;runtimes/win/lib/net46" />
<HarvestIncludePaths Include="ref/netstandard1.3">
<SupportedFramework>netcore50</SupportedFramework>
</HarvestIncludePaths>
<HarvestIncludePaths Include="runtimes/win/lib/netstandard1.3" />
<HarvestIncludePaths Include="runtimes/unix/lib/netstandard1.3">
<!-- package unix impl (platform not supported) as RID agnostic -->
<TargetPath>lib/netstandard1.3</TargetPath>
</HarvestIncludePaths>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -3,6 +3,7 @@
<PropertyGroup>
<BuildConfigurations>
netstandard;
netfx;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -1,20 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
namespace System.Security.AccessControl
{
// Derive AuthorizationRuleCollection from ICollection since we removed the old ReadOnlyCollectionBase
// base type and replaced it with this.
public sealed partial class AuthorizationRuleCollection : System.Collections.ICollection, System.Collections.IEnumerable
{
public int Count { get { throw null; } }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
}
}

View File

@@ -131,7 +131,7 @@ namespace System.Security.AccessControl
public bool IsInherited { get { throw null; } }
public System.Security.AccessControl.PropagationFlags PropagationFlags { get { throw null; } }
}
public sealed partial class AuthorizationRuleCollection
public sealed partial class AuthorizationRuleCollection : System.Collections.ReadOnlyCollectionBase
{
public AuthorizationRuleCollection() { }
public System.Security.AccessControl.AuthorizationRule this[int index] { get { throw null; } }

View File

@@ -3,14 +3,22 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{F80C478C-48EE-46A5-89C4-EE0CFB23A14F}</ProjectGuid>
<!-- UAP10.1 is not yet mapped to netstandard2.0, manually duplicate this ref -->
<PackageTargetFramework Condition="'$(TargetGroup)' == 'netstandard'">netstandard2.0;uap10.1</PackageTargetFramework>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Security.AccessControl.cs" />
<Compile Include="System.Security.AccessControl.Manual.cs" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Reference Include="mscorlib" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<SuppressPackageTargetFrameworkCompatibility Include="uap10.1" />
<ProjectReference Include="..\..\System.Security.Principal.Windows\ref\System.Security.Principal.Windows.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />

View File

@@ -5,6 +5,7 @@
netfx-Windows_NT;
netcoreapp-Windows_NT;
netcoreapp-Unix;
netstandard;
uap-Windows_NT;
</BuildConfigurations>
</PropertyGroup>

View File

@@ -196,4 +196,7 @@
<data name="Rank_MultiDimNotSupported" xml:space="preserve">
<value>Only single dimension arrays are supported here.</value>
</data>
<data name="PlatformNotSupported_AccessControl" xml:space="preserve">
<value>Access Control List (ACL) APIs are part of resource management on Windows and are not supported on this platform.</value>
</data>
</root>

View File

@@ -5,16 +5,17 @@
<AssemblyName>System.Security.AccessControl</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)'=='netfx'">true</IsPartialFacadeAssembly>
<GeneratePlatformNotSupportedAssembly Condition="'$(TargetsUnix)' == 'true'">true</GeneratePlatformNotSupportedAssembly>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsWindows)' != 'true'">SR.PlatformNotSupported_AccessControl</GeneratePlatformNotSupportedAssemblyMessage>
<ProjectGuid>{D27FFA1F-B446-4D24-B60A-1F88385CDB6D}</ProjectGuid>
</PropertyGroup>
<!-- Help VS understand available configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetGroup)'=='netfx'">
@@ -118,15 +119,18 @@
<Link>Common\Interop\Interop.DuplicateTokenEx_SafeTokenHandle.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<Reference Include="System.Collections.NonGeneric" />
<Reference Include="System.Runtime" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Security.Principal.Windows" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true' AND '$(TargetGroup)' != 'netfx'">
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Contracts" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Security.Principal.Windows" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Thread" />
</ItemGroup>

View File

@@ -30,20 +30,9 @@ namespace System.Security.AccessControl
_privilegeName = privilege;
}
private PrivilegeNotHeldException(SerializationInfo info, StreamingContext context) : base(info, context)
{
_privilegeName = info.GetString(nameof(PrivilegeName));
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException(nameof(info));
}
base.GetObjectData(info, context);
info.AddValue(nameof(PrivilegeName), _privilegeName, typeof(string));
}
public string PrivilegeName

View File

@@ -347,56 +347,8 @@ nameof(auditFlags),
}
public sealed class AuthorizationRuleCollection : ICollection, IEnumerable // TODO: Is this right? Was previously ReadOnlyCollectionBase
public sealed class AuthorizationRuleCollection : ReadOnlyCollectionBase
{
#region ReadOnlyCollectionBase APIs
// Goo to translate this from ReadOnlyCollectionBase to ICollection
Object _syncRoot;
List<AuthorizationRule> list;
List<AuthorizationRule> InnerList
{
get
{
if (list == null)
list = new List<AuthorizationRule>();
return list;
}
}
public int Count
{
get { return InnerList.Count; }
}
bool ICollection.IsSynchronized
{
get { return false; }
}
object ICollection.SyncRoot
{
get
{
if (_syncRoot == null)
{
System.Threading.Interlocked.CompareExchange<Object>(ref _syncRoot, new Object(), null);
}
return _syncRoot;
}
}
void ICollection.CopyTo(Array array, int index)
{
InnerList.CopyTo((AuthorizationRule[])array, index);
}
IEnumerator IEnumerable.GetEnumerator()
{
return InnerList.GetEnumerator();
}
#endregion
#region Constructors
public AuthorizationRuleCollection()

View File

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -25,16 +25,16 @@ namespace System.Security.AccessControl.Tests
[Fact]
public virtual void AccessRule_Constructor_Invalid()
{
Assert.Throws<ArgumentNullException>("identity", () => Constructor(null, 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
AssertExtensions.Throws<ArgumentNullException>("identity", () => Constructor(null, 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 0, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), -1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 2147483647, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1073741823, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 0, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), -1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 2147483647, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1073741823, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("inheritanceFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)4, (PropagationFlags)1, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("propagationFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)4, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("accessControlType", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)3));
AssertExtensions.Throws<ArgumentOutOfRangeException>("inheritanceFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)4, (PropagationFlags)1, (AccessControlType)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("propagationFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)4, (AccessControlType)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessControlType", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)3));
}
[Theory]
@@ -61,11 +61,11 @@ namespace System.Security.AccessControl.Tests
[Fact]
public override void AccessRule_Constructor_Invalid()
{
Assert.Throws<ArgumentNullException>("identity", () => Constructor(null, 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
AssertExtensions.Throws<ArgumentNullException>("identity", () => Constructor(null, 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("inheritanceFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)4, (PropagationFlags)1, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("propagationFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)4, (AccessControlType)0));
Assert.Throws<ArgumentOutOfRangeException>("type", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)2));
AssertExtensions.Throws<ArgumentOutOfRangeException>("inheritanceFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)4, (PropagationFlags)1, (AccessControlType)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("propagationFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)4, (AccessControlType)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("type", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AccessControlType)2));
}
}
}

View File

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -87,11 +87,11 @@ namespace System.Security.AccessControl.Tests
[Fact]
public void CommonAce_Constructor_Invalid()
{
Assert.Throws<ArgumentNullException>("securityIdentifier", () => new CommonAce((AceFlags)0, (AceQualifier)0, 1, null, true, new byte[4]));
Assert.Throws<ArgumentOutOfRangeException>("qualifier", () => CommonAce_CreateTestData(8, 4, 1, "S-1-5-11", true, 4, 0));
Assert.Throws<ArgumentOutOfRangeException>("qualifier", () => CommonAce_CreateTestData(8, -1, 1, "S-1-5-11", true, 4, 0));
Assert.Throws<ArgumentOutOfRangeException>("opaque", () => CommonAce_CreateTestData(2, 1, 2, "S-1-5-11", true, 1, 0));
Assert.Throws<ArgumentOutOfRangeException>("opaque", () => CommonAce_CreateTestData(2, 1, 2, "S-1-5-11", true, 17, 0));
AssertExtensions.Throws<ArgumentNullException>("securityIdentifier", () => new CommonAce((AceFlags)0, (AceQualifier)0, 1, null, true, new byte[4]));
AssertExtensions.Throws<ArgumentOutOfRangeException>("qualifier", () => CommonAce_CreateTestData(8, 4, 1, "S-1-5-11", true, 4, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("qualifier", () => CommonAce_CreateTestData(8, -1, 1, "S-1-5-11", true, 4, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("opaque", () => CommonAce_CreateTestData(2, 1, 2, "S-1-5-11", true, 1, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("opaque", () => CommonAce_CreateTestData(2, 1, 2, "S-1-5-11", true, 17, 0));
}
@@ -99,20 +99,20 @@ namespace System.Security.AccessControl.Tests
public void CommonAce_CreateBinaryForm_Invalid()
{
CommonAce ace = (CommonAce)CommonAce_CreateTestData(0, 0, 1, "S-1-5-11", false, 4, 0)[0];
Assert.Throws<ArgumentNullException>("binaryForm", () => CommonAce.CreateFromBinaryForm(null, 1));
Assert.Throws<ArgumentOutOfRangeException>("offset", () => CommonAce.CreateFromBinaryForm(new byte[1], -1));
Assert.Throws<ArgumentException>("binaryForm", () => CommonAce.CreateFromBinaryForm(new byte[ace.BinaryLength + 1], 2));
Assert.Throws<ArgumentException>("binaryForm", () => CommonAce.CreateFromBinaryForm(new byte[ace.BinaryLength], 1));
AssertExtensions.Throws<ArgumentNullException>("binaryForm", () => CommonAce.CreateFromBinaryForm(null, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => CommonAce.CreateFromBinaryForm(new byte[1], -1));
AssertExtensions.Throws<ArgumentException>("binaryForm", () => CommonAce.CreateFromBinaryForm(new byte[ace.BinaryLength + 1], 2));
AssertExtensions.Throws<ArgumentException>("binaryForm", () => CommonAce.CreateFromBinaryForm(new byte[ace.BinaryLength], 1));
}
[Fact]
public void CommonAce_GetBinaryForm_Invalid()
{
CommonAce ace = (CommonAce)CommonAce_CreateTestData(0, 0, 1, "S-1-5-11", false, 4, 0)[0];
Assert.Throws<ArgumentNullException>("binaryForm", () => ace.GetBinaryForm(null, 1));
Assert.Throws<ArgumentOutOfRangeException>("offset", () => ace.GetBinaryForm(new byte[1], -1));
Assert.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength + 1], 2));
Assert.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength], 1));
AssertExtensions.Throws<ArgumentNullException>("binaryForm", () => ace.GetBinaryForm(null, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => ace.GetBinaryForm(new byte[1], -1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength + 1], 2));
AssertExtensions.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength], 1));
}
[Theory]

View File

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -71,27 +71,27 @@ namespace System.Security.AccessControl.Tests
[Fact]
public void CompoundAce_Constructor_Invalid()
{
Assert.Throws<ArgumentNullException>("securityIdentifier", () => new CompoundAce((AceFlags)0, 1, (CompoundAceType)1, null));
AssertExtensions.Throws<ArgumentNullException>("securityIdentifier", () => new CompoundAce((AceFlags)0, 1, (CompoundAceType)1, null));
}
[Fact]
public void CompoundAce_CreateBinaryForm_Invalid()
{
CompoundAce ace = (CompoundAce)CompoundAce_CreateTestData(0, 1, 1, "S-1-5-11", 0)[0];
Assert.Throws<ArgumentNullException>("binaryForm", () => CompoundAce.CreateFromBinaryForm(null, 1));
Assert.Throws<ArgumentOutOfRangeException>("offset", () => CompoundAce.CreateFromBinaryForm(new byte[1], -1));
Assert.Throws<ArgumentException>("binaryForm", () => CompoundAce.CreateFromBinaryForm(new byte[ace.BinaryLength + 1], 2));
Assert.Throws<ArgumentException>("binaryForm", () => CompoundAce.CreateFromBinaryForm(new byte[ace.BinaryLength], 1));
AssertExtensions.Throws<ArgumentNullException>("binaryForm", () => CompoundAce.CreateFromBinaryForm(null, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => CompoundAce.CreateFromBinaryForm(new byte[1], -1));
AssertExtensions.Throws<ArgumentException>("binaryForm", () => CompoundAce.CreateFromBinaryForm(new byte[ace.BinaryLength + 1], 2));
AssertExtensions.Throws<ArgumentException>("binaryForm", () => CompoundAce.CreateFromBinaryForm(new byte[ace.BinaryLength], 1));
}
[Fact]
public void CompoundAce_GetBinaryForm_Invalid()
{
CompoundAce ace = (CompoundAce)CompoundAce_CreateTestData(0, 1, 1, "S-1-5-11", 0)[0];
Assert.Throws<ArgumentNullException>("binaryForm", () => ace.GetBinaryForm(null, 1));
Assert.Throws<ArgumentOutOfRangeException>("offset", () => ace.GetBinaryForm(new byte[1], -1));
Assert.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength + 1], 2));
Assert.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength], 1));
AssertExtensions.Throws<ArgumentNullException>("binaryForm", () => ace.GetBinaryForm(null, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => ace.GetBinaryForm(new byte[1], -1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength + 1], 2));
AssertExtensions.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength], 1));
}
[Theory]

View File

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -54,20 +54,20 @@ namespace System.Security.AccessControl.Tests
public void CustomAce_CreateBinaryForm_Invalid()
{
GenericAce ace = new CustomAce((AceType)19, (AceFlags)0, new byte[4]);
Assert.Throws<ArgumentNullException>("binaryForm", () => CustomAce.CreateFromBinaryForm(null, 1));
Assert.Throws<ArgumentOutOfRangeException>("offset", () => CustomAce.CreateFromBinaryForm(new byte[1], -1));
Assert.Throws<ArgumentException>("binaryForm", () => CustomAce.CreateFromBinaryForm(new byte[ace.BinaryLength + 1], 2));
Assert.Throws<ArgumentException>("binaryForm", () => CustomAce.CreateFromBinaryForm(new byte[ace.BinaryLength], 1));
AssertExtensions.Throws<ArgumentNullException>("binaryForm", () => CustomAce.CreateFromBinaryForm(null, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => CustomAce.CreateFromBinaryForm(new byte[1], -1));
AssertExtensions.Throws<ArgumentException>("binaryForm", () => CustomAce.CreateFromBinaryForm(new byte[ace.BinaryLength + 1], 2));
AssertExtensions.Throws<ArgumentException>("binaryForm", () => CustomAce.CreateFromBinaryForm(new byte[ace.BinaryLength], 1));
}
[Fact]
public void CustomAce_GetBinaryForm_Invalid()
{
GenericAce ace = new CustomAce((AceType)19, (AceFlags)0, new byte[4]);
Assert.Throws<ArgumentNullException>("binaryForm", () => ace.GetBinaryForm(null, 1));
Assert.Throws<ArgumentOutOfRangeException>("offset", () => ace.GetBinaryForm(new byte[1], -1));
Assert.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength + 1], 2));
Assert.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength], 1));
AssertExtensions.Throws<ArgumentNullException>("binaryForm", () => ace.GetBinaryForm(null, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => ace.GetBinaryForm(new byte[1], -1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength + 1], 2));
AssertExtensions.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength], 1));
}
[Theory]

View File

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -117,31 +117,31 @@ namespace System.Security.AccessControl.Tests
[Fact]
public void ObjectAce_Constructor_Invalid()
{
Assert.Throws<ArgumentNullException>("securityIdentifier", () => new ObjectAce((AceFlags)0, (AceQualifier)0, 1, null, (ObjectAceFlags)1, new Guid("{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}"), new Guid("{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}"), true, new byte[4]));
Assert.Throws<ArgumentOutOfRangeException>("qualifier", () => ObjectAce_CreateTestData(8, 4, 1, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", true, 4, 0));
Assert.Throws<ArgumentOutOfRangeException>("qualifier", () => ObjectAce_CreateTestData(8, -1, 1, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", true, 4, 0));
Assert.Throws<ArgumentOutOfRangeException>("opaque", () => ObjectAce_CreateTestData(2, 1, 2, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", true, 1, 0));
Assert.Throws<ArgumentOutOfRangeException>("opaque", () => ObjectAce_CreateTestData(2, 1, 2, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", true, 17, 0));
AssertExtensions.Throws<ArgumentNullException>("securityIdentifier", () => new ObjectAce((AceFlags)0, (AceQualifier)0, 1, null, (ObjectAceFlags)1, new Guid("{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}"), new Guid("{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}"), true, new byte[4]));
AssertExtensions.Throws<ArgumentOutOfRangeException>("qualifier", () => ObjectAce_CreateTestData(8, 4, 1, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", true, 4, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("qualifier", () => ObjectAce_CreateTestData(8, -1, 1, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", true, 4, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("opaque", () => ObjectAce_CreateTestData(2, 1, 2, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", true, 1, 0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("opaque", () => ObjectAce_CreateTestData(2, 1, 2, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", true, 17, 0));
}
[Fact]
public void ObjectAce_CreateBinaryForm_Invalid()
{
ObjectAce ace = (ObjectAce)ObjectAce_CreateTestData(0, 0, 1, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", false, 8, 0)[0];
Assert.Throws<ArgumentNullException>("binaryForm", () => ObjectAce.CreateFromBinaryForm(null, 1));
Assert.Throws<ArgumentOutOfRangeException>("offset", () => ObjectAce.CreateFromBinaryForm(new byte[1], -1));
Assert.Throws<ArgumentException>("binaryForm", () => ObjectAce.CreateFromBinaryForm(new byte[ace.BinaryLength + 1], 2));
Assert.Throws<ArgumentException>("binaryForm", () => ObjectAce.CreateFromBinaryForm(new byte[ace.BinaryLength], 1));
AssertExtensions.Throws<ArgumentNullException>("binaryForm", () => ObjectAce.CreateFromBinaryForm(null, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => ObjectAce.CreateFromBinaryForm(new byte[1], -1));
AssertExtensions.Throws<ArgumentException>("binaryForm", () => ObjectAce.CreateFromBinaryForm(new byte[ace.BinaryLength + 1], 2));
AssertExtensions.Throws<ArgumentException>("binaryForm", () => ObjectAce.CreateFromBinaryForm(new byte[ace.BinaryLength], 1));
}
[Fact]
public void ObjectAce_GetBinaryForm_Invalid()
{
ObjectAce ace = (ObjectAce)ObjectAce_CreateTestData(0, 0, 1, "S-1-5-11", 1, "{73D03E18-5C03-422c-9EC7-C4C5B1CB1612}", "{3CFD5DF9-9146-43c8-BF99-78E7E2DE4BAF}", false, 8, 0)[0];
Assert.Throws<ArgumentNullException>("binaryForm", () => ace.GetBinaryForm(null, 1));
Assert.Throws<ArgumentOutOfRangeException>("offset", () => ace.GetBinaryForm(new byte[1], -1));
Assert.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength + 1], 2));
Assert.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength], 1));
AssertExtensions.Throws<ArgumentNullException>("binaryForm", () => ace.GetBinaryForm(null, 1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => ace.GetBinaryForm(new byte[1], -1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength + 1], 2));
AssertExtensions.Throws<ArgumentOutOfRangeException>("binaryForm", () => ace.GetBinaryForm(new byte[ace.BinaryLength], 1));
}
[Theory]

View File

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -26,16 +26,16 @@ namespace System.Security.AccessControl.Tests
[Fact]
public virtual void AuditRule_Constructor_Invalid()
{
Assert.Throws<ArgumentNullException>("identity", () => Constructor(null, 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
AssertExtensions.Throws<ArgumentNullException>("identity", () => Constructor(null, 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 0, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), -1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 2147483647, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1073741823, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 0, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), -1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 2147483647, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("accessMask", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1073741823, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("inheritanceFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)4, (PropagationFlags)1, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("propagationFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)4, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("AuditFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)3));
AssertExtensions.Throws<ArgumentOutOfRangeException>("inheritanceFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)4, (PropagationFlags)1, (AuditFlags)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("propagationFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)4, (AuditFlags)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("AuditFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)3));
}
[Theory]
@@ -62,11 +62,11 @@ namespace System.Security.AccessControl.Tests
[Fact]
public override void AuditRule_Constructor_Invalid()
{
Assert.Throws<ArgumentNullException>("identity", () => Constructor(null, 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
AssertExtensions.Throws<ArgumentNullException>("identity", () => Constructor(null, 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("inheritanceFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)4, (PropagationFlags)1, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("propagationFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)4, (AuditFlags)0));
Assert.Throws<ArgumentOutOfRangeException>("auditFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)4));
AssertExtensions.Throws<ArgumentOutOfRangeException>("inheritanceFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)4, (PropagationFlags)1, (AuditFlags)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("propagationFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)4, (AuditFlags)0));
AssertExtensions.Throws<ArgumentOutOfRangeException>("auditFlags", () => Constructor(new SecurityIdentifier("S-1-5-32-544"), 1, true, (InheritanceFlags)1, (PropagationFlags)1, (AuditFlags)4));
}
}
}

View File

@@ -72,6 +72,9 @@
<Compile Include="SystemAcl\SystemAcl_RemoveInheritedAces.cs" />
<Compile Include="SystemAcl\SystemAcl_SetAudit.cs" />
<Compile Include="Utils.cs" />
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
<Link>Common\System\AssertExtensions.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>