Exemple #1
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
        }
Exemple #2
0
        /// <summary>
        /// Parse the structure of revision store file.
        /// </summary>
        /// <param name="cellStorageResponse">the CellStorageResponse message received from the server.</param>
        /// <returns>Returns the revision store file from the server.</returns>
        private MSOneStorePackage ConvertOneStorePackage(CellStorageResponse cellStorageResponse)
        {
            MSOneStorePackage package           = null;
            string            subResponseBase64 = cellStorageResponse.ResponseCollection.Response[0].SubResponse[0].SubResponseData.Text[0];

            byte[]           subResponseBinary = Convert.FromBase64String(subResponseBase64);
            FsshttpbResponse fsshttpbResponse  = FsshttpbResponse.DeserializeResponseFromByteArray(subResponseBinary, 0);

            if (fsshttpbResponse.DataElementPackage != null && fsshttpbResponse.DataElementPackage.DataElements != null)
            {
                MSONESTOREParser onenoteParser = new MSONESTOREParser();
                package = onenoteParser.Parse(fsshttpbResponse.DataElementPackage);
            }

            return(package);
        }
Exemple #3
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
        }
Exemple #4
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
        }
Exemple #5
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;
                        }
                    }
                }
            }
        }
Exemple #6
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
        }