Пример #1
0
        public static MessageStatus SetSecurityInfo(
            SecurityInformation securityInformation,
            OwnerSid ownerSidEnum
            )
        {
            //If the object store does not implement security, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.
            if (!isObjectImplementedFunctionality)
            {
                Helper.CaptureRequirement(3232, @"[In Server Requests Setting of Security Information] If the object store does not implement security, 
                    the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.");
                return(MessageStatus.INVALID_DEVICE_REQUEST);
            }
            // SecurityInformation contains any of OWNER_SECURITY_INFORMATION, GROUP_SECURITY_INFORMATION, or LABEL_SECURITY_INFORMATION, and Open.GrantedAccess does not contain WRITE_OWNER.
            if ((securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION || securityInformation == SecurityInformation.GROUP_SECURITY_INFORMATION || securityInformation == SecurityInformation.LABEL_SECURITY_INFORMATION) && ((gOpenGrantedAccess & FileAccess.WRITE_OWNER) == 0))
            {
                Helper.CaptureRequirement(3258, @"[In Server Requests Setting of Security Information]  
                    The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions:SecurityInformation 
                    contains any of LABEL_SECURITY_INFORMATION, and Open.GrantedAccess does not contain WRITE_OWNER.");
                Helper.CaptureRequirement(3256, @"[In Server Requests Setting of Security Information]  
                    The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions: 
                    SecurityInformation contains any of OWNER_SECURITY_INFORMATION,  and Open.GrantedAccess does not contain WRITE_OWNER.");
                Helper.CaptureRequirement(3257, @"[In Server Requests Setting of Security Information]  
                     The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions:
                     SecurityInformation contains any of GROUP_SECURITY_INFORMATION,, and Open.GrantedAccess does not contain WRITE_OWNER.");
                Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion, 
                        the object store MUST return:[Status].");
                return(MessageStatus.ACCESS_DENIED);
            }
            // SecurityInformation contains DACL_SECURITY_INFORMATION and Open.GrantedAccess does not contain WRITE_DAC
            if ((securityInformation == SecurityInformation.DACL_SECURITY_INFORMATION) && ((gOpenGrantedAccess & FileAccess.WRITE_DAC) == 0))
            {
                Helper.CaptureRequirement(3243, @"[In Server Requests Setting of Security Information]  
                    The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions:
                    SecurityInformation contains DACL_SECURITY_INFORMATION and Open.GrantedAccess does not contain WRITE_DAC.");
                Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion, 
                        the object store MUST return:[Status].");
                return(MessageStatus.ACCESS_DENIED);
            }
            // ? SecurityInformation contains SACL_SECURITY_INFORMATION and Open.GrantedAccess does not contain ACCESS_SYSTEM_SECURITY.
            if ((securityInformation == SecurityInformation.SACL_SECURITY_INFORMATION) && ((gOpenGrantedAccess & FileAccess.ACCESS_SYSTEM_SECURITY) == 0))
            {
                Helper.CaptureRequirement(3244, @"[In Server Requests Setting of Security Information]  
                    The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions: SecurityInformation contains SACL_SECURITY_INFORMATION and Open.GrantedAccess does not contain ACCESS_SYSTEM_SECURITY.");
                Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion, 
                        the object store MUST return:[Status].");
                return(MessageStatus.ACCESS_DENIED);
            }

            // If SecurityInformation contains OWNER_SECURITY_INFORMATION
            if (securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION)
            {
                // If InputBuffer.OwnerSid is not present,
                if (ownerSidEnum == OwnerSid.InputBufferOwnerSidNotPresent)
                {
                    Helper.CaptureRequirement(3251, @"[In Server Requests Setting of Security Information, 
                        Pseudocode for the operation is as follows:If SecurityInformation contains OWNER_SECURITY_INFORMATION:]
                        If InputBuffer.OwnerSid is not present, the operation MUST be failed with STATUS_INVALID_OWNER.");
                    Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion, 
                        the object store MUST return:[Status].");
                    return(MessageStatus.INVALID_OWNER);
                }
                if (ownerSidEnum == OwnerSid.InputBufferOwnerSidNotValid)
                {
                    Helper.CaptureRequirement(4584, @"[In Server Requests Setting of Security Information, 
                        Pseudocode for the operation is as follows:If SecurityInformation contains OWNER_SECURITY_INFORMATION:]
                        If InputBuffer.OwnerSid is not a valid owner SID for a file in the object store, as determined in an implementation-specific manner, 
                        the object store MUST return STATUS_INVALID_OWNER.");
                    Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion, 
                        the object store MUST return:[Status].");
                    return(MessageStatus.INVALID_OWNER);
                }
            }
            else
            {
                // If Open.File.SecurityDescriptor.Owner is NULL
                if (ownerSidEnum == OwnerSid.OpenFileSecDesOwnerIsNull)
                {
                    Helper.CaptureRequirement(3252, @"[In Server Requests Setting of Security Information,Pseudocode for the operation is as follows:
                        else If SecurityInformation doesn't contain OWNER_SECURITY_INFORMATION:]If Open.File.SecurityDescriptor.Owner is NULL, 
                        the operation MUST be failed with STATUS_INVALID_OWNER.");
                    Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion, 
                        the object store MUST return:[Status].");
                    return(MessageStatus.INVALID_OWNER);
                }
            }
            Helper.CaptureRequirement(3255, @"[In Server Requests Setting of Security Information,Pseudocode for the operation is as follows:]
                 The operation returns STATUS_SUCCESS.");
            Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion, 
                        the object store MUST return:[Status].");
            return(MessageStatus.SUCCESS);
        }
        public static MessageStatus SetSecurityInfo(
            SecurityInformation securityInformation,
            OwnerSid ownerSidEnum
            )
        {
            //If the object store does not implement security, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.
            if (!isObjectImplementedFunctionality)
            {
                Helper.CaptureRequirement(3232, @"[In Server Requests Setting of Security Information] If the object store does not implement security,
                    the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.");
                return MessageStatus.INVALID_DEVICE_REQUEST;
            }
            // SecurityInformation contains any of OWNER_SECURITY_INFORMATION, GROUP_SECURITY_INFORMATION, or LABEL_SECURITY_INFORMATION, and Open.GrantedAccess does not contain WRITE_OWNER.
            if ((securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION || securityInformation == SecurityInformation.GROUP_SECURITY_INFORMATION || securityInformation == SecurityInformation.LABEL_SECURITY_INFORMATION) && ((gOpenGrantedAccess & FileAccess.WRITE_OWNER) == 0))
            {
                Helper.CaptureRequirement(3258, @"[In Server Requests Setting of Security Information]
                    The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions:SecurityInformation
                    contains any of LABEL_SECURITY_INFORMATION, and Open.GrantedAccess does not contain WRITE_OWNER.");
                Helper.CaptureRequirement(3256, @"[In Server Requests Setting of Security Information]
                    The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions:
                    SecurityInformation contains any of OWNER_SECURITY_INFORMATION,  and Open.GrantedAccess does not contain WRITE_OWNER.");
                Helper.CaptureRequirement(3257, @"[In Server Requests Setting of Security Information]
                     The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions:
                     SecurityInformation contains any of GROUP_SECURITY_INFORMATION,, and Open.GrantedAccess does not contain WRITE_OWNER.");
                Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion,
                        the object store MUST return:[Status].");
                return MessageStatus.ACCESS_DENIED;
            }
            // SecurityInformation contains DACL_SECURITY_INFORMATION and Open.GrantedAccess does not contain WRITE_DAC
            if ((securityInformation == SecurityInformation.DACL_SECURITY_INFORMATION) && ((gOpenGrantedAccess & FileAccess.WRITE_DAC) == 0))
            {
                Helper.CaptureRequirement(3243, @"[In Server Requests Setting of Security Information]
                    The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions:
                    SecurityInformation contains DACL_SECURITY_INFORMATION and Open.GrantedAccess does not contain WRITE_DAC.");
                Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion,
                        the object store MUST return:[Status].");
                return MessageStatus.ACCESS_DENIED;
            }
            // ? SecurityInformation contains SACL_SECURITY_INFORMATION and Open.GrantedAccess does not contain ACCESS_SYSTEM_SECURITY.
            if ((securityInformation == SecurityInformation.SACL_SECURITY_INFORMATION) && ((gOpenGrantedAccess & FileAccess.ACCESS_SYSTEM_SECURITY) == 0))
            {
                Helper.CaptureRequirement(3244, @"[In Server Requests Setting of Security Information]
                    The operation MUST be failed with STATUS_ACCESS_DENIED under any of the following conditions: SecurityInformation contains SACL_SECURITY_INFORMATION and Open.GrantedAccess does not contain ACCESS_SYSTEM_SECURITY.");
                Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion,
                        the object store MUST return:[Status].");
                return MessageStatus.ACCESS_DENIED;
            }

            // If SecurityInformation contains OWNER_SECURITY_INFORMATION
            if (securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION)
            {
                // If InputBuffer.OwnerSid is not present,
                if (ownerSidEnum == OwnerSid.InputBufferOwnerSidNotPresent)
                {
                    Helper.CaptureRequirement(3251, @"[In Server Requests Setting of Security Information,
                        Pseudocode for the operation is as follows:If SecurityInformation contains OWNER_SECURITY_INFORMATION:]
                        If InputBuffer.OwnerSid is not present, the operation MUST be failed with STATUS_INVALID_OWNER.");
                    Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion,
                        the object store MUST return:[Status].");
                    return MessageStatus.INVALID_OWNER;
                }
                if (ownerSidEnum == OwnerSid.InputBufferOwnerSidNotValid)
                {
                    Helper.CaptureRequirement(4584, @"[In Server Requests Setting of Security Information,
                        Pseudocode for the operation is as follows:If SecurityInformation contains OWNER_SECURITY_INFORMATION:]
                        If InputBuffer.OwnerSid is not a valid owner SID for a file in the object store, as determined in an implementation-specific manner,
                        the object store MUST return STATUS_INVALID_OWNER.");
                    Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion,
                        the object store MUST return:[Status].");
                    return MessageStatus.INVALID_OWNER;
                }
            }
            else
            {
                // If Open.File.SecurityDescriptor.Owner is NULL
                if (ownerSidEnum == OwnerSid.OpenFileSecDesOwnerIsNull)
                {
                    Helper.CaptureRequirement(3252, @"[In Server Requests Setting of Security Information,Pseudocode for the operation is as follows:
                        else If SecurityInformation doesn't contain OWNER_SECURITY_INFORMATION:]If Open.File.SecurityDescriptor.Owner is NULL,
                        the operation MUST be failed with STATUS_INVALID_OWNER.");
                    Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion,
                        the object store MUST return:[Status].");
                    return MessageStatus.INVALID_OWNER;
                }
            }
            Helper.CaptureRequirement(3255, @"[In Server Requests Setting of Security Information,Pseudocode for the operation is as follows:]
                 The operation returns STATUS_SUCCESS.");
            Helper.CaptureRequirement(3239, @"[In Server Requests Setting of Security Information]On completion,
                        the object store MUST return:[Status].");
            return MessageStatus.SUCCESS;
        }
 internal static MessageStatus WorkaroundSetSecurityInfo(FileSystem fileSystem, SecurityInformation securityInformation, OwnerSid ownerSidEnum, MessageStatus returnedStatus, ITestSite site)
 {
     if (fileSystem == FileSystem.FAT32)
     {
         returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(3232, MessageStatus.INVALID_DEVICE_REQUEST, returnedStatus, site);
     }
     else if (((securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION || securityInformation == SecurityInformation.GROUP_SECURITY_INFORMATION || securityInformation == SecurityInformation.LABEL_SECURITY_INFORMATION)) || (securityInformation == SecurityInformation.DACL_SECURITY_INFORMATION) || (securityInformation == SecurityInformation.SACL_SECURITY_INFORMATION))
     {
         returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(3239, MessageStatus.ACCESS_DENIED, returnedStatus, site);
     }
     else if ((securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION && ownerSidEnum == OwnerSid.InputBufferOwnerSidNotPresent) || (securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION && ownerSidEnum == OwnerSid.InputBufferOwnerSidNotValid) || (securityInformation != SecurityInformation.OWNER_SECURITY_INFORMATION && ownerSidEnum == OwnerSid.OpenFileSecDesOwnerIsNull))
     {
         returnedStatus = FsaUtility.TransferExpectedResult <MessageStatus>(3239, MessageStatus.INVALID_OWNER, returnedStatus, site);
     }
     return(returnedStatus);
 }
 internal static MessageStatus WorkaroundSetSecurityInfo(SecurityInformation securityInformation, OwnerSid ownerSidEnum, MessageStatus returnedStatus, ITestSite site)
 {
     if (((securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION || securityInformation == SecurityInformation.GROUP_SECURITY_INFORMATION || securityInformation == SecurityInformation.LABEL_SECURITY_INFORMATION)) || (securityInformation == SecurityInformation.DACL_SECURITY_INFORMATION) || (securityInformation == SecurityInformation.SACL_SECURITY_INFORMATION))
     {
         returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(3239, MessageStatus.ACCESS_DENIED, returnedStatus, site);
     }
     else if ((securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION && ownerSidEnum == OwnerSid.InputBufferOwnerSidNotPresent) || (securityInformation == SecurityInformation.OWNER_SECURITY_INFORMATION && ownerSidEnum == OwnerSid.InputBufferOwnerSidNotValid) || (securityInformation != SecurityInformation.OWNER_SECURITY_INFORMATION && ownerSidEnum == OwnerSid.OpenFileSecDesOwnerIsNull))
     {
         returnedStatus = FsaUtility.TransferExpectedResult<MessageStatus>(3239, MessageStatus.INVALID_OWNER, returnedStatus, site);
     }
     return returnedStatus;
 }