@@ -8,10 +8,6 @@ namespace System.IO.Pipes.Tests
8
8
{
9
9
public class AnonymousPipeServerStreamAclTests : PipeServerStreamAclTestBase
10
10
{
11
- private const PipeDirection DefaultPipeDirection = PipeDirection . In ;
12
- private const HandleInheritability DefaultInheritability = HandleInheritability . None ;
13
- private const int DefaultBufferSize = 1 ;
14
-
15
11
[ Fact ]
16
12
public void Create_NullSecurity ( )
17
13
{
@@ -28,10 +24,7 @@ public void Create_NotSupportedPipeDirection()
28
24
}
29
25
30
26
[ Theory ]
31
- [ InlineData ( ( PipeDirection ) ( int . MinValue ) ) ]
32
- [ InlineData ( ( PipeDirection ) 0 ) ]
33
- [ InlineData ( ( PipeDirection ) 4 ) ]
34
- [ InlineData ( ( PipeDirection ) ( int . MaxValue ) ) ]
27
+ [ MemberData ( nameof ( Create_InvalidPipeDirection_MemberData ) ) ]
35
28
public void Create_InvalidPipeDirection ( PipeDirection direction )
36
29
{
37
30
Assert . Throws < ArgumentOutOfRangeException > ( ( ) =>
@@ -41,10 +34,7 @@ public void Create_InvalidPipeDirection(PipeDirection direction)
41
34
}
42
35
43
36
[ Theory ]
44
- [ InlineData ( ( HandleInheritability ) ( int . MinValue ) ) ]
45
- [ InlineData ( ( HandleInheritability ) ( - 1 ) ) ]
46
- [ InlineData ( ( HandleInheritability ) 2 ) ]
47
- [ InlineData ( ( HandleInheritability ) ( int . MaxValue ) ) ]
37
+ [ MemberData ( nameof ( Create_InvalidInheritability_MemberData ) ) ]
48
38
public void Create_InvalidInheritability ( HandleInheritability inheritability )
49
39
{
50
40
Assert . Throws < ArgumentOutOfRangeException > ( ( ) =>
@@ -54,8 +44,7 @@ public void Create_InvalidInheritability(HandleInheritability inheritability)
54
44
}
55
45
56
46
[ Theory ]
57
- [ InlineData ( int . MinValue ) ]
58
- [ InlineData ( - 1 ) ]
47
+ [ MemberData ( nameof ( Create_InvalidBufferSize_MemberData ) ) ]
59
48
public void Create_InvalidBufferSize ( int bufferSize )
60
49
{
61
50
Assert . Throws < ArgumentOutOfRangeException > ( ( ) =>
@@ -66,7 +55,7 @@ public void Create_InvalidBufferSize(int bufferSize)
66
55
67
56
public static IEnumerable < object [ ] > Create_ValidParameters_MemberData ( ) =>
68
57
from direction in new [ ] { PipeDirection . In , PipeDirection . Out }
69
- from inheritability in Enum . GetValues ( typeof ( HandleInheritability ) ) . Cast < HandleInheritability > ( )
58
+ from inheritability in new [ ] { HandleInheritability . None , HandleInheritability . Inheritable }
70
59
from bufferSize in new [ ] { 0 , 1 }
71
60
select new object [ ] { direction , inheritability , bufferSize } ;
72
61
@@ -78,7 +67,7 @@ public void Create_ValidParameters(PipeDirection direction, HandleInheritability
78
67
}
79
68
80
69
public static IEnumerable < object [ ] > Create_CombineRightsAndAccessControl_MemberData ( ) =>
81
- from rights in Enum . GetValues ( typeof ( PipeAccessRights ) ) . Cast < PipeAccessRights > ( )
70
+ from rights in s_combinedPipeAccessRights
82
71
from accessControl in new [ ] { AccessControlType . Allow , AccessControlType . Deny }
83
72
select new object [ ] { rights , accessControl } ;
84
73
@@ -87,22 +76,13 @@ from rights in Enum.GetValues(typeof(PipeAccessRights)).Cast<PipeAccessRights>()
87
76
[ MemberData ( nameof ( Create_CombineRightsAndAccessControl_MemberData ) ) ]
88
77
public void Create_CombineRightsAndAccessControl ( PipeAccessRights rights , AccessControlType accessControl )
89
78
{
90
- // These are the two cases that create a valid pipe when using Allow
91
- if ( ( rights == PipeAccessRights . FullControl || rights == PipeAccessRights . ReadWrite ) &&
92
- accessControl == AccessControlType . Allow )
79
+ // These are the only two rights that allow creating a pipe when using Allow
80
+ if ( accessControl == AccessControlType . Allow &&
81
+ ( rights == PipeAccessRights . FullControl || rights == PipeAccessRights . ReadWrite ) )
93
82
{
94
83
VerifyValidSecurity ( rights , accessControl ) ;
95
84
}
96
- // When creating the PipeAccessRule for the PipeSecurity, the PipeAccessRule constructor calls AccessMaskFromRights, which explicilty removes the Synchronize bit from rights when AccessControlType is Deny
97
- // and rights is not FullControl, so using Synchronize with Deny is not allowed
98
- else if ( rights == PipeAccessRights . Synchronize && accessControl == AccessControlType . Deny )
99
- {
100
- Assert . Throws < ArgumentException > ( "accessMask" , ( ) =>
101
- {
102
- PipeSecurity security = GetPipeSecurity ( WellKnownSidType . BuiltinUsersSid , PipeAccessRights . Synchronize , AccessControlType . Deny ) ;
103
- } ) ;
104
- }
105
- // Any other case is not authorized
85
+ // Any other combination is not authorized
106
86
else
107
87
{
108
88
PipeSecurity security = GetPipeSecurity ( WellKnownSidType . BuiltinUsersSid , rights , accessControl ) ;
@@ -113,11 +93,12 @@ public void Create_CombineRightsAndAccessControl(PipeAccessRights rights, Access
113
93
}
114
94
}
115
95
116
- [ Theory ]
117
- [ InlineData ( PipeAccessRights . ReadWrite | PipeAccessRights . Synchronize , AccessControlType . Allow ) ]
118
- public void Create_ValidBitwiseRightsSecurity ( PipeAccessRights rights , AccessControlType accessControl )
96
+ [ Fact ]
97
+ public void Create_ValidBitwiseRightsSecurity ( )
119
98
{
120
- VerifyValidSecurity ( rights , accessControl ) ;
99
+ // Synchronize gets removed from the bitwise combination,
100
+ // but ReadWrite (an allowed right) should remain untouched
101
+ VerifyValidSecurity ( PipeAccessRights . ReadWrite | PipeAccessRights . Synchronize , AccessControlType . Allow ) ;
121
102
}
122
103
123
104
private void VerifyValidSecurity ( PipeAccessRights rights , AccessControlType accessControl )
0 commit comments