OfficeDev/Interop-TestSuites

How to obtain the MSOneStore from within a MS-FSSHTTPB file?

nddipiazza opened this issue · 1 comments

I need some help extracting and asserting on some text from within a OneNote file saved from SharePoint Online.

So I go into SharePoint Online and create a OneNote file with some basic text content inside.

My overall goal is to do assertions on text content inside the OneNote file.

So I copy that file down to .one format and store it locally. Then I'm trying to use this project to create a Test Suite to extract the text from the OneNote file.

I have built the data elements list and that works.

But I'm confused how to extract the MSOneStorePackage from this data.

I tried the following:

      byte[] oneNoteBytes = File.ReadAllBytes(@"C:\test\testOneNoteMultiplePages.one");
      ExGuid exGuid;

      List<DataElement> dataElements = DataElementUtils.BuildDataElements(oneNoteBytes, out exGuid); // this works.

      DataElementPackage dataElementPackage = new DataElementPackage();
      dataElementPackage.DataElements = dataElements;

      MSONESTOREParser parser = new MSONESTOREParser();
      MSOneStorePackage msOneStorePackage = parser.Parse(dataElementPackage); // fails here during this call

      Console.WriteLine("Result: {0}", msOneStorePackage);

But this fails:

Unhandled Exception: System.InvalidOperationException: Unexpected to meet the byte array end.
   at Microsoft.Protocols.TestSuites.Common.BitReader.GetBytes(Int32 needReadlength, Int32 size) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\Common\BitField.cs:line 217
   at Microsoft.Protocols.TestSuites.Common.BitReader.ReadUInt32(Int32 readingLength) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\Common\BitField.cs:line 121
   at Microsoft.Protocols.TestSuites.MS_ONESTORE.ObjectSpaceObjectStreamHeader.DoDeserializeFromByteArray(Byte[] byteArray, Int32 startIndex) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\Common\ONESTORE\OtherStructures\ObjectSpaceObjectStreamHeader.cs:line 50
   at Microsoft.Protocols.TestSuites.MS_ONESTORE.ObjectSpaceObjectStreamOfOSIDs.DoDeserializeFromByteArray(Byte[] byteArray, Int32 startIndex) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\Common\ONESTORE\OtherStructures\ObjectSpaceObjectStreamOfOSIDs.cs:line 44
   at Microsoft.Protocols.TestSuites.MS_ONESTORE.ObjectSpaceObjectPropSet.DoDeserializeFromByteArray(Byte[] byteArray, Int32 startIndex) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\Common\ONESTORE\OtherStructures\ObjectSpaceObjectPropSet.cs:line 46
   at Microsoft.Protocols.TestSuites.SharedAdapter.HeaderCell.CreateInstance(ObjectGroupDataElementData objectElement) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\SharedTestSuite\SharedAdapter\Stack\ONESTORE\MSOneStorePackage.cs:line 125
   at Microsoft.Protocols.TestSuites.SharedAdapter.MSONESTOREParser.ParseHeaderCell(RevisionManifestDataElementData headerCellRevisionManifest) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\SharedTestSuite\SharedAdapter\Helper\MSONESTOREParser.cs:line 99
   at Microsoft.Protocols.TestSuites.SharedAdapter.MSONESTOREParser.Parse(DataElementPackage dataElementPackage) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\SharedTestSuite\SharedAdapter\Helper\MSONESTOREParser.cs:line 53
   at TestFSSHTTP_FSSHTTPB.Program.Main(String[] args) in C:\test\Interop-TestSuites\FileSyncandWOPI\Source\TestFSSHTTP-FSSHTTPB\Program.cs:line 24

Looks like the ObjectSpaceObjectStreamHeader is expecting a 32 byte array, but it only got a 16 byte array.

Can someone kick me in the right direction for the full parsing of the content so that I can get to the pages and their text?

Here is the one note file i am testing with:
testOneNoteMultiplePages.zip

PR #56 addresses this. Tested it, works.