diff --git a/TestSuites/FileServer/src/FSA/Adapter/FSAAdapter.cs b/TestSuites/FileServer/src/FSA/Adapter/FSAAdapter.cs index bd9e79306..4802877fc 100644 --- a/TestSuites/FileServer/src/FSA/Adapter/FSAAdapter.cs +++ b/TestSuites/FileServer/src/FSA/Adapter/FSAAdapter.cs @@ -3612,6 +3612,46 @@ BufferSize bufferSize return returnedStatus; } + /// + /// Implement FsCtlSetObjID method + /// + /// FsControlRequestType is self-defined to indicate control type + /// Indicate buffer size + /// An NTSTATUS code that specifies the result + public MessageStatus FsCtlSetObjID( + FsControlRequestType requestType, + BufferSize bufferSize, + byte[] inbuffer + ) + { + byte[] outbuffer = new byte[0]; + uint ctlCode = 0; + + // According to FSCC 2.3, the ctlCode should be as follows: + switch (requestType) + { + case FsControlRequestType.SET_OBJECT_ID: + ctlCode = (uint)FsControlCommand.FSCTL_SET_OBJECT_ID; + break; + + case FsControlRequestType.SET_OBJECT_ID_EXTENDED: + ctlCode = (uint)FsControlCommand.FSCTL_SET_OBJECT_ID_EXTENDED; + break; + + default: + ctlCode = (uint)FsControlCommand.FSCTL_SET_OBJECT_ID; + break; + } + + MessageStatus returnedStatus = transAdapter.IOControl( + ctlCode, + this.transBufferSize, + inbuffer, + out outbuffer); + + return returnedStatus; + } + #endregion #region 3.1.5.9.30 FSCTL_SET_REPARSE_POINT diff --git a/TestSuites/FileServer/src/FSA/Adapter/IFSAAdapter.cs b/TestSuites/FileServer/src/FSA/Adapter/IFSAAdapter.cs index 5b869ec2a..7205c6dbb 100644 --- a/TestSuites/FileServer/src/FSA/Adapter/IFSAAdapter.cs +++ b/TestSuites/FileServer/src/FSA/Adapter/IFSAAdapter.cs @@ -482,6 +482,18 @@ MessageStatus FsCtlSetObjID( FsControlRequestType requestType, BufferSize bufferSize ); + + /// + /// Implement FsCtlSetObjID Interface + /// + /// FsControlRequestType is self-defined to indicate control type + /// Indicate buffer size + /// An NTSTATUS code that specifies the result + MessageStatus FsCtlSetObjID( + FsControlRequestType requestType, + BufferSize bufferSize, + byte[] inbuffer + ); #endregion #region 3.1.5.9.32 FSCTL_SET_SPARSE diff --git a/TestSuites/FileServer/src/FSA/TestSuite/FsControlRequest/FSCTL_SET_OBJECT_ID.cs b/TestSuites/FileServer/src/FSA/TestSuite/FsControlRequest/FSCTL_SET_OBJECT_ID.cs new file mode 100644 index 000000000..2ddd69b05 --- /dev/null +++ b/TestSuites/FileServer/src/FSA/TestSuite/FsControlRequest/FSCTL_SET_OBJECT_ID.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Protocols.TestSuites.FileSharing.Common.Adapter; +using Microsoft.Protocols.TestSuites.FileSharing.FSA.Adapter; +using Microsoft.Protocols.TestTools; +using Microsoft.Protocols.TestTools.StackSdk; +using Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Fscc; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; + +namespace Microsoft.Protocols.TestSuites.FileSharing.FSA.TestSuite +{ + public partial class FsCtlTestCases : PtfTestClassBase + { + #region Test cases + + #region FsCtl_SetObjectId_IsSupported + + [TestMethod()] + [TestCategory(TestCategories.Bvt)] + [TestCategory(TestCategories.Fsa)] + [TestCategory(TestCategories.IoCtlRequest)] + [TestCategory(TestCategories.NonSmb)] + [TestCategory(TestCategories.Positive)] + [Description("Send FSCTL_SET_OBJECT_ID request to a file.")] + public void BVT_FsCtl_SetObjectId_File_IsSupported() + { + FsCtl_SetObjectId_Test(FileType.DataFile); + } + + [TestMethod()] + [TestCategory(TestCategories.Bvt)] + [TestCategory(TestCategories.Fsa)] + [TestCategory(TestCategories.IoCtlRequest)] + [TestCategory(TestCategories.NonSmb)] + [TestCategory(TestCategories.Positive)] + [Description("Send FSCTL_SET_OBJECT_ID request to a directory.")] + public void BVT_FsCtl_SetObjectId_Dir_IsSupported() + { + FsCtl_SetObjectId_Test(FileType.DirectoryFile); + } + + #endregion + + #region OutputBufferSize_TooSmall Tests + + [TestMethod()] + [TestCategory(TestCategories.Fsa)] + [TestCategory(TestCategories.IoCtlRequest)] + [TestCategory(TestCategories.NonSmb)] + [Description("Send FSCTL_SET_OBJECT_ID request to a file.")] + public void FsCtl_SetObjectId_File_OutputBufferSize_TooSmall() + { + FsCtl_SetObjectId_Test(FileType.DataFile, BufferSize.LessThanFILE_OBJECTID_BUFFER); + } + + [TestMethod()] + [TestCategory(TestCategories.Fsa)] + [TestCategory(TestCategories.IoCtlRequest)] + [TestCategory(TestCategories.NonSmb)] + [Description("Send FSCTL_SET_OBJECT_ID request to a directory.")] + public void FsCtl_SetObjectId_Dir_OutputBufferSize_TooSmall() + { + FsCtl_SetObjectId_Test(FileType.DirectoryFile, BufferSize.LessThanFILE_OBJECTID_BUFFER); + } + + #endregion + + #endregion + + #region Test Case Utility + + private void FsCtl_SetObjectId_Test(FileType fileType, BufferSize bufferSize = BufferSize.BufferSizeSuccess) + { + BaseTestSite.Log.Add(LogEntryKind.TestStep, "Test case steps:"); + MessageStatus status; + + //Step 1: Create file + BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. Create " + fileType.ToString()); + status = fsaAdapter.CreateFile(fileType); + BaseTestSite.Assert.AreEqual(MessageStatus.SUCCESS, status, "Create should succeed."); + + + //Step 2: FSCTL request with FSCTL_SET_OBJECT_ID + BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. FSCTL request with FSCTL_SET_OBJECT_ID"); + FILE_OBJECTID_BUFFER_Type_1 inputBuffer = new() + { + ObjectId = Guid.NewGuid() + }; + status = fsaAdapter.FsCtlSetObjID(FsControlRequestType.SET_OBJECT_ID, bufferSize, TypeMarshal.ToBytes(inputBuffer)); + + //Step 3: Verify test result + BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. Verify returned NTSTATUS code."); + // MS-FSA 2.1.5.10.35 FSCTL_SET_OBJECT_ID + // <132> Section 2.1.5.10.35: This is only implemented by the NTFS file systems. + if (fsaAdapter.IsObjectIDsSupported) + { + if (bufferSize == BufferSize.LessThanFILE_OBJECTID_BUFFER) + { + fsaAdapter.AssertAreEqual(Manager, MessageStatus.INVALID_PARAMETER, status, "FSCTL_SET_OBJECT_ID is supported, If OutputBufferSize is less than sizeof(FILE_OBJECTID_BUFFER), the operation MUST be failed with STATUS_INVALID_PARAMETER."); + } + else + { + fsaAdapter.AssertAreEqual(Manager, MessageStatus.SUCCESS, status, "FSCTL_SET_OBJECT_ID is supported, status set to STATUS_SUCCESS."); + } + } + else + { + fsaAdapter.AssertAreEqual(Manager, MessageStatus.INVALID_DEVICE_REQUEST, status, + "If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST."); + } + } + + #endregion + } +} diff --git a/pipelines/github/GitHubPR-Regression.yml b/pipelines/github/GitHubPR-Regression.yml index b3273baee..c2195da4a 100644 --- a/pipelines/github/GitHubPR-Regression.yml +++ b/pipelines/github/GitHubPR-Regression.yml @@ -119,7 +119,7 @@ stages: steps: - checkout: none - - script: "git clone -b $(extRepo.branchName) $(extRepo.url) $(extRepo.dir)" + - script: "git clone -b $(extRepo.branchName) $(extRepo.v2.url) $(extRepo.dir)" displayName: "Fetch Helper" - task: PowerShell@2 @@ -127,7 +127,7 @@ stages: inputs: targetType: filePath filePath: "$(extRepo.dir)/RegressionRunScripts/Common/Queue-SinglePipelineWithParameters.ps1" - arguments: '-AccessToken "$(System.AccessToken)" -ApiUrl "$(build.apiUrl)" -RemoteAccessToken "$(tokens.pipelineTriggerToken)" -RemoteApiUrl "$(extRepo.apiUrl)" -PipelineName "$(test.regressionPipelineName)" -TargetRepoBranch "$(extRepo.branchName)" -PipelineParameters "`"targetRepo.csvFile`": `"$(test.targetRepoCsvFile)`", `"test.filter`": `"$(test.filter)`", `"test.buildId`": `"$(Build.BuildId)`", `"test.remoteApiUrl`": `"$(build.apiUrl)`", `"test.remoteAccessToken`": `"$(System.AccessToken)`"" -BuildIdVariableName "test.regressionBuildId" -Reason "manual" -ReportInfo $false' + arguments: '-AccessToken "$(System.AccessToken)" -ApiUrl "$(build.apiUrl)" -RemoteAccessToken "$(tokens.pipelineTriggerTokenV2)" -RemoteApiUrl "$(extRepo.apiUrl)" -PipelineName "$(test.regressionPipelineName)" -TargetRepoBranch "$(extRepo.branchName)" -PipelineParameters "`"targetRepo.csvFile`": `"$(test.targetRepoCsvFile)`", `"test.filter`": `"$(test.filter)`", `"test.buildId`": `"$(Build.BuildId)`", `"test.remoteApiUrl`": `"$(build.apiUrl)`", `"test.remoteAccessToken`": `"$(System.AccessToken)`"" -BuildIdVariableName "test.regressionBuildId" -Reason "manual" -ReportInfo $false' workingDirectory: "$(extRepo.dir)/RegressionRunScripts/Common" - task: PowerShell@2