Example #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
        }
Example #2
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
        }