private void AlternateDataStream_Query_FileBasicInformation(FileType fileType) { //Prerequisites: Create streams on a newly created file //Step 1: Query FILE_BASIC_INFORMATION long byteCount; byte[] outputBuffer; FileBasicInformation fileBasicInfo = new FileBasicInformation(); uint outputBufferSize = (uint)TypeMarshal.ToBytes<FileBasicInformation>(fileBasicInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "{0}. QueryFileInformation with FileInfoClass.FILE_BASIC_INFORMATION", ++testStep); status = this.fsaAdapter.QueryFileInformation(FileInfoClass.FILE_BASIC_INFORMATION, outputBufferSize, out byteCount, out outputBuffer); this.fsaAdapter.AssertIfNotSuccess(status, "QueryFileInformation with FileInfoClass.FILE_BASIC_INFORMATION operation failed."); // Step 2: Verify FILE_BASIC_INFORMATION fileBasicInfo = TypeMarshal.ToStruct<FileBasicInformation>(outputBuffer); bool isIntegrityStreamSet = (fileBasicInfo.FileAttributes & (uint)FileAttribute.INTEGRITY_STREAM) == (uint)FileAttribute.INTEGRITY_STREAM; BaseTestSite.Log.Add(LogEntryKind.TestStep, "{0}. Verify outputBuffer.FileAttributes.FILE_ATTRIBUTE_INTEGRITY_STREAM", ++testStep); if (this.fsaAdapter.IsIntegritySupported == true) { this.fsaAdapter.AssertAreEqual(this.Manager, true, isIntegrityStreamSet, "If integrity is supported, the object store MUST set FILE_ATTRIBUTE_INTEGRITY_STREAM in OutputBuffer.FileAttributes."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, false, isIntegrityStreamSet, "Integrity is not supported, FILE_ATTRIBUTE_INTEGRITY_STREAM MUST NOT set."); } }
private void FileInfo_Query_FileBasicInfo_IsIntegritySupported(FileType fileType) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); MessageStatus status; //Step 1: Create File BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString() + " with FileAttribute.INTEGRITY_STREAM"); status = this.fsaAdapter.CreateFile( FileAttribute.NORMAL | FileAttribute.INTEGRITY_STREAM, // Set Integrity field fileType == FileType.DataFile? CreateOptions.NON_DIRECTORY_FILE : CreateOptions.DIRECTORY_FILE, fileType == FileType.DataFile ? StreamTypeNameToOPen.DATA : StreamTypeNameToOPen.INDEX_ALLOCATION, //Stream Type FileAccess.GENERIC_READ | FileAccess.GENERIC_WRITE | FileAccess.FILE_WRITE_DATA | FileAccess.FILE_WRITE_ATTRIBUTES, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.OPEN_IF, StreamFoundType.StreamIsFound, SymbolicLinkType.IsNotSymbolicLink, fileType, FileNameStatus.PathNameValid); //Step 2: Query FILE_BASIC_INFORMATION long byteCount; byte[] outputBuffer; FileBasicInformation fileBasicInfo = new FileBasicInformation(); uint outputBufferSize = (uint)TypeMarshal.ToBytes<FileBasicInformation>(fileBasicInfo).Length; BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. QueryFileInformation with FileInfoClass.FILE_BASIC_INFORMATION"); status = this.fsaAdapter.QueryFileInformation(FileInfoClass.FILE_BASIC_INFORMATION, outputBufferSize, out byteCount, out outputBuffer); //Step 3: Verify test result fileBasicInfo = TypeMarshal.ToStruct<FileBasicInformation>(outputBuffer); bool isIntegrityStreamSet = (fileBasicInfo.FileAttributes & (uint)FileAttribute.INTEGRITY_STREAM) == (uint)FileAttribute.INTEGRITY_STREAM; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. Verify outputBuffer.FileAttributes.FILE_ATTRIBUTE_INTEGRITY_STREAM"); if (this.fsaAdapter.IsIntegritySupported == true) { this.fsaAdapter.AssertAreEqual(this.Manager, true, isIntegrityStreamSet, "If integrity is supported, the object store MUST set FILE_ATTRIBUTE_INTEGRITY_STREAM in OutputBuffer.FileAttributes."); } else { this.fsaAdapter.AssertAreEqual(this.Manager, false, isIntegrityStreamSet, "Integrity is not supported, FILE_ATTRIBUTE_INTEGRITY_STREAM MUST NOT set."); } }
/// <summary> /// Verify the data type FileBasicInformation, which is defined in TD 2.4.7 /// </summary> /// <param name="fileBasicInformation">FileBasicInformation type data</param> public void VerifyDataTypeFileBasicInformation( FileBasicInformation fileBasicInformation) { Site.DefaultProtocolDocShortName = "MS-FSCC"; // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1024, actual CreationTime: {0}", fileBasicInformation.CreationTime.ToString()); // // Verify MS-FSCC requirement 1024 // // Verify if the actual creationTime equals to the expcted creationTime Site.CaptureRequirementIfAreEqual<int>( 8, Marshal.SizeOf(fileBasicInformation.CreationTime), 1024, @"[In FILE_BASIC_INFORMATION]CreationTime (8 bytes): A 64-bit signed integer that contains the time when the file was created."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1025, actual CreationTime: {0}", fileBasicInformation.CreationTime.ToString()); // // Verify MS-FSCC requirement 1025 // bool isVerifiedR1025 = fileBasicInformation.CreationTime.GetType() == typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME); // Marshal.SizeOf(fileBasicInformation.CreationTime) == sizeofCreationTime); // And the size of the CreationTime is verified above, we didn't verify here again Site.CaptureRequirementIfIsTrue( isVerifiedR1025, 1025, @"[In FILE_BASIC_INFORMATION]CreationTime (8 bytes): All dates and times in this message are in absolute system-time format, which is represented as a FILETIME (section 2.1.1) structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1026, actual CreationTime: {0}", fileBasicInformation.CreationTime.ToString()); // // Verify MS-FSCC requirement 1026 // // As the size of the CreationTime is verified above, this rs will not be verified again bool isVerifyR1026 = (fileBasicInformation.CreationTime.dwHighDateTime > 0 || fileBasicInformation.CreationTime.dwLowDateTime > 0); Site.CaptureRequirementIfIsTrue( isVerifyR1026, 1026, @"[In FILE_BASIC_INFORMATION]CreationTime (8 bytes): A valid time for this field is an integer greater than 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1029, actual CreationTime: {0}", fileBasicInformation.CreationTime.ToString()); // // Verify MS-FSCC requirement 1029 // // As the type of the CreationTime has been verified above, this rs will not be verified again // As the type of the CreationTime is uint, it can not be less 0, so only verifiy if greater than or equal to 0 bool isVerifyR1029 = (fileBasicInformation.CreationTime.dwHighDateTime >= 0 && fileBasicInformation.CreationTime.dwLowDateTime >= 0); Site.CaptureRequirementIfIsTrue( isVerifyR1029, 1029, @"[In FILE_BASIC_INFORMATION]CreationTime (8 bytes): This field MUST NOT be set to a value less than -1."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1030, actual LastAccessTime: {0}", fileBasicInformation.LastAccessTime.ToString()); // // Verify MS-FSCC requirement 1030 // // Verify if the actual lastaccesstime equals to the expected lastaccesstime. int sizeofLastAccessTime = 8; bool isVerifyR1030 = ((fileBasicInformation.LastAccessTime.GetType() == typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME) && Marshal.SizeOf(fileBasicInformation.LastAccessTime) == sizeofLastAccessTime)); Site.CaptureRequirementIfIsTrue( isVerifyR1030, 1030, @"[In FILE_BASIC_INFORMATION]LastAccessTime (8 bytes): A 64-bit signed integer that contains the last time the file was accessed in the format of a FILETIME structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1031, actual LastAccessTime: {0}", fileBasicInformation.LastAccessTime.ToString()); // // Verify MS-FSCC requirement 1031 // bool isVerifyR1031 = (fileBasicInformation.LastAccessTime.dwHighDateTime > 0 || fileBasicInformation.LastAccessTime.dwLowDateTime > 0) && (Marshal.SizeOf(fileBasicInformation.LastAccessTime) == sizeofLastAccessTime); Site.CaptureRequirementIfIsTrue( isVerifyR1031, 1031, @"[In FILE_BASIC_INFORMATION]LastAccessTime (8 bytes): A valid time for this field is an integer greater than 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1034, actual LastAccessTime: {0}", fileBasicInformation.LastAccessTime.ToString()); // // Verify MS-FSCC requirement 1034 // // As the type of the LastAccessTime is uint, it can not be less 0, so only verifiy if >= 0 bool isVerifyR1034 = (fileBasicInformation.LastAccessTime.dwHighDateTime >= 0 && fileBasicInformation.LastAccessTime.dwLowDateTime >= 0) && Marshal.SizeOf(fileBasicInformation.LastAccessTime) == sizeofLastAccessTime; Site.CaptureRequirementIfIsTrue( isVerifyR1034, 1034, @"[In FILE_BASIC_INFORMATION]LastAccessTime (8 bytes): This field MUST NOT be set to a value less than -1. <54>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1035, actual LastWriteTime: {0}", fileBasicInformation.LastWriteTime.ToString()); int sizeofLastWriteTime = 8; // // Verify MS-FSCC requirement 1035 // bool isVerifyR1035 = (fileBasicInformation.LastWriteTime.GetType() == typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME) && Marshal.SizeOf(fileBasicInformation.LastWriteTime) == sizeofLastWriteTime); Site.CaptureRequirementIfIsTrue( isVerifyR1035, 1035, @"[In FILE_BASIC_INFORMATION]LastWriteTime (8 bytes): A 64-bit signed integer that contains the last time information was written to the file in the format of a FILETIME structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1036, actual LastWriteTime: {0}", fileBasicInformation.LastWriteTime.ToString()); // // Verify MS-FSCC requirement 1036 // // And the size of the LastWriteTime is verified above, we didn't verify here again bool isVerifyR1036 = (fileBasicInformation.LastWriteTime.dwHighDateTime > 0 || fileBasicInformation.LastWriteTime.dwLowDateTime > 0) && Marshal.SizeOf(fileBasicInformation.LastWriteTime) == sizeofLastWriteTime; Site.CaptureRequirementIfIsTrue( isVerifyR1036, 1036, @"[In FILE_BASIC_INFORMATION]LastWriteTime (8 bytes): A valid time for this field is an integer greater than 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1039, actual LastWriteTime: {0}", fileBasicInformation.LastWriteTime.ToString()); // // Verify MS-FSCC requirement 1039 // // As the type of the LastWriteTime is uint, it can not be less 0, so only verifiy if >= 0 bool isVerifyR1039 = (fileBasicInformation.LastWriteTime.dwHighDateTime >= 0 && fileBasicInformation.LastWriteTime.dwLowDateTime >= 0); Site.CaptureRequirementIfIsTrue( isVerifyR1039, 1039, @"[In FILE_BASIC_INFORMATION]LastWriteTime (8 bytes): This field MUST NOT be set to a value less than -1. <55>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1040, actual ChangeTime: {0}", fileBasicInformation.ChangeTime.ToString()); // // Verify MS-FSCC requirement 1040 // bool isVerifyR1040 = (fileBasicInformation.ChangeTime.GetType() == typeof(Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc.FILETIME) && Marshal.SizeOf(fileBasicInformation.ChangeTime) == 8 ); Site.CaptureRequirementIfIsTrue( isVerifyR1040, 1040, @"[In FILE_BASIC_INFORMATION]ChangeTime (8 bytes): A 64-bit signed integer that contains the last time the file was changed in the format of a FILETIME structure."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1041, actual ChangeTime: {0}", fileBasicInformation.ChangeTime.ToString()); // // Verify MS-FSCC requirement 1041 // bool isVerifyR1041 = (fileBasicInformation.ChangeTime.dwHighDateTime > 0 || fileBasicInformation.ChangeTime.dwLowDateTime > 0) && Marshal.SizeOf(fileBasicInformation.ChangeTime) == 8; Site.CaptureRequirementIfIsTrue( isVerifyR1041, 1041, @"[In FILE_BASIC_INFORMATION]ChangeTime (8 bytes): A valid time for this field is an integer greater than 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1044, actual ChangeTime: {0}", fileBasicInformation.ChangeTime.ToString()); // // Verify MS-FSCC requirement 1044 // // As the type of the ChangeTime is uint, it can not be less 0, so only verifiy if >= 0 bool isVerifyR1044 = (fileBasicInformation.ChangeTime.dwHighDateTime >= 0 && fileBasicInformation.ChangeTime.dwLowDateTime >= 0) && Marshal.SizeOf(fileBasicInformation.ChangeTime) == 8; Site.CaptureRequirementIfIsTrue( isVerifyR1044, 1044, @"[In FILE_BASIC_INFORMATION]ChangeTime (8 bytes): This field MUST NOT be set to a value less than -1. <56>"); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1045, actual FileAttributes: {0}", fileBasicInformation.FileAttributes); // // Verify MS-FSCC requirement 1045 // // right now, the file attribute is Fuzzy and untestable, so we didn't verify if it's legal. Site.CaptureRequirementIfAreEqual<int>( 4, Marshal.SizeOf(fileBasicInformation.FileAttributes), 1045, @"[In FILE_BASIC_INFORMATION]FileAttributes (4 bytes): A 32-bit unsigned integer that contains the file attributes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1046, actual FileAttributes: {0}", fileBasicInformation.FileAttributes); // // Verify MS-FSCC requirement 1046 // // Verify the size and the value of FileAttributes, and the values are: // FILE_ATTRIBUTE_ARCHIVE 0x00000020, FILE_ATTRIBUTE_COMPRESSED 0x00000800, // FILE_ATTRIBUTE_DIRECTORY 0x00000010, FILE_ATTRIBUTE_ENCRYPTED 0x00004000, // FILE_ATTRIBUTE_HIDDEN 0x00000002, FILE_ATTRIBUTE_NORMAL 0x00000080, // FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000, FILE_ATTRIBUTE_OFFLINE 0x00001000, // FILE_ATTRIBUTE_READONLY 0x00000001, FILE_ATTRIBUTE_REPARSE_POINT 0x00000400, // FILE_ATTRIBUTE_SPARSE_FILE 0x00000200, FILE_ATTRIBUTE_SYSTEM 0x00000004, // FILE_ATTRIBUTE_TEMPORARY 0x00000100] uint bitUsed = ( 0x00000020 | 0x00000800 | 0x00000010 | 0x00004000 | 0x00000002 | 0x00000080 | 0x00002000 | 0x00001000 | 0x00000001 | 0x00000400 | 0x00000200 | 0x00000004 | 0x00000100); // Get the bits which the file attributes not used uint bitUnused = ~bitUsed; const int sizeOfFileAttributes = 4; bool isVerifyR11046 = ((sizeOfFileAttributes == Marshal.SizeOf(fileBasicInformation.FileAttributes)) && ((bitUnused & fileBasicInformation.FileAttributes) == 0x00000000)); // Verify the size and the actual value of FileAttributes Site.CaptureRequirementIfIsTrue( isVerifyR11046, 1046, @"[In FILE_BASIC_INFORMATION]FileAttributes (4 bytes): Valid file attributes are specified in section 2.6."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1047, actual type of Reserved: {0};", fileBasicInformation.Reserved.GetType()); // // Verify MS-FSCC requirement 1047 // const int sizeOfReserved = 4; Site.CaptureRequirementIfAreEqual<int>( sizeOfReserved, Marshal.SizeOf(fileBasicInformation.Reserved), 1047, @"[In FILE_BASIC_INFORMATION]Reserved (4 bytes): A 32-bit field."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1048"); // // Verify MS-FSCC requirement 1048 // // As the value of the Reserved can be any value, only verify the size of it Site.CaptureRequirementIfAreEqual<int>( sizeOfReserved, Marshal.SizeOf(fileBasicInformation.Reserved), 1048, @"[In FILE_BASIC_INFORMATION]Reserved (4 bytes): This field is reserved."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1050"); // // Verify MS-FSCC requirement 1050 // // As the value of the Reserved can be any value, this rs will be only verified the size. Site.CaptureRequirementIfAreEqual<int>( sizeOfReserved, Marshal.SizeOf(fileBasicInformation.Reserved), 1050, @"[In FILE_BASIC_INFORMATION]Reserved (4 bytes): This field can be set to any value."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1023"); // // Verify MS-FSCC requirement 1023 // // As all the elements in the FILE_BASIC_INFORMATION are verified above, // This rs will be captured directly Site.CaptureRequirement( 1023, @"The FILE_BASIC_INFORMATION data element is as follows:[CreationTime, ..., LastAccessTime, ..., LastWriteTime, ..., ChangeTime, ..., FileAttributes, Reserved]."); // for FILE_BASIC_INFORMATION is defined as section 2.4.7 in the sdk, // after all the member of FILE_BASIC_INFORMATION is verified , this rs can be covered. Site.CaptureRequirement( 978, @"[In FileAllInformation]BasicInformation (40 bytes): A FILE_BASIC_INFORMATION structure specified in section 2.4.7."); Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }