/// <summary> /// This method is used to create object group data/blob element list. /// </summary> /// <param name="fileContent">Specify the file content in byte array format.</param> /// <param name="rootNodeExGuid">Output parameter to represent the root node extended GUID.</param> /// <param name="objectDataExGuidList">Input/Output parameter to represent the list of extended GUID for the data object data.</param> /// <returns>Return the list of data element which will represent the file content.</returns> public static List<DataElement> CreateObjectGroupDataElement(byte[] fileContent, out ExGuid rootNodeExGuid, ref List<ExGuid> objectDataExGuidList) { NodeObject rootNode = new RootNodeObject.RootNodeObjectBuilder().Build(fileContent); // Storage the root object node ExGuid rootNodeExGuid = new ExGuid(rootNode.ExGuid); List<DataElement> elements = new ObjectGroupDataElementData.Builder().Build(rootNode); objectDataExGuidList.AddRange( elements.Where(element => element.DataElementType == DataElementType.ObjectGroupDataElementData) .Select(element => element.DataElementExtendedGUID) .ToArray()); return elements; }
/// <summary> /// This method is used to create object group data/blob element list. /// </summary> /// <param name="fileContent">Specify the file content in byte array format.</param> /// <param name="rootNodeExGuid">Output parameter to represent the root node extended GUID.</param> /// <param name="objectDataExGuidList">Input/Output parameter to represent the list of extended GUID for the data object data.</param> /// <returns>Return the list of data element which will represent the file content.</returns> public static List <DataElement> CreateObjectGroupDataElement(byte[] fileContent, out ExGuid rootNodeExGuid, ref List <ExGuid> objectDataExGuidList) { NodeObject rootNode = new RootNodeObject.RootNodeObjectBuilder().Build(fileContent); // Storage the root object node ExGuid rootNodeExGuid = new ExGuid(rootNode.ExGuid); List <DataElement> elements = new ObjectGroupDataElementData.Builder().Build(rootNode); objectDataExGuidList.AddRange( elements.Where(element => element.DataElementType == DataElementType.ObjectGroupDataElementData) .Select(element => element.DataElementExtendedGUID) .ToArray()); return(elements); }
public void TestCase_S13_TC10_PutChanges_Partial() { string fileUrl = Common.GetConfigurationPropertyValue("BigFile", this.Site); // Initialize the service this.InitializeContext(fileUrl, this.UserName01, this.Password01, this.Domain); CellSubRequestType queryChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID()); CellStorageResponse response = Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { queryChange }); 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 query change operation succeeds."); FsshttpbResponse fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site); SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponse, this.Site); // Get the file contents byte[] bytes = new RootNodeObject.RootNodeObjectBuilder() .Build(fsshttpbResponse.DataElementPackage.DataElements, fsshttpbResponse.CellSubResponses[0].GetSubResponseData<QueryChangesSubResponseData>().StorageIndexExtendedGUID) .GetContent() .ToArray(); // Update file contents byte[] newBytes = SharedTestSuiteHelper.GenerateRandomFileContent(Site); System.Array.Copy(newBytes, 0, bytes, 0, newBytes.Length); FsshttpbCellRequest cellRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest(); ExGuid storageIndexExGuid; List<DataElement> dataElements = DataElementUtils.BuildDataElements(bytes, out storageIndexExGuid); // Send the first partial put changes sub request null storageIndexExGuid. PutChangesCellSubRequest putChange = new PutChangesCellSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), null); cellRequest.AddSubRequest(putChange, dataElements.Take(4).ToList()); putChange.Partial = 1; CellSubRequestType cellSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64()); response = Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { cellSubRequest }); cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse<CellSubResponseType>(response, 0, 0, this.Site); // Expect the operation succeeds this.Site.Assert.AreEqual(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site), "The PutChanges operation should succeed."); fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site); SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponse, this.Site); // Send the last partial put changes sub request cellRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest(); putChange = new PutChangesCellSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), storageIndexExGuid); putChange.PartialLast = 1; cellRequest.AddSubRequest(putChange, dataElements.Skip(4).ToList()); cellSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64()); cellSubRequest.SubRequestData.CoalesceSpecified = true; cellSubRequest.SubRequestData.Coalesce = true; response = Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { cellSubRequest }); cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse<CellSubResponseType>(response, 0, 0, this.Site); this.Site.Assert.AreEqual(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site), "The PutChanges operation should succeed."); fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site); SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponse, this.Site); }
public void TestCase_S01_TC01_DownloadContents_Success() { // Initialize the context using user01 and defaultFileUrl. this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain); // Upload random file content to the server. byte[] fileContent = SharedTestSuiteHelper.GenerateRandomFileContent(this.Site); CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), fileContent); CellStorageResponse response = Adapter.CellStorageRequest(this.DefaultFileUrl, 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), "Test case cannot continue unless the upload file operation succeeds."); SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site), this.Site); // Query the updated file content. CellSubRequestType queryChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID()); response = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { queryChange }); cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse<CellSubResponseType>(response, 0, 0, this.Site); if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R97602 Site.CaptureRequirementIfAreEqual<ErrorCodeType>( ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site), "MS-FSSHTTP", 97602, @"[In Cell Subrequest][The protocol returns results based on the following conditions:] ErrorCode includes ""Success"" to indicate success in processing the file [upload or ]download request."); } else { Site.Assert.AreEqual<ErrorCodeType>( ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site), @"[In Cell Subrequest][The protocol returns results based on the following conditions:] ErrorCode includes ""Success"" to indicate success in processing the file [upload or ]download request."); } FsshttpbResponse fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site); SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponse, this.Site); byte[] downloadBytes = new RootNodeObject.RootNodeObjectBuilder().Build(fsshttpbResponse.DataElementPackage.DataElements, fsshttpbResponse.CellSubResponses[0].GetSubResponseData<QueryChangesSubResponseData>().StorageIndexExtendedGUID) .GetContent() .ToArray(); bool isContentMatch = AdapterHelper.ByteArrayEquals(fileContent, downloadBytes); this.Site.Assert.IsTrue( isContentMatch, "The download file contents should be equal to the updated file contents."); }
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. "); } }