/// <summary>
        /// This method is used to fetch editor table on the specified file.
        /// </summary>
        /// <param name="file">Specify the file URL.</param>
        /// <returns>Return the editors table on the file if the server support the editor tables, otherwise return null.</returns>
        protected EditorsTable FetchEditorTable(string file)
        {
            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 2053, this.Site))
            {
                // Call QueryEditorsTable to get editors table
                this.InitializeContext(file, this.UserName01, this.Password01, this.Domain);
                CellSubRequestType  cellSubRequestEditorsTable      = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryEditorsTable(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());
                CellStorageResponse cellStorageResponseEditorsTable = this.Adapter.CellStorageRequest(file, new SubRequestType[] { cellSubRequestEditorsTable });
                CellSubResponseType subResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(cellStorageResponseEditorsTable, 0, 0, this.Site);
                FsshttpbResponse    queryEditorsTableResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(subResponse, this.Site);

                // Get EditorsTable
                EditorsTable editorsTable = EditorsTableUtils.GetEditorsTableFromResponse(queryEditorsTableResponse, this.Site);

                if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                {
                    // If can fetch the editors table, then the following requirement can be directly captured.
                    this.Site.CaptureRequirement(
                        "MS-FSSHTTP",
                        2053,
                        @"[In Appendix B: Product Behavior]  Implementation does represent the editors table as a compressed XML fragment. (<42> Section 3.1.4.8: On servers running Office 2013, the editors table is represented as a compressed XML fragment.)");
                }

                return(editorsTable);
            }

            return(null);
        }
Beispiel #2
0
        public void MSONESTORE_S01_TC02_QueryEncyptionOneFile()
        {
            // Get the resource url that contains the file data.
            string resourceName = Common.GetConfigurationPropertyValue("OneFileEncryption", Site);
            string url          = this.GetResourceUrl(resourceName);

            this.InitializeContext(url, this.UserName, this.Password, this.Domain);

            // Call QueryChange to get the data that is uploaded by above step.
            CellSubRequestType  cellSubRequest      = this.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentSerialNumber());
            CellStorageResponse cellStorageResponse = this.SharedAdapter.CellStorageRequest(url, new SubRequestType[] { cellSubRequest });
            MSOneStorePackage   package             = this.ConvertOneStorePackage(cellStorageResponse);

            #region Capture code
            RevisionManifestDataElementData rootRevisionManifest = package.RevisionManifests[0];
            bool isFoundEncryptionKeyRoot = false;

            isFoundEncryptionKeyRoot =
                rootRevisionManifest.RevisionManifestRootDeclareList.Where(r => r.RootExtendedGUID.Value == 0x00000003).ToArray().Length == 1;

            Site.CaptureRequirementIfIsTrue(
                isFoundEncryptionKeyRoot,
                932,
                @"[In Revisions] The root object with RootObjectReference3FND.rootRole value set to 0x00000003 MUST be present only when the file is encrypted. (see section 2.7.7).");
            #endregion
        }
        public void TestCase_S10_TC01_SubRequestToken()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);

            // Update the file contents when the coalesce is true.
            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10)));

            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            CellStorageResponse response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest, putChange });
            int exclusiveIndex           = 0;
            int putchangeIndex           = 0;

            for (int i = 0; i < response.ResponseCollection.Response[0].SubResponse.Length; i++)
            {
                if (response.ResponseCollection.Response[0].SubResponse[i].SubRequestToken == exclusiveLocksubRequest.SubRequestToken)
                {
                    exclusiveIndex = i;
                }
                else if (response.ResponseCollection.Response[0].SubResponse[i].SubRequestToken == putChange.SubRequestToken)
                {
                    putchangeIndex = i;
                }
            }

            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, exclusiveIndex, this.Site);
            CellSubResponseType          putChangeResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, putchangeIndex, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site), "Test case cannot continue unless the get lock sub request succeeds.");
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, exclusiveLocksubRequest.SubRequestData.ExclusiveLockID);
            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(putChangeResponse.ErrorCode, this.Site), "Test case cannot continue unless the put changes sub request succeeds.");

            this.Site.Assert.AreEqual <int>(
                int.Parse(exclusiveLocksubRequest.SubRequestToken),
                int.Parse(exclusiveResponse.SubRequestToken),
                "Test case cannot run unless the put change response token equals the expected sub request token.");
            this.Site.Assert.AreEqual <int>(
                int.Parse(putChange.SubRequestToken),
                int.Parse(putChangeResponse.SubRequestToken),
                "Test case cannot run unless the put change response token equals the expected sub request token.");

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If both the subRequest tokens are mapping, then MS-FSSHTTP_R1484 and MS-FSSHTTP_R283 can be captured.
                Site.CaptureRequirement(
                    "MS-FSSHTTP",
                    1484,
                    @"[In SubResponseType] SubRequestToken: If client sends 2 SubRequest elements in the Request, in the server response, SubRequestToken uniquely identifies the 2 SubRequest element whose subresponse is being generated as part of the SubResponse element.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R283
                Site.CaptureRequirement(
                    "MS-FSSHTTP",
                    283,
                    @"[In SubResponseType][SubRequestToken] The mapping subresponse that gets generated for the subrequest references the SubRequestToken to indicate that it is the response for that subrequest.");
            }
        }
Beispiel #4
0
        /// <summary>
        /// A method used to create a CellSubRequest object for QueryChanges and initialize it.
        /// </summary>
        /// <param name="subRequestId">A parameter represents the subRequest identifier.</param>
        /// <returns>A return value represents the CellRequest object for QueryChanges.</returns>
        private CellSubRequestType CreateCellSubRequestEmbeddedQueryChanges(ulong subRequestId)
        {
            FsshttpbCellRequest        cellRequest = this.CreateFsshttpbCellRequest();
            QueryChangesCellSubRequest queryChange = this.BuildFsshttpbQueryChangesSubRequest(subRequestId);

            cellRequest.AddSubRequest(queryChange, null);

            CellSubRequestType cellSubRequest = this.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64());

            return(cellSubRequest);
        }
Beispiel #5
0
        public void TestCase_S10_TC04_DependencyTypeOnNotSupported_Support()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);

            // Update the file contents when the coalesce is true.
            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10)));

            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            // Make a putChanges subRequest dependent on the exclusive lock and the dependency type is OnNotSupported.
            putChange.DependencyTypeSpecified = true;
            putChange.DependencyType          = DependencyTypes.OnNotSupported;
            putChange.DependsOn = exclusiveLocksubRequest.SubRequestToken;

            CellStorageResponse response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest, putChange });

            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);
            CellSubResponseType          putChanges        = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 1, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site), "Test case cannot continue unless the get lock sub request succeeds.");
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, exclusiveLocksubRequest.SubRequestData.ExclusiveLockID);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code equals DependentOnlyOnNotSupportedRequestGetSupported, then capture R324 and R2244
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnNotSupportedRequestGetSupported,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    324,
                    @"[In DependencyCheckRelatedErrorCodeTypes] DependentOnlyOnNotSupportedRequestGetSupported:
                         Indicates an error when the subrequest on which this specific subrequest is dependent is supported and the DependencyType attribute in this subrequest is set to ""OnNotSupported"" or [""OnSuccessOrOnNotSupported""].");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2244
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnNotSupportedRequestGetSupported,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    2244,
                    @"[In DependencyTypes] OnNotSupported: Indicates that the subrequest MUST NOT be processed if the other subrequest is supported.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnNotSupportedRequestGetSupported,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    @"[In DependencyCheckRelatedErrorCodeTypes] DependentOnlyOnNotSupportedRequestGetSupported:
                        Indicates an error when the subrequest on which this specific subrequest is dependent is supported and the DependencyType attribute in this subrequest is set to ""OnNotSupported"" or [""OnSuccessOrOnNotSupported""].");
            }
        }
Beispiel #6
0
        /// <summary>
        /// A method used to create a CellSubRequest object and initialize it.
        /// </summary>
        /// <param name="requestToken">A parameter represents Request token.</param>
        /// <param name="base64Content">A parameter represents serialized subRequest.</param>
        /// <param name="binaryDataSize">A parameter represents the number of bytes of data in the SubRequestData element of a cell sub-request.</param>
        /// <returns>A return value represents CellSubRequest object.</returns>
        private CellSubRequestType CreateCellSubRequest(ulong requestToken, string base64Content, long binaryDataSize)
        {
            CellSubRequestType cellRequestType = new CellSubRequestType();

            cellRequestType.SubRequestToken = requestToken.ToString();
            CellSubRequestDataType subRequestData = new CellSubRequestDataType();

            subRequestData.BinaryDataSize = binaryDataSize;
            subRequestData.Text           = new string[1];
            subRequestData.Text[0]        = base64Content;

            cellRequestType.SubRequestData = subRequestData;

            return(cellRequestType);
        }
Beispiel #7
0
        public void MSFSSHTTP_FSSHTTPB_S01_TC03_DownloadContents_InvalidUrl()
        {
            // Query the updated file content using the invalid url.
            string invalidUrl = this.DefaultFileUrl + "Invalid";

            // Initialize the context using user01 and invalid url.
            this.InitializeContext(invalidUrl, this.UserName01, this.Password01, this.Domain);

            CellSubRequestType  queryChange     = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());
            CellStorageResponse response        = Adapter.CellStorageRequest(invalidUrl, new SubRequestType[] { queryChange });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1875
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.CellRequestFail,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1875,
                    @"[In Cell Subrequest][The protocol server returns results based on the following conditions:] If the protocol server was unable to find the URL for the file specified in the Url attribute, the protocol server reports a failure by returning an error code value set to ""CellRequestFail"" in the ErrorCode attribute sent back in the SubResponse element. [and the binary data in the returned SubRequestData element indicates an HRESULT Error as described in [MS-FSSHTTPB] section 2.2.3.2.4.]");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R11230
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.CellRequestFail,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    11230,
                    @"[In Cell Subrequest][The protocol server returns results based on the following conditions:] [If the protocol server was unable to find the URL for the file specified in the Url attribute, the protocol server reports a failure by returning an error code value set to ""CellRequestFail"" in the ErrorCode attribute sent back in the SubResponse element, and] the binary data in the returned SubRequestData element indicates an HRESULT Error as described in [MS-FSSHTTPB] section 2.2.3.2.4.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.CellRequestFail,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    @"[In Cell Subrequest][The protocol server returns results based on the following conditions:] If the protocol server was unable to find the URL for the file specified in the Url attribute, the protocol server reports a failure by returning an error code value set to ""CellRequestFail"" in the ErrorCode attribute sent back in the SubResponse element. [and the binary data in the returned SubRequestData element indicates an HRESULT Error as described in [MS-FSSHTTPB] section 2.2.3.2.4.]");

                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.CellRequestFail,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    @"[In Cell Subrequest][The protocol server returns results based on the following conditions:] [If the protocol server was unable to find the URL for the file specified in the Url attribute, the protocol server reports a failure by returning an error code value set to ""CellRequestFail"" in the ErrorCode attribute sent back in the SubResponse element, and] the binary data in the returned SubRequestData element indicates an HRESULT Error as described in [MS-FSSHTTPB] section 2.2.3.2.4.");
            }
        }
        public void TestCase_S15_TC02_UploadContents_CreateFile_ExclusiveLock()
        {
            string randomFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

            // Initialize the context using user01 and defaultFileUrl.
            this.InitializeContext(randomFileUrl, this.UserName01, this.Password01, this.Domain);

            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), SharedTestSuiteHelper.GenerateRandomFileContent(this.Site));

            putChange.SubRequestData.CoalesceSpecified           = true;
            putChange.SubRequestData.Coalesce                    = true;
            putChange.SubRequestData.ExpectNoFileExistsSpecified = true;
            putChange.SubRequestData.ExpectNoFileExists          = true;
            putChange.SubRequestData.ExclusiveLockID             = SharedTestSuiteHelper.DefaultExclusiveLockID;
            putChange.SubRequestData.Timeout = "3600";

            CellStorageResponse response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "When uploading contents if the protocol server was unable to find the URL for the file specified in the Url attribute,, the server returns success and create a new file using the specified contents in the file URI.");

            bool isExclusiveLock = this.CheckExclusiveLockExist(randomFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID, this.UserName01, this.Password01, this.Domain);

            Site.Log.Add(
                TestTools.LogEntryKind.Debug,
                "When creating a new file with ExclusiveLockID specified, the server will lock the new created file, but actually it {0}",
                isExclusiveLock ? "locks" : "does not lock");

            Site.Assert.IsTrue(
                isExclusiveLock,
                "When creating a new file with ExclusiveLockID specified, the server will lock the new created file");

            this.StatusManager.RecordExclusiveLock(randomFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID, this.UserName01, this.Password01, this.Domain);
            this.StatusManager.RecordFileUpload(randomFileUrl);
        }
Beispiel #9
0
        public void MSONESTORE_S01_TC01_QueryOneFileContainsFileData()
        {
            // Get the resource url that contains the file data.
            string resourceName = Common.GetConfigurationPropertyValue("OneFileWithFileData", Site);
            string url          = this.GetResourceUrl(resourceName);

            this.InitializeContext(url, this.UserName, this.Password, this.Domain);

            // Call QueryChange to get the data that is specified by above step.
            CellSubRequestType  cellSubRequest      = this.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentSerialNumber());
            CellStorageResponse cellStorageResponse = this.SharedAdapter.CellStorageRequest(url, new SubRequestType[] { cellSubRequest });
            MSOneStorePackage   package             = this.ConvertOneStorePackage(cellStorageResponse);

            // Call adapter to load same file in local.
            OneNoteRevisionStoreFile file    = this.Adapter.LoadOneNoteFile(resourceName);
            int             objectSpaceCount = file.RootFileNodeList.ObjectSpaceManifestList.Count;
            List <FileNode> fileData3Refs    = new List <FileNode>();

            for (int i = 0; i < file.RootFileNodeList.ObjectSpaceManifestList.Count; i++)
            {
                ObjectSpaceManifestList objectSpace = file.RootFileNodeList.ObjectSpaceManifestList[i];
                for (int j = 0; j < objectSpace.RevisionManifestList[0].ObjectGroupList.Count; j++)
                {
                    ObjectGroupList objectGroupList = objectSpace.RevisionManifestList[0].ObjectGroupList[j];
                    fileData3Refs.AddRange(objectGroupList.FileNodeSequence.Where(f => f.FileNodeID == FileNodeIDValues.ObjectDeclarationFileData3RefCountFND).ToArray());
                }
            }

            #region Capture code for Revisions
            ExGuid rootObjectId = package.DataRoot[0].ObjectGroupID;
            RevisionManifestDataElementData rootRevision = package.RevisionManifests[0];

            // Verify MS-ONESTORE requirement: MS-ONESTORE_R933
            Site.CaptureRequirementIfAreEqual <ExGuid>(
                rootObjectId,
                rootRevision.RevisionManifestObjectGroupReferencesList[0].ObjectGroupExtendedGUID,
                933,
                @"[In Revisions] The Object Extended GUID field in the Revision Manifest Data Element structure MUST be equal to the identity of the corresponding root object in the revision in the revision store.");
            #endregion

            #region Capture code for Objects
            List <RevisionStoreObject> objectsWithFileData = new List <RevisionStoreObject>();
            foreach (RevisionStoreObjectGroup objGroup in package.DataRoot)
            {
                objectsWithFileData.AddRange(objGroup.Objects.Where(o => o.FileDataObject != null).ToArray());
            }
            foreach (RevisionStoreObjectGroup objGroup in package.OtherFileNodeList)
            {
                objectsWithFileData.AddRange(objGroup.Objects.Where(o => o.FileDataObject != null).ToArray());
            }
            string           subResponseBase64  = cellStorageResponse.ResponseCollection.Response[0].SubResponse[0].SubResponseData.Text[0];
            byte[]           subResponseBinary  = Convert.FromBase64String(subResponseBase64);
            FsshttpbResponse fsshttpbResponse   = FsshttpbResponse.DeserializeResponseFromByteArray(subResponseBinary, 0);
            DataElement[]    objectBlOBElements = fsshttpbResponse.DataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.ObjectDataBLOBDataElementData).ToArray();

            foreach (RevisionStoreObject obj in objectsWithFileData)
            {
                Guid   fileDataObjectGuid = this.GetFileDataObjectGUID(obj);
                string extension          = this.GetFileDataObjectExtension(obj);
                bool   isFoundBLOB        =
                    objectBlOBElements.Where(b => b.DataElementExtendedGUID.Equals(obj.FileDataObject.ObjectDataBLOBReference.BLOBExtendedGUID)).ToArray().Length > 0;

                // Verify MS-ONESTORE requirement: MS-ONESTORE_R948
                Site.CaptureRequirementIfIsTrue(
                    isFoundBLOB && obj.FileDataObject.ObjectDataBLOBDeclaration.ObjectPartitionID.DecodedValue == 2,
                    948,
                    @"[In Objects] Object Data BLOB Declaration.PartitionID: 2 (File Data) and Object Data BLOB Reference. BLOB Extended GUID: MUST have a reference to an Object Data BLOB Data Element structure, as specified in [MS-FSSHTTPB] section 2.2.1.12.8, used to transmit the data of the file data object.");

                foreach (FileNode fn in fileData3Refs)
                {
                    ObjectDeclarationFileData3RefCountFND fnd = fn.fnd as ObjectDeclarationFileData3RefCountFND;
                    if (fnd.FileDataReference.StringData.ToLower().Contains(fileDataObjectGuid.ToString().ToLower()))
                    {
                        // Verify MS-ONESTORE requirement: MS-ONESTORE_R951
                        Site.CaptureRequirementIfIsTrue(
                            fnd.FileDataReference.StringData.StartsWith("<invfdo>") == false,
                            951,
                            @"[In Objects] This property MUST be set only if the prefix specified by the ObjectDeclarationFileData3RefCountFND.FileDataReference field (section 2.5.27) [or ObjectDeclarationFileData3LargeRefCountFND.FileDataReference field (section 2.5.28)] is not <invfdo>.");


                        Site.CaptureRequirementIfAreEqual <string>(
                            fnd.Extension.StringData,
                            extension,
                            958,
                            @"[In Objects] MUST be the value specified by the ObjectDeclarationFileData3RefCountFND.Extension field [or the ObjectDeclarationFileData3LargeRefCountFND.Extension] field.");
                        break;
                    }
                }
            }
            #endregion
        }
        public void TestCase_S15_TC03_Download_UploadPartial()
        {
            string fileUrl       = Common.GetConfigurationPropertyValue("BigFile", this.Site);
            string uploadFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(Site);
            bool   partial       = false;

            Knowledge knowledge = null;

            // Set the limit number of upload tries, this will allow 500000 * 10 bytes size file to be download and complete upload.
            int limitNumberOfPartialUpload = 10;

            do
            {
                this.InitializeContext(fileUrl, this.UserName01, this.Password01, this.Domain);

                // Create query changes request with allow fragments flag with the value false.
                FsshttpbCellRequest        cellRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
                QueryChangesCellSubRequest queryChange = SharedTestSuiteHelper.BuildFsshttpbQueryChangesSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), 0, false, false, true, 0, true, true, 0, null, 500000, null, knowledge);
                cellRequest.AddSubRequest(queryChange, null);
                CellSubRequestType cellSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64());

                CellStorageResponse cellStorageResponse = this.Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { cellSubRequest });
                CellSubResponseType subResponse         = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(cellStorageResponse, 0, 0, this.Site);
                this.Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site),
                    "Test case cannot continue unless the query changes succeed.");

                FsshttpbResponse queryResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(subResponse, this.Site);
                SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(queryResponse, this.Site);
                QueryChangesSubResponseData data = queryResponse.CellSubResponses[0].GetSubResponseData <QueryChangesSubResponseData>();
                partial   = data.PartialResult;
                knowledge = data.Knowledge;

                this.InitializeContext(uploadFileUrl, this.UserName01, this.Password01, this.Domain);
                cellRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
                PutChangesCellSubRequest putChange = new PutChangesCellSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), null);
                putChange.Partial     = partial ? 1 : 0;
                putChange.PartialLast = partial ? 0 : 1;
                putChange.StorageIndexExtendedGUID = partial ? null : data.StorageIndexExtendedGUID;

                if (partial)
                {
                    var storageIndex = queryResponse.DataElementPackage.DataElements.FirstOrDefault(e => e.DataElementType == DataElementType.StorageIndexDataElementData);
                    if (storageIndex != null)
                    {
                        queryResponse.DataElementPackage.DataElements.Remove(storageIndex);
                    }
                }

                cellRequest.AddSubRequest(putChange, queryResponse.DataElementPackage.DataElements);
                cellSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64());

                cellStorageResponse = this.Adapter.CellStorageRequest(uploadFileUrl, new SubRequestType[] { cellSubRequest });
                subResponse         = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(cellStorageResponse, 0, 0, this.Site);
                this.Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site),
                    "Test case cannot continue unless the query changes succeed.");

                FsshttpbResponse putResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(subResponse, this.Site);
                SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(putResponse, this.Site);

                // Decrease the number of upload tries.
                limitNumberOfPartialUpload--;
            }while (partial && limitNumberOfPartialUpload > 0);

            this.StatusManager.RecordFileUpload(uploadFileUrl);
        }
        public void TestCase_S11_TC02_QueryAccessRead()
        {
            string readOnlyUser         = Common.GetConfigurationPropertyValue("ReadOnlyUser", this.Site);
            string readOnlyUserPassword = Common.GetConfigurationPropertyValue("ReadOnlyUserPwd", this.Site);

            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, readOnlyUser, readOnlyUserPassword, this.Domain);

            // Query changes from the protocol server
            CellSubRequestType  queryChange      = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());
            CellStorageResponse queryResponse    = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { queryChange });
            CellSubResponseType querySubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(queryResponse, 0, 0, this.Site);
            FsshttpbResponse    fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(querySubResponse, this.Site);

            this.Site.Assert.AreEqual(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(querySubResponse.ErrorCode, this.Site),
                "The operation QueryChanges should succeed when the user {0} only has ViewOnly permission.",
                readOnlyUser);

            this.Site.Assert.IsFalse(
                fsshttpbResponse.CellSubResponses[0].Status,
                "The operation QueryChanges should succeed when the user {0} only has ViewOnly permission.",
                readOnlyUser);

            // Call QueryAccess
            CellSubRequestType  cellSubRequest      = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryAccess(0);
            CellStorageResponse cellStorageResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { cellSubRequest });
            CellSubResponseType subResponse         = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(cellStorageResponse, 0, 0, this.Site);
            FsshttpbResponse    queryAccessResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(subResponse, this.Site);

            // Get readAccessResponse and writeAccessResponse Data.
            HRESULTError dataRead = queryAccessResponse.CellSubResponses[0]
                                    .GetSubResponseData <QueryAccessSubResponseData>()
                                    .ReadAccessResponse.ReadResponseError
                                    .GetErrorData <HRESULTError>();

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error type is HRESULTError, then capture R944.
                Site.CaptureRequirementIfIsNotNull(
                    dataRead,
                    "MS-FSSHTTPB",
                    944,
                    @"[In Query Access] Response Error (variable): If read operations will succeed, the response error will have an error type of HRESULT error.");

                // If HResult is 0,MS-FSSHTTPB_R2228 should be covered.
                Site.CaptureRequirementIfAreEqual <int>(
                    0,
                    dataRead.ErrorCode,
                    "MS-FSSHTTPB",
                    2228,
                    @"[In Query Access] Response Error (variable): [If read operations will succeed, ]the HRESULT error code will be zero.");
            }
            else
            {
                Site.Assert.IsNotNull(
                    dataRead,
                    @"[In Query Access] Response Error (variable): If read operations will succeed, the response error will have an error type of HRESULT error.");

                Site.Assert.AreEqual <int>(
                    0,
                    dataRead.ErrorCode,
                    @"[In Query Access] Response Error (variable): [If read operations will succeed, ]the HRESULT error code will be zero.");
            }

            HRESULTError dataWrite = queryAccessResponse.CellSubResponses[0]
                                     .GetSubResponseData <QueryAccessSubResponseData>()
                                     .WriteAccessResponse.WriteResponseError
                                     .GetErrorData <HRESULTError>();

            this.Site.Assert.AreNotEqual <int>(
                0,
                dataWrite.ErrorCode,
                "Test case cannot continue unless the write HRESULTError code not equals 0 when the user have read permission.");
        }
Beispiel #12
0
        public void TestCase_S14_TC02_AllocateExtendedGuidRange_ReservedIgnore()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            FsshttpbCellRequest fsshttpRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
            AllocateExtendedGuidRangeCellSubRequest allocateExtendedGuidRange = new AllocateExtendedGuidRangeCellSubRequest(new Compact64bitInt(8000), SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());

            // Make the reserved value equal to 0.
            allocateExtendedGuidRange.Reserved = 0;
            fsshttpRequest.AddSubRequest(allocateExtendedGuidRange, null);
            CellSubRequestType  cellSubRequest  = SharedTestSuiteHelper.CreateCellSubRequest((ulong)SequenceNumberGenerator.GetCurrentToken(), fsshttpRequest.ToBase64());
            CellStorageResponse response        = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { cellSubRequest });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "Test case cannot continue unless the allocate extended guid range operation on the file {0} succeed.",
                this.DefaultFileUrl);

            FsshttpbResponse fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site);

            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponse, this.Site);

            FsshttpbCellRequest fsshttpRequestSecond = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
            AllocateExtendedGuidRangeCellSubRequest allocateExtendedGuidRangeSecond = new AllocateExtendedGuidRangeCellSubRequest(new Compact64bitInt(8000), SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());

            // Make the reserved value equal to 1.
            allocateExtendedGuidRangeSecond.Reserved = 1;
            fsshttpRequestSecond.AddSubRequest(allocateExtendedGuidRangeSecond, null);
            CellSubRequestType  cellSubRequestSecond  = SharedTestSuiteHelper.CreateCellSubRequest((ulong)SequenceNumberGenerator.GetCurrentToken(), fsshttpRequestSecond.ToBase64());
            CellStorageResponse responseSecond        = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { cellSubRequestSecond });
            CellSubResponseType cellSubResponseSecond = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(responseSecond, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponseSecond.ErrorCode, this.Site),
                "Test case cannot continue unless the allocate extended guid range operation on the file {0} succeed.",
                this.DefaultFileUrl);

            FsshttpbResponse fsshttpbResponseSecond = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponseSecond, this.Site);

            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponseSecond, this.Site);

            // Compare this two responses roughly, and if these two responses are identical in main part, then capture the requirement MS-FSSHTTPB_R2189
            bool isVerifyR2189 = SharedTestSuiteHelper.ComapreSucceedFsshttpAllocateExtendedGuidRangeResposne(fsshttpbResponse, fsshttpbResponseSecond, this.Site);

            this.Site.Log.Add(TestTools.LogEntryKind.Debug, "Expect the two allocate extended GUID range responses are same, actual {0}", isVerifyR2189);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTPB requirement: MS-FSSHTTPB_R2189
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR2189,
                    "MS-FSSHTTPB",
                    2189,
                    @"[In Allocate Extended GUID Range] A - Reserved (8 bits): Whenever A - Reserved is set to one or zero, the protocol server must return the same response.");
            }
            else
            {
                Site.Assert.IsTrue(
                    isVerifyR2189,
                    @"[In Allocate Extended GUID Range] A - Reserved (8 bits): Whenever A - Reserved is set to one or zero, the protocol server must return the same response.");
            }
        }
Beispiel #13
0
        public void TestCase_S10_TC05_DependencyTypeOnSuccessOrNotSupported_OnSuccess()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);

            // Update the file contents when the coalesce is true.
            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10)));

            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            // Make a putChanges subRequest dependent on the exclusive lock and the dependency type is success.
            putChange.DependencyTypeSpecified = true;
            putChange.DependencyType          = DependencyTypes.OnSuccessOrNotSupported;
            putChange.DependsOn = exclusiveLocksubRequest.SubRequestToken;

            CellStorageResponse response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest, putChange });

            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);
            CellSubResponseType          putChanges        = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 1, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site), "Test case cannot continue unless the get lock sub request succeeds.");
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, exclusiveLocksubRequest.SubRequestData.ExclusiveLockID);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site), "Test case cannot continue unless the put changes sub request succeeds.");

            // Make another GetLock request with a different exclusive lock ID.
            exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);
            exclusiveLocksubRequest.SubRequestData.ExclusiveLockID = System.Guid.NewGuid().ToString();

            // Also make another putChange request dependent on the new GetLock request.
            putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10)));
            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            // Make a putChanges subRequest dependent on the exclusive lock and the dependency type is success.
            putChange.DependencyTypeSpecified = true;
            putChange.DependencyType          = DependencyTypes.OnSuccessOrNotSupported;
            putChange.DependsOn = exclusiveLocksubRequest.SubRequestToken;

            response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest, putChange });

            exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);
            putChanges        = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 1, this.Site);

            this.Site.Assert.AreNotEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site), "Test case cannot continue unless the get lock sub request fails.");

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the first putChanges request succeed and the second putChanges request fails, then capture requirement R336 and R32201.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnSuccessRequestFailed,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    336,
                    @"[In DependencyTypes] OnSuccessOrNotSupported: Indicates that the subrequest MUST be processed only when one of the following conditions is true:
                         On the successful execution of the other subrequest.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R32201
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnSuccessRequestFailed,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    32201,
                    @"[In DependencyCheckRelatedErrorCodeTypes] DependentOnlyOnSuccessRequestFailed: Indicates an error when the subrequest on which this specific subrequest is dependent has failed and the DependencyType attribute in this subrequest is set to [""OnSuccess""] or ""OnSuccessOrNotSupported"".");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnSuccessRequestFailed,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    @"[In DependencyTypes] OnSuccessOrNotSupported: Indicates that the subrequest MUST be processed only when one of the following conditions is true:
                    On the successful execution of the other subrequest.");
            }
        }
        public void TestCase_S15_TC01_CreateFile()
        {
            string randomFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

            // Initialize the context using user01 and defaultFileUrl.
            this.InitializeContext(randomFileUrl, this.UserName01, this.Password01, this.Domain);

            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), SharedTestSuiteHelper.GenerateRandomFileContent(this.Site));

            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            CellStorageResponse response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "When uploading contents if the protocol server was unable to find the URL for the file specified in the Url attribute,, the server returns success and create a new file using the specified contents in the file URI.");

            // Query the updated file content.
            CellSubRequestType queryChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());

            response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { queryChange });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3103
                // If queryChange subrequest can download a file from randomFileUrl, then capture MS-FSSHTTP_R3103.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    3103,
                    @"[In Cell Subrequest] But for Put Changes subrequest, as described in [MS-FSSHTTPB] section 2.2.2.1.4, [If the protocol server was unable to find the URL for the file specified in the Url attribute] the protocol server creates a new file using the specified Url.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    @"[In Cell Subrequest] But for Put Changes subrequest, as described in [MS-FSSHTTPB] section 2.2.2.1.4, [If the protocol server was unable to find the URL for the file specified in the Url attribute] the protocol server creates a new file using the specified Url.");
            }

            this.StatusManager.RecordFileUpload(randomFileUrl);

            // Re-generate the non-exist file URL again.
            randomFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);
            this.InitializeContext(randomFileUrl, this.UserName01, this.Password01, this.Domain);

            putChange.SubRequestData.ExpectNoFileExistsSpecified = true;
            putChange.SubRequestData.ExpectNoFileExists          = true;
            putChange.SubRequestData.Etag = string.Empty;
            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;
            response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2252
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    2252,
                    @"[In Cell Subrequest] In this case[If the ExpectNoFileExists attribute is set to true in a file content upload cell subrequest, the Etag attribute MUST be an empty string], the protocol server MUST NOT cause the cell subrequest to fail with a coherency error if the file does not exist on the server.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    @"[In Cell Subrequest] In this case[If the ExpectNoFileExists attribute is set to true in a file content upload cell subrequest, the Etag attribute MUST be an empty string], the protocol server MUST NOT cause the cell subrequest to fail with a coherency error if the file does not exist on the server.");
            }

            this.StatusManager.RecordFileUpload(randomFileUrl);
        }
        public void TestCase_S15_TC04_UploadContents_ExclusiveLockSuccess()
        {
            string randomFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

            // Initialize the context using user01 and defaultFileUrl.
            this.InitializeContext(randomFileUrl, this.UserName01, this.Password01, this.Domain);

            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), SharedTestSuiteHelper.GenerateRandomFileContent(this.Site));

            putChange.SubRequestData.CoalesceSpecified           = true;
            putChange.SubRequestData.Coalesce                    = true;
            putChange.SubRequestData.ExpectNoFileExistsSpecified = true;
            putChange.SubRequestData.ExpectNoFileExists          = true;
            putChange.SubRequestData.ExclusiveLockID             = SharedTestSuiteHelper.DefaultExclusiveLockID;
            putChange.SubRequestData.BypassLockID                = putChange.SubRequestData.ExclusiveLockID;
            putChange.SubRequestData.Timeout = "3600";

            CellStorageResponse response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "When the file is locked by exclusive lock and the ByPassLockID is specified by the valid exclusive lock id, the server returns the error code success.");

            this.StatusManager.RecordExclusiveLock(randomFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID, this.UserName01, this.Password01, this.Domain);
            this.StatusManager.RecordFileUpload(randomFileUrl);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the server responds with the error code "Success",
                // when the above steps show that the client has got an exclusive lock and the PutChange subrequest was sent with BypassLockID equal to ExclusiveLockID,
                // then requirement MS-FSSHTTP_R833 is captured.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    833,
                    @"[In CellSubRequestDataOptionalAttributes][BypassLockID] If a client has got an exclusive lock, this value[BypassLockID] MUST be the same as the value of ExclusiveLockID, as specified in section 2.3.1.1.");

                // If the server responds with "ExclusiveLock" in LockType attribute, the requirement MS-FSSHTTP_R1533 is captured.
                Site.CaptureRequirementIfAreEqual <string>(
                    "ExclusiveLock",
                    cellSubResponse.SubResponseData.LockType.ToString(),
                    "MS-FSSHTTP",
                    1533,
                    @"[In CellSubResponseDataType] The LockType attribute MUST be set to ""ExclusiveLock"" in the cell subresponse if the ExclusiveLockID attribute is sent in the cell subrequest and the protocol server is successfully able to take an exclusive lock.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    @"[In CellSubRequestDataOptionalAttributes][BypassLockID] If a client has got an exclusive lock, this value[BypassLockID] MUST be the same as the value of ExclusiveLockID, as specified in section 2.3.1.1.");

                Site.Assert.AreEqual <string>(
                    "ExclusiveLock",
                    cellSubResponse.SubResponseData.LockType.ToString(),
                    @"[In CellSubResponseDataType] The LockType attribute MUST be set to ""ExclusiveLock"" in the cell subresponse if the ExclusiveLockID attribute is sent in the cell subrequest and the protocol server is successfully able to take an exclusive lock.");
            }

            // Update contents without the ByPassLockID and coalesce true.
            putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), SharedTestSuiteHelper.GenerateRandomFileContent(this.Site));
            putChange.SubRequestData.BypassLockID      = null;
            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "When the file is locked by exclusive lock and the ByPassLockID is not specified, the server returns the error code success.");
        }
Beispiel #16
0
        public void MSFSSHTTP_FSSHTTPB_S01_TC01_DownloadContents_EmptyUrl()
        {
            if ((!Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site)) &&
                (!Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site)))
            {
                Site.Assume.Inconclusive("Implementation does not have same behaviors as Microsoft products.");
            }

            // Initialize the context using user01 and defaultFileUrl.
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            CellStorageResponse response = new CellStorageResponse();
            bool isR3008Verified         = false;

            try
            {
                // Query the updated file content.
                CellSubRequestType queryChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());
                response = Adapter.CellStorageRequest(string.Empty, new SubRequestType[] { queryChange });
            }
            catch (System.Xml.XmlException exception)
            {
                string message = exception.Message;
                isR3008Verified  = message.Contains("Duplicate attribute");
                isR3008Verified &= message.Contains("ErrorCode");
            }

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3008
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site))
                {
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is empty.");

                    Site.CaptureRequirementIfIsTrue(
                        isR3008Verified,
                        "MS-FSSHTTP",
                        3008,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does return two ErrorCode attributes in Response element. <11> Section 2.2.3.5:  SharePoint Server 2010 will return 2 ErrorCode attributes in Response element.");
                }

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3009
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site))
                {
                    Site.CaptureRequirementIfIsNull(
                        response.ResponseCollection,
                        "MS-FSSHTTP",
                        3009,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does not return Response element. <11> Section 2.2.3.5:  SharePoint Server 2013 will not return Response element.");
                }
            }
            else
            {
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site))
                {
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists.");

                    Site.Assert.IsTrue(
                        isR3008Verified,
                        "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists.");
                }

                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site))
                {
                    Site.Assert.IsNull(
                        response.ResponseCollection,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does not return Response element. <8> Section 2.2.3.5:  SharePoint Server 2013 will not return Response element.");
                }
            }
        }
        public void TestCase_S09_TC05_GetVersions_Success_Results_VersionData()
        {
            string documentLibraryName = Common.GetConfigurationPropertyValue("MSFSSHTTPFSSHTTPBLibraryName", this.Site);

            if (!SutPowerShellAdapter.SwitchMajorVersioning(documentLibraryName, true))
            {
                this.Site.Assert.Fail("Cannot disable the version on the document library {0}", documentLibraryName);
            }

            // Prepare a file.
            string fileUrl = this.PrepareFile();

            // Initialize the context
            this.InitializeContext(fileUrl, this.UserName01, this.Password01, this.Domain);

            // Check out one file by a specified user name.
            if (!this.SutPowerShellAdapter.CheckOutFile(fileUrl, this.UserName01, this.Password01, this.Domain))
            {
                this.Site.Assert.Fail("Cannot change the file {0} to check out status using the user name {1} and password {2}", fileUrl, this.UserName01, this.Password01);
            }

            this.StatusManager.RecordFileCheckOut(fileUrl, this.UserName01, this.Password01, this.Domain);

            string checkInComments1 = "New Comment1 for testing purpose on the operation GetVersions.";

            if (!SutPowerShellAdapter.CheckInFile(fileUrl, this.UserName01, this.Password01, this.Domain, checkInComments1))
            {
                this.Site.Assert.Fail("Cannot change the file {0} to check in status using the user name {1} and password {2}", fileUrl, this.UserName01, this.Password01);
            }

            this.StatusManager.CancelRecordCheckOut(fileUrl);

            // Check out one file by a specified user name again.
            if (!this.SutPowerShellAdapter.CheckOutFile(fileUrl, this.UserName02, this.Password02, this.Domain))
            {
                this.Site.Assert.Fail("Cannot change the file {0} to check out status using the user name {1} and password {2}", fileUrl, this.UserName02, this.Password02);
            }

            this.StatusManager.RecordFileCheckOut(fileUrl, this.UserName02, this.Password02, this.Domain);

            string checkInComments2 = "New Comment2 for testing purpose on the operation GetVersions.";

            if (!SutPowerShellAdapter.CheckInFile(fileUrl, this.UserName02, this.Password02, this.Domain, checkInComments2))
            {
                this.Site.Assert.Fail("Cannot change the file {0} to check in status using the user name {1} and password {2}", fileUrl, this.UserName02, this.Password02);
            }

            this.StatusManager.CancelRecordCheckOut(fileUrl);

            // Query changes from the protocol server
            CellSubRequestType  queryChange      = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());
            CellStorageResponse queryResponse    = Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { queryChange });
            CellSubResponseType querySubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(queryResponse, 0, 0, this.Site);

            this.Site.Assert.AreEqual(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(querySubResponse.ErrorCode, this.Site), "The operation QueryChanges should succeed.");
            FsshttpbResponse fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(querySubResponse, this.Site);

            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponse, this.Site);
            int contentLength = new RootNodeObject.RootNodeObjectBuilder().Build(
                fsshttpbResponse.DataElementPackage.DataElements,
                fsshttpbResponse.CellSubResponses[0].GetSubResponseData <QueryChangesSubResponseData>().StorageIndexExtendedGUID).GetContent().Count;

            // Invoke "GetVersions" sub-request with the test file URL that under a document list which is enable versioning.
            GetVersionsSubRequestType  getVersionsSubRequest  = SharedTestSuiteHelper.CreateGetVersionsSubRequest(SequenceNumberGenerator.GetCurrentToken());
            CellStorageResponse        cellStoreageResponse   = Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { getVersionsSubRequest });
            GetVersionsSubResponseType getVersionsSubResponse = SharedTestSuiteHelper.ExtractSubResponse <GetVersionsSubResponseType>(cellStoreageResponse, 0, 0, this.Site);

            this.Site.Assert.IsNotNull(getVersionsSubResponse, "The object 'getVersionsSubResponse' should not be null.");
            this.Site.Assert.IsNotNull(getVersionsSubResponse.ErrorCode, "The object 'getVersionsSubResponse.ErrorCode' should not be null.");

            // Make sure the error code value in the response equals "Success"
            Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(getVersionsSubResponse.ErrorCode, this.Site),
                @"The response of the ""getVersions"" sub-request on the file {0} should succeed.",
                this.DefaultFileUrl);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the result contains 3 versions (1.the original, 2. User01 checked in, 3 User02 checked in), then the MS-FSSHTTP requirement: MS-FSSHTTP_R2307 is verified.
                Site.CaptureRequirementIfAreEqual <int>(
                    3,
                    getVersionsSubResponse.GetVersionsResponse.GetVersionsResult.results.result.Length,
                    "MS-FSSHTTP",
                    2307,
                    @"[In GetVersionsSubResponseType][Results complex type] result: A separate result element MUST exist for each version of the file that the user can access.");

                // If the result contains 3 versions (1.the original, 2. User01 checked in, 3 User02 checked in), then the MS-FSSHTTP requirement: MS-FSSHTTP_R30841 is verified.
                Site.CaptureRequirementIfAreEqual <int>(
                    3,
                    getVersionsSubResponse.GetVersionsResponse.GetVersionsResult.results.result.Length,
                    "MS-FSSHTTP",
                    30841,
                    @"[In GetVersionsResponse] GetVersionsResult: An XML node that contains the details about all the versions of the specified file that the user can access.");
            }
            else
            {
                Site.Assert.AreEqual <int>(
                    3,
                    getVersionsSubResponse.GetVersionsResponse.GetVersionsResult.results.result.Length,
                    @"[In GetVersionsSubResponseType][Results complex type] result: A separate result element MUST exist for each version of the file that the user can access.");
            }

            bool isFindVersion    = false;
            bool isNotStartWithAt = false;

            foreach (VersionData item in getVersionsSubResponse.GetVersionsResponse.GetVersionsResult.results.result)
            {
                if (string.Compare(checkInComments2, item.comments, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    bool isCreatedBy = item.createdBy != null && item.createdBy.IndexOf(this.UserName02, System.StringComparison.OrdinalIgnoreCase) >= 0;
                    this.Site.Log.Add(
                        LogEntryKind.Debug,
                        "For requirement MS-FSSHTTP_R2312, expect the CreatedBy contains the user name {0}, the actual value is {1}",
                        this.UserName02,
                        item.createdBy);

                    if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                    {
                        // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2312
                        Site.CaptureRequirementIfIsTrue(
                            isCreatedBy,
                            "MS-FSSHTTP",
                            2312,
                            @"[In GetVersionsSubResponseType][VersionData complex type] createdBy: The creator of the version of the file.");

                        bool isCreatedByName = item.createdByName != null && item.createdByName.IndexOf(this.UserName02, System.StringComparison.OrdinalIgnoreCase) >= 0;
                        this.Site.Log.Add(
                            LogEntryKind.Debug,
                            "For requirement MS-FSSHTTP_R2313, expect the createdByName contains the user name {0}, the actual value is {1}",
                            this.UserName02,
                            item.createdByName);

                        // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2313
                        Site.CaptureRequirementIfIsTrue(
                            isCreatedByName,
                            "MS-FSSHTTP",
                            2313,
                            @"[In GetVersionsSubResponseType][VersionData complex type] createdByName: The display name of the creator of the version of the file.");

                        bool isVersion = item.version != null && item.version.StartsWith("@", StringComparison.OrdinalIgnoreCase);
                        this.Site.Log.Add(
                            LogEntryKind.Debug,
                            "For requirement MS-FSSHTTP_R2309, expect the version start with @, the actual value is {0}",
                            item.version);

                        // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2309
                        Site.CaptureRequirementIfIsTrue(
                            isVersion,
                            "MS-FSSHTTP",
                            2309,
                            @"[In GetVersionsSubResponseType][VersionData complex type] version: The most recent version of the file MUST be preceded with an at sign (@).");

                        // Using UNICODE, so the actual file size will double the length 5.
                        Site.CaptureRequirementIfAreEqual <ulong>(
                            (ulong)contentLength,
                            item.size,
                            "MS-FSSHTTP",
                            2314,
                            @"[In GetVersionsSubResponseType][VersionData complex type] size: The size, in bytes, of the version of the file.");

                        // If go through here, then the requirement MS-FSSHTTP_R2315 can be directly captured.
                        Site.CaptureRequirement(
                            "MS-FSSHTTP",
                            2315,
                            @"[In GetVersionsSubResponseType][VersionData complex type] comments: The comment entered when the version of the file was replaced on the protocol server during check in.");
                    }
                    else
                    {
                        Site.Assert.IsTrue(
                            isCreatedBy,
                            @"[In GetVersionsSubResponseType][VersionData complex type] createdBy: The creator of the version of the file.");

                        Site.Assert.IsNotNull(
                            item.createdRaw,
                            @"[In GetVersionsSubResponseType] Implementation does return this attribute[createdRaw]. [In VersionData] createdRaw: The creation date and time for the version of the file in DateTime format, as specified in [ISO-8601]. (Microsoft SharePoint Foundation 2010 and above follow this behavior.)");

                        bool isCreatedByName = item.createdByName != null && item.createdByName.IndexOf(this.UserName02, System.StringComparison.OrdinalIgnoreCase) >= 0;
                        Site.Assert.IsTrue(
                            isCreatedByName,
                            @"[In GetVersionsSubResponseType][VersionData complex type] createdByName: The display name of the creator of the version of the file.");

                        bool isVersion = item.version != null && item.version.StartsWith("@", StringComparison.OrdinalIgnoreCase);
                        Site.Assert.IsTrue(
                            isVersion,
                            @"[In GetVersionsSubResponseType][VersionData complex type] version: The most recent version of the file MUST be preceded with an at sign (@).");

                        Site.Assert.AreEqual <ulong>(
                            (ulong)contentLength,
                            item.size,
                            @"[In GetVersionsSubResponseType][VersionData complex type] size: The size, in bytes, of the version of the file.");
                    }

                    isFindVersion = true;
                }
                else
                {
                    isNotStartWithAt = !item.version.StartsWith("@", StringComparison.OrdinalIgnoreCase);
                }
            }

            if (!isFindVersion)
            {
                this.Site.Assert.Fail("Cannot find the Version record for the comment {0}", checkInComments2);
            }

            Site.Log.Add(
                LogEntryKind.Debug,
                "All the other versions MUST exist without any prefix, and actually they {0} have prefix.",
                isNotStartWithAt ? "do not" : "do");

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2310
                Site.CaptureRequirementIfIsTrue(
                    isNotStartWithAt,
                    "MS-FSSHTTP",
                    2310,
                    @"[In GetVersionsSubResponseType][VersionData complex type] version: All the other versions MUST exist without any prefix. ");
            }
            else
            {
                Site.Assert.IsTrue(
                    isNotStartWithAt,
                    @"[In GetVersionsSubResponseType][VersionData complex type] version: All the other versions MUST exist without any prefix. ");
            }
        }
Beispiel #18
0
        public void MSONESTORE_S01_TC03_QueryOneFileWithoutFileData()
        {
            // Get the resource url that contains the file data.
            string resourceName = Common.GetConfigurationPropertyValue("OneFileWithoutFileData", Site);
            string url          = this.GetResourceUrl(resourceName);

            this.InitializeContext(url, this.UserName, this.Password, this.Domain);

            // Call QueryChange to get the data that is specified by above step.
            CellSubRequestType  cellSubRequest      = this.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentSerialNumber());
            CellStorageResponse cellStorageResponse = this.SharedAdapter.CellStorageRequest(url, new SubRequestType[] { cellSubRequest });
            MSOneStorePackage   package             = this.ConvertOneStorePackage(cellStorageResponse);

            // Call adapter to load same file in local.
            OneNoteRevisionStoreFile file = this.Adapter.LoadOneNoteFile(resourceName);

            #region Capture code for Header Cell
            for (int i = 0; i < package.HeaderCell.ObjectData.Body.RgPrids.Length; i++)
            {
                PropertyID propId = package.HeaderCell.ObjectData.Body.RgPrids[i];
                if (propId.Value == 0x14001D93)
                {
                    FourBytesOfData crcData = package.HeaderCell.ObjectData.Body.RgData[i] as FourBytesOfData;

                    // Verify MS-ONESTORE requirement: MS-ONESTORE_R917
                    Site.CaptureRequirementIfAreEqual <uint>(
                        file.Header.crcName,
                        BitConverter.ToUInt32(crcData.Data, 0),
                        917,
                        @"[In Header Cell] FileNameCRC's PropertyID 0x14001D93 with value: MUST be the Header.crcName field.");
                }
                else if (propId.Value == 0x1C001D94)
                {
                    PrtFourBytesOfLengthFollowedByData guidFileData = package.HeaderCell.ObjectData.Body.RgData[i] as PrtFourBytesOfLengthFollowedByData;

                    // Verify MS-ONESTORE requirement: MS-ONESTORE_R912
                    Site.CaptureRequirementIfAreEqual <Guid>(
                        file.Header.guidFile,
                        new Guid(guidFileData.Data),
                        912,
                        @"[In Header Cell] [FileIdentityGuid] MUST be the value specified by the Header.guidFile field.");
                }
                else if (propId.Value == 0x1C001D95)
                {
                    PrtFourBytesOfLengthFollowedByData guidAncestorData = package.HeaderCell.ObjectData.Body.RgData[i] as PrtFourBytesOfLengthFollowedByData;

                    // Verify MS-ONESTORE requirement: MS-ONESTORE_R914
                    Site.CaptureRequirementIfAreEqual <Guid>(
                        file.Header.guidAncestor,
                        new Guid(guidAncestorData.Data),
                        914,
                        @"[In Header Cell] [FileAncestorIdentityGuid] MUST be the value specified by the Header.guidAncestor field.");
                }
            }
            #endregion

            #region Capture code for Revision
            List <RevisionManifest> revisionManifestList = new List <RevisionManifest>();

            foreach (ObjectSpaceManifestList objSpaceManifestList in file.RootFileNodeList.ObjectSpaceManifestList)
            {
                foreach (RevisionManifestList revManifestList in objSpaceManifestList.RevisionManifestList)
                {
                    revisionManifestList.AddRange(revManifestList.RevisionManifests);
                }
            }

            foreach (RevisionManifestDataElementData revisionManifestData in package.RevisionManifests)
            {
                ExGuid revisionId     = revisionManifestData.RevisionManifest.RevisionID;
                ExGuid baseRevisionId = revisionManifestData.RevisionManifest.BaseRevisionID;

                ExtendedGUID rid          = null;
                ExtendedGUID ridDependent = null;
                bool         isFound      = false;
                for (int i = 0; i < revisionManifestList.Count; i++)
                {
                    FileNode revisionStart = revisionManifestList[i].FileNodeSequence[0];
                    if (revisionStart.FileNodeID == FileNodeIDValues.RevisionManifestStart6FND)
                    {
                        rid          = ((RevisionManifestStart6FND)revisionStart.fnd).rid;
                        ridDependent = ((RevisionManifestStart6FND)revisionStart.fnd).ridDependent;
                    }
                    else if (revisionStart.FileNodeID == FileNodeIDValues.RevisionManifestStart7FND)
                    {
                        rid          = ((RevisionManifestStart7FND)revisionStart.fnd).Base.rid;
                        ridDependent = ((RevisionManifestStart7FND)revisionStart.fnd).Base.ridDependent;
                    }

                    if (rid.Guid == revisionId.GUID && rid.N == revisionId.Value)
                    {
                        isFound = true;
                        break;
                    }
                }

                // Verify MS-ONESTORE requirement: MS-ONESTORE_R925
                Site.CaptureRequirementIfIsTrue(
                    isFound,
                    925,
                    @"[In Revisions] § Revision ID: MUST be equal to the revision store file revision identifier (section 2.1.8).");

                // Verify MS-ONESTORE requirement: MS-ONESTORE_R926
                Site.CaptureRequirementIfIsTrue(
                    baseRevisionId.GUID == ridDependent.Guid && baseRevisionId.Value == ridDependent.N,
                    926,
                    @"[In Revisions] § Base Revision ID: MUST be equal to the revision store file dependency revision identifier (section 2.1.9).");

                ExGuid objectGroupId      = revisionManifestData.RevisionManifestObjectGroupReferencesList[0].ObjectGroupExtendedGUID;
                bool   isFoundObjectGroup = false;

                isFoundObjectGroup = package.DataRoot.Where(o => o.ObjectGroupID == objectGroupId).ToArray().Length > 0 ||
                                     package.OtherFileNodeList.Where(o => o.ObjectGroupID == objectGroupId).ToArray().Length > 0;

                // Verify MS-ONESTORE requirement: MS-ONESTORE_R935
                Site.CaptureRequirementIfIsTrue(
                    isFoundObjectGroup,
                    935,
                    @"[In Object Groups] The Revision Manifest Data Element structure, as specified in [MS-FSSHTTPB] section 2.2.1.12.5, that references an object group MUST specify the object group extended GUID to be equal to the revision store object group identifier.");
            }
            #endregion
        }
Beispiel #19
0
        public void TestCase_S14_TC01_AllocateExtendedGuidRange_Success()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Allocate Extended GUID Range
            Compact64bitInt     requestIdCount  = new Compact64bitInt(8000);
            CellSubRequestType  allocateRequest = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedAllocateExtendedGuidRange((int)SequenceNumberGenerator.GetCurrentToken(), SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), requestIdCount);
            CellStorageResponse response        = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { allocateRequest });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "Test case cannot continue unless the allocate extended guid range operation on the file {0} succeed.",
                this.DefaultFileUrl);

            FsshttpbResponse fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site);

            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponse, this.Site);

            // Extract the Allocate ExtendedGuid Range sub-response info
            this.Site.Assert.IsTrue(fsshttpbResponse.CellSubResponses.Count > 0, "The protocol server should return SubResponse for Allocate ExtendedGuid Range sub-request processing.");
            this.Site.Assert.IsNotNull(fsshttpbResponse.CellSubResponses[0].GetSubResponseData <AllocateExtendedGuidRangeSubResponseData>(), "The protocol server should return SubResponseData for Allocate ExtendedGuid Range sub-request processing.");

            AllocateExtendedGuidRangeSubResponseData allocateResponse = fsshttpbResponse.CellSubResponses[0].GetSubResponseData <AllocateExtendedGuidRangeSubResponseData>();

            // Assert for elements in Allocate Extended Guid Range sub-response
            this.Site.Assert.IsNotNull(allocateResponse.AllocateExtendedGUIDRangeResponse, "The protocol server should return Allocate Extended GUID Range Response.");
            this.Site.Assert.IsNotNull(allocateResponse.GUIDComponent, "The protocol server should allocate ExtendedGuids as requested.");
            this.Site.Assert.IsNotNull(allocateResponse.IntegerRangeMin, "The protocol server should return an integer Range Min in the sub-response.");
            this.Site.Assert.IsNotNull(allocateResponse.IntegerRangeMax, "The protocol server should return an integer Range Max in the sub-response.");

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTPB requirement: MS-FSSHTTPB_R9005
                Site.CaptureRequirement(
                    "MS-FSSHTTPB",
                    99099,
                    @"[In Appendix B: Product Behavior] The implementation does support this sub-request [Allocate ExtendedGuid Range Sub-Request]( SharePoint Server 2013 and above follow this behavior.)");
            }

            // Allocate Extended GUID Range value less than 1000.
            requestIdCount  = new Compact64bitInt(100);
            allocateRequest = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedAllocateExtendedGuidRange((int)SequenceNumberGenerator.GetCurrentToken(), SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), requestIdCount);
            response        = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { allocateRequest });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);
            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "Test case cannot continue unless the allocate extended guid range operation on the file {0} succeed.",
                this.DefaultFileUrl);

            // Allocate Extended GUID Range value less than 100000.
            requestIdCount  = new Compact64bitInt(150000);
            allocateRequest = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedAllocateExtendedGuidRange((int)SequenceNumberGenerator.GetCurrentToken(), SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), requestIdCount);
            response        = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { allocateRequest });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);
            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "Test case cannot continue unless the allocate extended guid range operation on the file {0} succeed.",
                this.DefaultFileUrl);
        }
Beispiel #20
0
        public void MSONESTORE_S01_TC04_QueryOneFileWithLargeReferences()
        {
            // Get the resource url that contains the file data.
            string resourceName = Common.GetConfigurationPropertyValue("OneWithLarge", Site);
            string url          = this.GetResourceUrl(resourceName);

            this.InitializeContext(url, this.UserName, this.Password, this.Domain);

            // Call QueryChange to get the data that is specified by above step.
            CellSubRequestType  cellSubRequest      = this.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentSerialNumber());
            CellStorageResponse cellStorageResponse = this.SharedAdapter.CellStorageRequest(url, new SubRequestType[] { cellSubRequest });
            MSOneStorePackage   package             = this.ConvertOneStorePackage(cellStorageResponse);

            // Call adapter to load same file in local.
            OneNoteRevisionStoreFile file      = this.Adapter.LoadOneNoteFile(resourceName);
            int             objectSpaceCount   = file.RootFileNodeList.ObjectSpaceManifestList.Count;
            List <FileNode> fileData3LargeRefs = new List <FileNode>();

            for (int i = 0; i < file.RootFileNodeList.ObjectSpaceManifestList.Count; i++)
            {
                ObjectSpaceManifestList objectSpace = file.RootFileNodeList.ObjectSpaceManifestList[i];
                for (int j = 0; j < objectSpace.RevisionManifestList[0].ObjectGroupList.Count; j++)
                {
                    ObjectGroupList objectGroupList = objectSpace.RevisionManifestList[0].ObjectGroupList[j];
                    fileData3LargeRefs.AddRange(objectGroupList.FileNodeSequence.Where(f => f.FileNodeID == FileNodeIDValues.ObjectDeclarationFileData3LargeRefCountFND).ToArray());
                }
            }

            List <RevisionStoreObject> objectsWithFileData = new List <RevisionStoreObject>();

            foreach (RevisionStoreObjectGroup objGroup in package.DataRoot)
            {
                objectsWithFileData.AddRange(objGroup.Objects.Where(o => o.FileDataObject != null).ToArray());
            }
            foreach (RevisionStoreObjectGroup objGroup in package.OtherFileNodeList)
            {
                objectsWithFileData.AddRange(objGroup.Objects.Where(o => o.FileDataObject != null).ToArray());
            }
            foreach (RevisionStoreObject obj in objectsWithFileData)
            {
                Guid   fileDataObjectGuid = this.GetFileDataObjectGUID(obj);
                string extension          = this.GetFileDataObjectExtension(obj);

                if (extension.ToLower().Contains("xps"))
                {
                    foreach (FileNode fnode in fileData3LargeRefs)
                    {
                        ObjectDeclarationFileData3LargeRefCountFND fnd = fnode.fnd as ObjectDeclarationFileData3LargeRefCountFND;
                        if (fnd.FileDataReference.StringData.ToLower().Contains(fileDataObjectGuid.ToString().ToLower()))
                        {
                            // Verify MS-ONESTORE requirement: MS-ONESTORE_R952
                            Site.CaptureRequirementIfIsTrue(
                                fnd.FileDataReference.StringData.StartsWith("<invfdo>") == false,
                                952,
                                @"[In Objects] This property MUST be set only if the prefix specified by the [ObjectDeclarationFileData3RefCountFND.FileDataReference field (section 2.5.27) or] ObjectDeclarationFileData3LargeRefCountFND.FileDataReference field (section 2.5.28) is not <invfdo>.");

                            // Verify MS-ONESTORE requirement: MS-ONESTORE_R959
                            Site.CaptureRequirementIfAreEqual <string>(
                                fnd.Extension.StringData,
                                extension,
                                959,
                                @"[In Objects] MUST be the value specified by the [ObjectDeclarationFileData3RefCountFND.Extension field or] the ObjectDeclarationFileData3LargeRefCountFND.Extension field.");

                            break;
                        }
                    }
                }
            }
        }
        public void TestCase_S11_TC01_QueryAccessReadWrite()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Query changes from the protocol server
            CellSubRequestType  queryChange      = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());
            CellStorageResponse queryResponse    = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { queryChange });
            CellSubResponseType querySubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(queryResponse, 0, 0, this.Site);

            this.Site.Assert.AreEqual(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(querySubResponse.ErrorCode, this.Site), "The operation QueryChanges should succeed.");
            FsshttpbResponse fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(querySubResponse, this.Site);
            ExGuid           storageIndex     = fsshttpbResponse.CellSubResponses[0].GetSubResponseData <QueryChangesSubResponseData>().StorageIndexExtendedGUID;

            // Create a putChanges cellSubRequest
            FsshttpbCellRequest cellRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
            ExGuid                   storageIndexExGuid;
            List <DataElement>       dataElements = DataElementUtils.BuildDataElements(System.Text.Encoding.Unicode.GetBytes("bad"), out storageIndexExGuid);
            PutChangesCellSubRequest putChange    = new PutChangesCellSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), storageIndexExGuid);

            putChange.ExpectedStorageIndexExtendedGUID = storageIndex;
            dataElements.AddRange(fsshttpbResponse.DataElementPackage.DataElements);
            cellRequest.AddSubRequest(putChange, dataElements);
            CellSubRequestType putChangesSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64());

            // Put changes to the protocol server
            CellStorageResponse response        = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { putChangesSubRequest });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            // Expect the Put changes operation succeeds
            this.Site.Assert.AreEqual(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site), "The PutChanges operation should succeed.");
            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site), this.Site);

            // Call QueryAccess.
            CellSubRequestType  cellSubRequest      = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryAccess(0);
            CellStorageResponse cellStorageResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { cellSubRequest });
            CellSubResponseType subResponse         = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(cellStorageResponse, 0, 0, this.Site);
            FsshttpbResponse    queryAccessResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(subResponse, this.Site);

            // Get readAccessResponse and writeAccessResponse Data.
            HRESULTError dataRead = queryAccessResponse.CellSubResponses[0]
                                    .GetSubResponseData <QueryAccessSubResponseData>()
                                    .ReadAccessResponse.ReadResponseError
                                    .GetErrorData <HRESULTError>();

            this.Site.Assert.AreEqual <int>(
                0,
                dataRead.ErrorCode,
                "Test case cannot continue unless the read HRESULTError code equals 0 when the user have read/write permission.");

            HRESULTError dataWrite = queryAccessResponse.CellSubResponses[0]
                                     .GetSubResponseData <QueryAccessSubResponseData>()
                                     .WriteAccessResponse.WriteResponseError
                                     .GetErrorData <HRESULTError>();

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error type is HRESULTError, then capture R946.
                Site.CaptureRequirementIfIsNotNull(
                    dataWrite,
                    "MS-FSSHTTPB",
                    946,
                    @"[In Query Access] Response Error (variable): If the Put Changes operation will succeed, the response error will have an error type of HRESULT error.");

                // If the error type is HRESULTError and error code equals 0, then capture R2229.
                Site.CaptureRequirementIfAreEqual <int>(
                    0,
                    dataWrite.ErrorCode,
                    "MS-FSSHTTPB",
                    2229,
                    @"[In Query Access] Response Error (variable): [If the Put Changes operation will succeed, ]the HRESULT error code will be zero.");

                // If error code equals 0, then capture R2231.
                Site.CaptureRequirementIfAreEqual <int>(
                    0,
                    dataWrite.ErrorCode,
                    "MS-FSSHTTPB",
                    2231,
                    @"[In HRESULT Error] Error Code (4 bytes): Zero means that no error occurred.");
            }
            else
            {
                Site.Assert.IsNotNull(
                    dataWrite,
                    @"[In Query Access] Response Error (variable): If the Put Changes operation will succeed, the response error will have an error type of HRESULT error.");

                Site.Assert.AreEqual <int>(
                    0,
                    dataWrite.ErrorCode,
                    @"[In Query Access] Response Error (variable): [If the Put Changes operation will succeed, ]the HRESULT error code will be zero.");
            }
        }
Beispiel #22
0
        public void MSONESTORE_S01_TC05_TestObjectSpaceObjectPropSet()
        {
            // Get the resource url that contains the file data.
            string resourceName = Common.GetConfigurationPropertyValue("OneFileWithoutFileData", Site);
            string url          = this.GetResourceUrl(resourceName);

            this.InitializeContext(url, this.UserName, this.Password, this.Domain);

            // Call QueryChange to get the data that is specified by above step.
            CellSubRequestType  cellSubRequest      = this.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentSerialNumber());
            CellStorageResponse cellStorageResponse = this.SharedAdapter.CellStorageRequest(url, new SubRequestType[] { cellSubRequest });
            MSOneStorePackage   package             = this.ConvertOneStorePackage(cellStorageResponse);

            #region Capture code for ObjectSpaceObjectPropSet
            foreach (RevisionStoreObjectGroup objGroup in package.DataRoot)
            {
                foreach (RevisionStoreObject obj in objGroup.Objects)
                {
                    ObjectSpaceObjectPropSet objectPropSet = obj.PropertySet.ObjectSpaceObjectPropSet;
                    int OIDsLen  = objectPropSet.OIDs.SerializeToByteList().Count;
                    int OSIDsLen = 0;
                    if (objectPropSet.OSIDs != null)
                    {
                        OSIDsLen = objectPropSet.OSIDs.SerializeToByteList().Count;
                    }
                    int contextLen = 0;
                    if (objectPropSet.ContextIDs != null)
                    {
                        contextLen = objectPropSet.ContextIDs.SerializeToByteList().Count;
                    }
                    int bodyLen = 0;
                    if (objectPropSet.Body != null)
                    {
                        bodyLen = objectPropSet.Body.SerializeToByteList().Count;
                    }

                    if ((OIDsLen + OSIDsLen + contextLen + bodyLen) % 8 == 0)
                    {
                        // Verify MS-ONESTORE requirement: MS-ONESTORE_R749
                        Site.CaptureRequirementIfIsNull(
                            objectPropSet.Padding,
                            749,
                            @"[In ObjectSpaceObjectPropSet] If the sum of the sizes of the OIDs, OSIDs, ContextIDs, and body fields is a multiple of 8, then the padding field is not present.");
                    }
                    else
                    {
                        // Verify MS-ONESTORE requirement: MS-ONESTORE_R747
                        Site.CaptureRequirementIfAreEqual <int>(
                            0,
                            (OIDsLen + OSIDsLen + contextLen + bodyLen + objectPropSet.Padding.Length) % 8,
                            747,
                            @"[In ObjectSpaceObjectPropSet] [padding] The total size, in bytes, of an ObjectSpaceObjectPropSet structure MUST be a multiple of 8; the size of the padding field is the number of bytes necessary to ensure the total size of ObjectSpaceObjectPropSet structure is a multiple of 8. ");
                    }
                }
            }

            foreach (RevisionStoreObjectGroup objGoup in package.OtherFileNodeList)
            {
                foreach (RevisionStoreObject obj in objGoup.Objects)
                {
                    ObjectSpaceObjectPropSet objPropSet = obj.PropertySet.ObjectSpaceObjectPropSet;
                    if (objPropSet.OIDs.Header.Count > 0)
                    {
                        int number = this.GetNumberOfSpecificProperty(0x08, 0x09, objPropSet.Body);
                        // Verify MS-ONESTORE requirement: MS-ONESTORE_R730
                        Site.CaptureRequirementIfAreEqual <uint>(
                            objPropSet.OIDs.Header.Count,
                            (uint)number,
                            730,
                            @"[In ObjectSpaceObjectPropSet] [OIDs] The count of referenced objects is calculated as the number of properties specified by the body field, with PropertyID equal to 0x8 plus the number of referenced objects specified by properties with PropertyID equal to 0x9, 0x10, and 0x11. ");
                    }
                    if (objPropSet.OSIDs != null)
                    {
                        int number = this.GetNumberOfSpecificProperty(0x0A, 0x0B, objPropSet.Body);
                        // Verify MS-ONESTORE requirement: MS-ONESTORE_R736
                        Site.CaptureRequirementIfAreEqual <uint>(
                            objPropSet.OSIDs.Header.Count,
                            (uint)number,
                            736,
                            @"[In ObjectSpaceObjectPropSet] [OSIDs] The count of referenced object spaces is calculated as the number of properties specified by the body field with PropertyID equal to 0xA plus the number of referenced object spaces specified by properties with PropertyID equal to 0xB, 0x10, and 0x11.");
                    }
                    if (objPropSet.ContextIDs != null)
                    {
                        int number = this.GetNumberOfSpecificProperty(0x0C, 0x0D, objPropSet.Body);
                        // Verify MS-ONESTORE requirement: MS-ONESTORE_R742
                        Site.CaptureRequirementIfAreEqual <uint>(
                            objPropSet.ContextIDs.Header.Count,
                            (uint)number,
                            742,
                            @"[In ObjectSpaceObjectPropSet] [ContextIDs] The count of referenced contexts is calculated as the number of properties specified by the body field with PropertyID equal to 0xC plus the number of referenced contexts specified by properties with PropertyID equal to 0xD, 0x10, and 0x11.");
                    }
                }
            }
            #endregion
        }