Esempio n. 1
0
 public void Create_CombineRightsAndAccessControl(PipeAccessRights rights, AccessControlType accessControl)
 {
     // These are the two cases that create a valid pipe when using Allow
     if ((rights == PipeAccessRights.FullControl || rights == PipeAccessRights.ReadWrite) &&
         accessControl == AccessControlType.Allow)
     {
         VerifyValidSecurity(rights, accessControl);
     }
     // When creating the PipeAccessRule for the PipeSecurity, the PipeAccessRule constructor calls AccessMaskFromRights, which explicilty removes the Synchronize bit from rights when AccessControlType is Deny
     // and rights is not FullControl, so using Synchronize with Deny is not allowed
     else if (rights == PipeAccessRights.Synchronize && accessControl == AccessControlType.Deny)
     {
         Assert.Throws <ArgumentException>("accessMask", () =>
         {
             PipeSecurity security = GetPipeSecurity(WellKnownSidType.BuiltinUsersSid, PipeAccessRights.Synchronize, AccessControlType.Deny);
         });
     }
     // Any other case is not authorized
     else
     {
         PipeSecurity security = GetPipeSecurity(WellKnownSidType.BuiltinUsersSid, rights, accessControl);
         Assert.Throws <UnauthorizedAccessException>(() =>
         {
             AnonymousPipeServerStreamAcl.Create(DefaultPipeDirection, DefaultInheritability, DefaultBufferSize, security).Dispose();
         });
     }
 }
Esempio n. 2
0
 public void Create_CombineRightsAndAccessControl(PipeAccessRights rights, AccessControlType accessControl)
 {
     // These are the only two rights that allow creating a pipe when using Allow
     if (accessControl == AccessControlType.Allow &&
         (rights == PipeAccessRights.FullControl || rights == PipeAccessRights.ReadWrite))
     {
         VerifyValidSecurity(rights, accessControl);
     }
     // Any other combination is not authorized
     else
     {
         PipeSecurity security = GetPipeSecurity(WellKnownSidType.BuiltinUsersSid, rights, accessControl);
         Assert.Throws <UnauthorizedAccessException>(() =>
         {
             AnonymousPipeServerStreamAcl.Create(DefaultPipeDirection, DefaultInheritability, DefaultBufferSize, security).Dispose();
         });
     }
 }
Esempio n. 3
0
        private AnonymousPipeServerStream CreateAndVerifyAnonymousPipe(
            PipeSecurity expectedSecurity,
            PipeDirection direction             = DefaultPipeDirection,
            HandleInheritability inheritability = DefaultInheritability,
            int bufferSize = DefaultBufferSize)
        {
            AnonymousPipeServerStream pipe = AnonymousPipeServerStreamAcl.Create(direction, inheritability, bufferSize, expectedSecurity);

            Assert.NotNull(pipe);

            if (expectedSecurity != null)
            {
                PipeSecurity actualSecurity = pipe.GetAccessControl();
                VerifyPipeSecurity(expectedSecurity, actualSecurity);
            }

            return(pipe);
        }