/// <summary> /// Find the specific object group by object group ID. /// </summary> /// <param name="file">The instance of OneNoteRevisionStoreFile.</param> /// <param name="ObjectGroupId">The object group ID.</param> /// <returns>Returns the specify object group.</returns> private ObjectGroupList FindObjectGroup(OneNoteRevisionStoreFile file, ExGuid ObjectGroupId) { foreach (ObjectSpaceManifestList objSpaceManifest in file.RootFileNodeList.ObjectSpaceManifestList) { foreach (RevisionManifestList revManifestList in objSpaceManifest.RevisionManifestList) { for (int i = 0; i < revManifestList.RevisionManifests.Count; i++) { RevisionManifest revManifest = revManifestList.RevisionManifests[i]; ObjectGroupListReferenceFND objGroupListRef = revManifest.FileNodeSequence[1].fnd as ObjectGroupListReferenceFND; if (objGroupListRef.ObjectGroupID.Guid == ObjectGroupId.GUID && objGroupListRef.ObjectGroupID.N == ObjectGroupId.Value) { return(revManifestList.ObjectGroupList[i]); } } } } return(null); }
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."); } }
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 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 }