public void MSWOPI_S18_TC02_CheckFolderInfo_HostAuthenticationId() { { // Get the folder URL. string folderFullUrl = Common.GetConfigurationPropertyValue("SubFolderUrl", this.Site); // Get the WOPI URL. string wopiTargetFolderUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(folderFullUrl, WOPIRootResourceUrlType.FolderLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFolderUrl); // Return information about the folder and permissions that the current user has relative to that file. WOPIHttpResponse httpWebResponseForCheckFolderInfo = WopiAdapter.CheckFolderInfo(wopiTargetFolderUrl, commonHeaders, string.Empty); string jsonString = WOPIResponseHelper.ReadHTTPResponseBodyToString(httpWebResponseForCheckFolderInfo); // Convert the json string to object. CheckFolderInfo checkFolderInfo = WOPISerializerHelper.JsonToObject <CheckFolderInfo>(jsonString); // Get the WOPI URL. string wopiTargetFolderUrlOther = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl( folderFullUrl, WOPIRootResourceUrlType.FileLevel, Common.GetConfigurationPropertyValue("UserName1", this.Site), Common.GetConfigurationPropertyValue("Password1", this.Site), Common.GetConfigurationPropertyValue("Domain", this.Site)); // Get the common header. WebHeaderCollection commonHeadersOther = HeadersHelper.GetCommonHeaders(wopiTargetFolderUrlOther); // Return information about the folder and permissions that the current user has relative to that file. WOPIHttpResponse httpWebResponseForCheckFolderInfoOther = WopiAdapter.CheckFolderInfo(wopiTargetFolderUrlOther, commonHeadersOther, string.Empty); jsonString = WOPIResponseHelper.ReadHTTPResponseBodyToString(httpWebResponseForCheckFolderInfoOther); // Convert the json string to object. CheckFolderInfo checkFolderInfoOther = WOPISerializerHelper.JsonToObject <CheckFolderInfo>(jsonString); // Verify MS-WOPI requirement: MS-WOPI_R742 this.Site.CaptureRequirementIfAreNotEqual( checkFolderInfo.HostAuthenticationId, checkFolderInfoOther.HostAuthenticationId, 742, @"[In Response Body] HostAuthenticationId: A string that is used by the WOPI server to uniquely for a sample of N (default N=2) identify the users."); // Verify requirement MS-WOPI_R59 bool isR59Satisfied = checkFolderInfo.HostAuthenticationId != checkFolderInfoOther.HostAuthenticationId; if (Convert.ToBoolean(Common.IsRequirementEnabled("MS-WOPI", 59, this.Site))) { // Verify MS-WOPI requirement: MS-WOPI_R59 this.Site.CaptureRequirementIfIsTrue( isR59Satisfied, 59, @"[In Common URI Parameters] Implementation does support the token is scoped to a specific user and set of resources.(Microsoft SharePoint Foundation 2013 and above follow this behavior)"); } } }
/// <summary> /// This method is used to initialize the shared test cases' context. /// </summary> /// <param name="requestFileUrl">A parameter represents the file URL.</param> /// <param name="userName">A parameter represents the user name we used.</param> /// <param name="password">A parameter represents the password of the user.</param> /// <param name="domain">A parameter represents the domain.</param> /// <param name="celloperationType">A parameter represents the type of CellStore operation which is used to determine different initialize logic.</param> /// <param name="site">A parameter represents the site.</param> public static void InitializeContextForShare(string requestFileUrl, string userName, string password, string domain, CellStoreOperationType celloperationType, ITestSite site) { SharedContext context = SharedContext.Current; string normalTargetUrl = string.Empty; switch (celloperationType) { case CellStoreOperationType.NormalCellStore: { normalTargetUrl = requestFileUrl; context.OperationType = OperationType.WOPICellStorageRequest; break; } case CellStoreOperationType.RelativeAdd: { // For relative adding a file, the WOPI resource file URL should be an existed file, and the file should be added in a location where the relative source file is located. normalTargetUrl = relativeSourceFileUrl; context.OperationType = OperationType.WOPICellStorageRelativeRequest; break; } case CellStoreOperationType.RealativeModified: { normalTargetUrl = requestFileUrl; context.OperationType = OperationType.WOPICellStorageRelativeRequest; break; } } // Convert the request file url to WOPI format URL so that the MS-FSSHTTP test cases will use WOPI format URL to send request. string wopiTargetUrl = wopiSutManagedCodeControlAdapter.GetWOPIRootResourceUrl(normalTargetUrl, WOPIRootResourceUrlType.FileLevel, userName, password, domain); context.TargetUrl = wopiTargetUrl; context.IsMsFsshttpRequirementsCaptured = false; context.Site = site; // Only set the X-WOPI-RelativeTarget header value in relative CellStorage operation. if (CellStoreOperationType.NormalCellStore != celloperationType) { // Read the file name from the target resource URL. context.XWOPIRelativeTarget = GetFileNameFromFullUrl(requestFileUrl); } // Generate common headers WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetUrl); context.XWOPIProof = commonHeaders["X-WOPI-Proof"]; context.XWOPIProofOld = commonHeaders["X-WOPI-ProofOld"]; context.XWOPITimeStamp = commonHeaders["X-WOPI-TimeStamp"]; context.XWOPIAuthorization = commonHeaders["Authorization"]; context.EndpointConfigurationName = currentSharedTestCasesEndpointName; context.UserName = userName; context.Password = password; context.Domain = domain; }
public void MSWOPI_S18_TC01_CheckFolderInfo() { if (!Common.IsRequirementEnabled("MS-WOPI", 593, this.Site)) { Site.Assume.Inconclusive(@"The implementation does not support the get the folder access_token and WOPISrc. It is determined using SHOULDMAY PTFConfig property named R593Enabled_MS-WOPI."); } // Get the folder URL. string folderFullUrl = Common.GetConfigurationPropertyValue("SubFolderUrl", this.Site); // Get the WOPI URL. string wopiTargetFolderUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(folderFullUrl, WOPIRootResourceUrlType.FolderLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFolderUrl); // Return information about the folder and permissions that the current user has relative to that file. WOPIHttpResponse httpWebResponseForCheckFolderInfo = WopiAdapter.CheckFolderInfo(wopiTargetFolderUrl, commonHeaders, string.Empty); // Get the json string from the response of CheckFolderInfo. string jsonString = WOPIResponseHelper.ReadHTTPResponseBodyToString(httpWebResponseForCheckFolderInfo); // Convert the json string to object. CheckFolderInfo checkFolderInfo = WOPISerializerHelper.JsonToObject <CheckFolderInfo>(jsonString); // Verify MS-WOPI requirement: MS-WOPI_R597 this.Site.CaptureRequirementIfIsNotNull( checkFolderInfo, 597, @"[In HTTP://server/<...>/wopi*/folders/<id>] Operation ""CheckFolderInfo"" is used for ""Returns information about a folder."); // Verify MS-WOPI requirement: MS-WOPI_R597 this.Site.CaptureRequirementIfIsNotNull( checkFolderInfo, 598, @"[In CheckFolderInfo] Return information about the folder and permissions that the current user has relative to that file."); // The URI in "CheckFolderInfo" WOPI request follow the "HTTP://server/<...>/wopi*/folders/<id>?access_token=<token>" pattern, if the operation execute successfully, capture R599 // Verify MS-WOPI requirement: MS-WOPI_R599 this.Site.CaptureRequirement( 599, @"[In CheckFolderInfo] HTTP Verb: GET URI: HTTP://server/<...>/wopi*/folders/<id>?access_token=<token>"); if (!string.IsNullOrEmpty(checkFolderInfo.UserFriendlyName)) { // Verify MS-WOPI requirement: MS-WOPI_R645 bool isVerifiedR645 = checkFolderInfo.UserFriendlyName.IndexOf(Common.GetConfigurationPropertyValue("UserName", this.Site), StringComparison.OrdinalIgnoreCase) >= 0 || checkFolderInfo.UserFriendlyName.IndexOf(Common.GetConfigurationPropertyValue("UserFriendlyName", this.Site), StringComparison.OrdinalIgnoreCase) >= 0; this.Site.CaptureRequirementIfIsTrue( isVerifiedR645, 645, @"[In Response Body] UserFriendlyName: A string that is the name of the user."); } }
public void MSWOPI_S19_TC05_PutFile_Fail409() { // Get the file URL. string fileUrl = this.AddFileToSUT(); // Get the WOPI URL. string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); string identifierForLock = Guid.NewGuid().ToString("N"); // Lock this file. WopiAdapter.Lock(wopiTargetFileUrl, commonHeaders, identifierForLock); try { // Get file content URL. string wopiFileContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFileUrl, WOPISubResourceUrlType.FileContentsLevel); // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); string exceptedUpdateContent = "WOPI PUT file test"; byte[] bodycontents = Encoding.UTF8.GetBytes(exceptedUpdateContent); string identifier = Guid.NewGuid().ToString("N"); int statusCode = 0; try { // Update a file on the WOPI server. WOPIHttpResponse httpWebResponseOfPutFile = WopiAdapter.PutFile(wopiFileContentsLevelUrl, commonHeaders, null, bodycontents, identifier); statusCode = httpWebResponseOfPutFile.StatusCode; } catch (WebException webEx) { HttpWebResponse errorResponse = this.GetErrorResponseFromWebException(webEx); statusCode = this.GetStatusCodeFromHTTPResponse(errorResponse); } // Verify MS-WOPI requirement: MS-WOPI_R690 this.Site.CaptureRequirementIfAreEqual( 409, statusCode, 690, @"[In PutFile] Status code ""409"" means ""Lock mismatch""."); } finally { // Release a lock for editing a file. commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); WopiAdapter.UnLock(wopiTargetFileUrl, commonHeaders, identifierForLock); } }
public void MSWOPI_S19_TC01_GetFile() { // Get the file URL. string fileUrl = this.AddFileToSUT(); // Get the WOPI URL. string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get file content URL. string wopiFileContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFileUrl, WOPISubResourceUrlType.FileContentsLevel); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); int statusCode = 0; // Get a file. WOPIHttpResponse responseOfGetFile = WopiAdapter.GetFile(wopiFileContentsLevelUrl, commonHeaders, null); statusCode = responseOfGetFile.StatusCode; // Verify MS-WOPI requirement: MS-WOPI_R667 this.Site.CaptureRequirementIfAreEqual( 200, statusCode, 667, @"[In GetFile] Status code ""200"" means ""Success""."); // Verify MS-WOPI requirement: MS-WOPI_R657 this.Site.CaptureRequirementIfIsNotNull( responseOfGetFile, 657, @"[In HTTP://server/<...>/wopi*/files/<id>/contents] Operation ""GetFile"" is used for ""Request message to retrieve a file for the HTTP://server/<...>/wopi*/files/<id>/contents operation""."); // Verify MS-WOPI requirement: MS-WOPI_R659 this.Site.CaptureRequirementIfIsNotNull( responseOfGetFile, 659, @"[In GetFile] Get a file."); // The URI in "GetFile" WOPI request follow the "HTTP://server/<...>/wopi*/files/<id>/contents?access_token=<token>" pattern, if the operation execute successfully, capture R660 // Verify MS-WOPI requirement: MS-WOPI_R660 this.Site.CaptureRequirement( 660, @"[In GetFile] HTTP Verb: GET URI: HTTP://server/<...>/wopi*/files/<id>/contents?access_token=<token>"); // Verify MS-WOPI requirement: MS-WOPI_R672 this.Site.CaptureRequirementIfIsNotNull( responseOfGetFile, 672, @"[In Response Body] The binary contents of the file."); }
public void MSWOPI_S19_TC06_PutFile_Lock() { // Get the file URL. string fileUrl = this.AddFileToSUT(); // Get the WOPI URL. string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get file content URL. string wopiFileContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFileUrl, WOPISubResourceUrlType.FileContentsLevel); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); string identifierForLock = Guid.NewGuid().ToString("N"); // Lock this file. WopiAdapter.Lock(wopiTargetFileUrl, commonHeaders, identifierForLock); try { // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); string exceptedUpdateContent = "WOPI PUT file test"; byte[] bodycontents = Encoding.UTF8.GetBytes(exceptedUpdateContent); // Update a file on the WOPI server with the identifier of Lock. WopiAdapter.PutFile(wopiFileContentsLevelUrl, commonHeaders, null, bodycontents, identifierForLock); // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); // Get a file. WOPIHttpResponse responseOfGetFile = WopiAdapter.GetFile(wopiFileContentsLevelUrl, commonHeaders, null); // Read message from response of GetFile. string actualUpdateContent = WOPIResponseHelper.ReadHTTPResponseBodyToString(responseOfGetFile); // Verify MS-WOPI requirement: MS-WOPI_R697 this.Site.CaptureRequirementIfAreEqual( exceptedUpdateContent, actualUpdateContent, 697, @"[In Processing Details] If the file is currently associated with a lock established by the Lock operation (see section 3.3.5.1.3) [or the UnlockAndRelock operation (see section 3.3.5.1.6)] the WOPI server MUST provide the matching lock value in order for this operation to succeed."); } finally { // Release a lock for editing a file. commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); WopiAdapter.UnLock(wopiTargetFileUrl, commonHeaders, identifierForLock); } }
public void MSWOPI_S19_TC04_PutFile_Fail404() { // Get the file URL. string fileUrl = this.AddFileToSUT(); // Get the WOPI URL. string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get file content URL. string wopiFileContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFileUrl, WOPISubResourceUrlType.FileContentsLevel); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); // Delete this file. WopiAdapter.DeleteFile(wopiTargetFileUrl, commonHeaders); // The file has been deleted, so remove it from the clean up list. this.ExcludeFileFromTheCleanUpProcess(fileUrl); // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); string exceptedUpdateContent = "WOPI PUT file test"; byte[] bodycontents = Encoding.UTF8.GetBytes(exceptedUpdateContent); string identifier = Guid.NewGuid().ToString("N"); int statusCodeOfPutFile = 0; try { // Update a file on the WOPI server. WOPIHttpResponse httpWebResponseOfPutFile = WopiAdapter.PutFile(wopiFileContentsLevelUrl, commonHeaders, null, bodycontents, identifier); statusCodeOfPutFile = httpWebResponseOfPutFile.StatusCode; } catch (WebException webEx) { HttpWebResponse errorResponse = this.GetErrorResponseFromWebException(webEx); statusCodeOfPutFile = this.GetStatusCodeFromHTTPResponse(errorResponse); } // Verify MS-WOPI requirement: MS-WOPI_R689 this.Site.CaptureRequirementIfAreEqual( 404, statusCodeOfPutFile, 689, @"[In PutFile] Status code ""404"" means ""File unknown/User unauthorized""."); }
public void MSWOPI_S19_TC02_GetFile_Fail404() { // Get the file URL. string fileUrl = this.AddFileToSUT(); // Get the WOPI URL. string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get file content URL. string wopiFileContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFileUrl, WOPISubResourceUrlType.FileContentsLevel); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); // Delete the file. WopiAdapter.DeleteFile(wopiTargetFileUrl, commonHeaders); // The file has been deleted, so remove it from the clean up list. this.ExcludeFileFromTheCleanUpProcess(fileUrl); // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); int statusCodeOfGetFile = 0; try { // Get a file. WOPIHttpResponse responseOfGetFile = WopiAdapter.GetFile(wopiFileContentsLevelUrl, commonHeaders, null); statusCodeOfGetFile = responseOfGetFile.StatusCode; } catch (WebException webEx) { HttpWebResponse errorResponse = this.GetErrorResponseFromWebException(webEx); statusCodeOfGetFile = this.GetStatusCodeFromHTTPResponse(errorResponse); } // Verify MS-WOPI requirement: MS-WOPI_R669 this.Site.CaptureRequirementIfAreEqual( 404, statusCodeOfGetFile, 669, @"[In GetFile] Status code ""404"" means ""File unknown/User unauthorized""."); }
public void MSWOPI_S20_TC03_EnumerateChildren_Fail404() { if (!Common.IsRequirementEnabled("MS-WOPI", 593, this.Site)) { Site.Assume.Inconclusive(@"The implementation does not support the get the folder access_token and WOPISrc. It is determined using SHOULDMAY PTFConfig property named R593Enabled_MS-WOPI."); } // Get the folder URL. string folderFullUrl = Common.GetConfigurationPropertyValue("SubFolderUrl", this.Site); // Get the WOPI URL. string wopiTargetFolderUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(folderFullUrl, WOPIRootResourceUrlType.FolderLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get folder content URL. string wopiFolderContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFolderUrl, WOPISubResourceUrlType.FolderChildrenLevel); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiFolderContentsLevelUrl); // Remove "Authorization" header from common headers. commonHeaders.Remove("Authorization"); // Return the contents of a folder on the WOPI server with invalid token. int statusCode = 0; try { WOPIHttpResponse httpWebResponseForEnumerateChildren = WopiAdapter.EnumerateChildren(wopiFolderContentsLevelUrl, commonHeaders); statusCode = httpWebResponseForEnumerateChildren.StatusCode; } catch (WebException webEx) { HttpWebResponse errorResponse = this.GetErrorResponseFromWebException(webEx); statusCode = this.GetStatusCodeFromHTTPResponse(errorResponse); } // Verify MS-WOPI requirement: MS-WOPI_R709 this.Site.CaptureRequirementIfAreEqual <int>( 404, statusCode, 709, @"[In EnumerateChildren] Status code ""404"" means ""File unknown/User unauthorized""."); }
/// <summary> /// This method is used to get the common headers. /// </summary> /// <param name="targetResourceUri">The value of the target resource URI.</param> /// <returns>The common headers.</returns> public static WebHeaderCollection GetCommonHeaders(string targetResourceUri) { WebHeaderCollection getCommonHeaders = new WebHeaderCollection(); string tokenValue = TokenAndRequestUrlHelper.GetTokenValueFromWOPIResourceUrl(targetResourceUri); // Setting the required headers: string authorizationValue = string.Format(@"Bearer {0}", tokenValue); getCommonHeaders.Add("Authorization", authorizationValue); long currentTicks = DateTime.UtcNow.Ticks; string proofHeaderValueOfCurrent = HeadersHelper.GetProofHeaderValue(targetResourceUri, currentTicks); getCommonHeaders.Add("X-WOPI-Proof", proofHeaderValueOfCurrent); string proofHeaderValueOfOld = HeadersHelper.GetProofHeaderValue(targetResourceUri, currentTicks, true); getCommonHeaders.Add("X-WOPI-ProofOld", proofHeaderValueOfOld); getCommonHeaders.Add("X-WOPI-TimeStamp", currentTicks.ToString()); return(getCommonHeaders); }
public void MSWOPI_S19_TC03_PutFile() { // Get the file URL. string fileUrl = this.AddFileToSUT(); // Get the WOPI URL. string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get file content URL. string wopiFileContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFileUrl, WOPISubResourceUrlType.FileContentsLevel); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); string exceptedUpdateContent = "WOPI PUT file test"; byte[] bodycontents = Encoding.UTF8.GetBytes(exceptedUpdateContent); string identifier = Guid.NewGuid().ToString("N"); int statusCode = 0; // Update a file on the WOPI server. WOPIHttpResponse httpWebResponseOfPutFile = WopiAdapter.PutFile(wopiFileContentsLevelUrl, commonHeaders, null, bodycontents, identifier); statusCode = httpWebResponseOfPutFile.StatusCode; // Verify MS-WOPI requirement: MS-WOPI_R687 this.Site.CaptureRequirementIfAreEqual( 200, statusCode, 687, @"[In PutFile] Status code ""200"" means ""Success""."); // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); // Get a file. WOPIHttpResponse responseOfGetFile = WopiAdapter.GetFile(wopiFileContentsLevelUrl, commonHeaders, null); // Read message from response of GetFile. string actualUpdateContent = WOPIResponseHelper.ReadHTTPResponseBodyToString(responseOfGetFile); // Verify MS-WOPI requirement: MS-WOPI_R674 this.Site.CaptureRequirementIfAreEqual( exceptedUpdateContent, actualUpdateContent, 674, @"[In PutFile] Update a file on the WOPI server."); // Verify MS-WOPI requirement: MS-WOPI_R675 this.Site.CaptureRequirement( 675, @"[In PutFile] HTTP Verb: POST URI: HTTP://server/<...>/wopi*/files/<id>/contents?access_token=<token>"); // Verify MS-WOPI requirement: MS-WOPI_R696 this.Site.CaptureRequirementIfAreEqual( exceptedUpdateContent, actualUpdateContent, 696, @"[In Processing Details] The WOPI server MUST update the binary of the file identified by <id> to match the binary contents in the request body, if the response indicates Success."); // Verify MS-WOPI requirement: MS-WOPI_R658 this.Site.CaptureRequirementIfAreEqual( exceptedUpdateContent, actualUpdateContent, 658, @"[In HTTP://server/<...>/wopi*/files/<id>/contents] Operation ""PutFile"" is used for ""Request message to update a file for the HTTP://server/<...>/wopi*/files/<id>/contents operation""."); // Verify MS-WOPI requirement: MS-WOPI_R673 this.Site.CaptureRequirementIfAreEqual( exceptedUpdateContent, actualUpdateContent, 673, @"[In Processing Details] The WOPI server MUST return the complete binary of the file identified by <id> in the response body, if the response indicates Success."); }
public void MSWOPI_S20_TC01_EnumerateChildren() { // Get the folder URL. string folderFullUrl = Common.GetConfigurationPropertyValue("SubFolderUrl", this.Site); // Get the WOPI URL. string wopiTargetFolderUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(folderFullUrl, WOPIRootResourceUrlType.FolderLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get folder content URL. string wopiFolderContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFolderUrl, WOPISubResourceUrlType.FolderChildrenLevel); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiFolderContentsLevelUrl); // Return the contents of a folder on the WOPI server. WOPIHttpResponse httpWebResponseForEnumerateChildren = WopiAdapter.EnumerateChildren(wopiFolderContentsLevelUrl, commonHeaders); int statusCode = httpWebResponseForEnumerateChildren.StatusCode; // Get the json string from the response of EnumerateChildren. string jsonStringForEnumerateChildren = WOPIResponseHelper.ReadHTTPResponseBodyToString(httpWebResponseForEnumerateChildren); // Convert the json string to object. EnumerateChildren enchildren = WOPISerializerHelper.JsonToObject <EnumerateChildren>(jsonStringForEnumerateChildren); string fileName = enchildren.Children[0].Name; // Verify MS-WOPI requirement: MS-WOPI_R707 this.Site.CaptureRequirementIfAreEqual <int>( 200, statusCode, 707, @"[In EnumerateChildren] Status code ""200"" means ""Success""."); // The status code is 200 mean success.When response is success the URIs are return. this.Site.CaptureRequirement( 703, @"[In HTTP://server/<...>/wopi*/folder/<id>/children] Operation ""EnumerateChildren"" is used for ""Returns a set of URIs that provides access to resources in the folder""."); // The status code is 200 mean success.When response is success the contexts are return. this.Site.CaptureRequirement( 704, @"[In EnumerateChildren] The EnumerateChildren method returns the contents of a folder on the WOPI server."); // The status code is 200 mean success.When response is success the URI follows the format. this.Site.CaptureRequirement( 705, @"[In EnumerateChildren] HTTP Verb: GET URI: HTTP://server/<...>/wopi*/folder/<id>/children?access_token=<token>"); string subFileUrl = Common.GetConfigurationPropertyValue("UrlOfFileOnSubFolder", this.Site); string expectedFileName = TestSuiteHelper.GetFileNameFromFullUrl(subFileUrl); // Verify MS-WOPI requirement: MS-WOPI_R713 bool isEqualToExpectedFileName = expectedFileName.CompareStringValueIgnoreCase(fileName, this.Site); this.Site.CaptureRequirementIfIsTrue( isEqualToExpectedFileName, 713, @"[In Response Body] Name: The name of the child resource."); // Verify MS-WOPI requirement: MS-WOPI_R714 // The EnumerateChildren request message follow this format and use the id and token return by WOPI server. // If the WOPI server can return the response of EnumerateChildren, capture R714 this.Site.CaptureRequirement( 714, @"[In Response Body] Url: The URI of the child resource of the form http://server/<...>/wopi*/files/<id>?access_token=<token> where id is the WOPI server’s unique id of the resource and token is the token that provides access to the resource."); }
public void MSWOPI_S20_TC02_EnumerateChildren_Version() { #region Get the WOPI resource URL for visiting file. // Get the file URL. string fileUrl = Common.GetConfigurationPropertyValue("UrlOfFileOnSubFolder", this.Site); // Get the WOPI URL. string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get file content URL. string wopiFileContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFileUrl, WOPISubResourceUrlType.FileContentsLevel); #endregion #region Get the WOPI resource URL for visiting folder. // Get the folder URL. string folderFullUrl = Common.GetConfigurationPropertyValue("SubFolderUrl", this.Site); // Get the WOPI URL. string wopiTargetFolderUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(folderFullUrl, WOPIRootResourceUrlType.FolderLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get folder content URL. string wopiFolderContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFolderUrl, WOPISubResourceUrlType.FolderChildrenLevel); #endregion #region Call EnumerateChildren // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiFolderContentsLevelUrl); // Return the contents of a folder on the WOPI server. WOPIHttpResponse httpWebResponseForEnumerateChildren = WopiAdapter.EnumerateChildren(wopiFolderContentsLevelUrl, commonHeaders); // Get the json string from the response of EnumerateChildren. string jsonStringForEnumerateChildren = WOPIResponseHelper.ReadHTTPResponseBodyToString(httpWebResponseForEnumerateChildren); // Convert the json string to object. EnumerateChildren enchildren = WOPISerializerHelper.JsonToObject <EnumerateChildren>(jsonStringForEnumerateChildren); string versionOld = enchildren.Children[0].Version; #endregion #region Call PutFile // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); string exceptedUpdateContent = "WOPI PUT file test"; byte[] bodycontents = Encoding.UTF8.GetBytes(exceptedUpdateContent); string identifier = Guid.NewGuid().ToString("N"); // Update a file on the WOPI server. WopiAdapter.PutFile(wopiFileContentsLevelUrl, commonHeaders, null, bodycontents, identifier); #endregion #region Call EnumerateChildren // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFolderContentsLevelUrl); // Return the contents of a folder on the WOPI server. httpWebResponseForEnumerateChildren = WopiAdapter.EnumerateChildren(wopiFolderContentsLevelUrl, commonHeaders); // Get the json string from the response of EnumerateChildren. jsonStringForEnumerateChildren = WOPIResponseHelper.ReadHTTPResponseBodyToString(httpWebResponseForEnumerateChildren); // Convert the json string to object. enchildren = WOPISerializerHelper.JsonToObject <EnumerateChildren>(jsonStringForEnumerateChildren); string versionNew = enchildren.Children[0].Version; #endregion #region Call CheckFileInfo // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); // Return information about the file WOPIHttpResponse responseOfCheckFileInfo = WopiAdapter.CheckFileInfo(wopiTargetFileUrl, commonHeaders, null); // Get the json string from the response of CheckFileInfo. string jsonStringForCheckFileInfo = WOPIResponseHelper.ReadHTTPResponseBodyToString(responseOfCheckFileInfo); // Convert the json string to object. CheckFileInfo checkFileInfo = WOPISerializerHelper.JsonToObject <CheckFileInfo>(jsonStringForCheckFileInfo); string versionCheckFileInfo = checkFileInfo.Version; #endregion // Verify MS-WOPI requirement: MS-WOPI_R716 this.Site.CaptureRequirementIfAreNotEqual <string>( versionOld, versionNew, 716, @"[In Response Body] [Version] This value MUST change when the file changes."); // Verify MS-WOPI requirement: MS-WOPI_R934 this.Site.CaptureRequirementIfAreEqual <string>( versionCheckFileInfo, versionNew, 934, @"[In Response Body] [Version] MUST match the value that would be provided by the ""Version"" field in the response to CheckFileInfo (see section 3.3.5.1.1)."); }
public void MSWOPI_S19_TC05_PutFile_Fail409() { // Get the file URL. string fileUrl = this.AddFileToSUT(); // Get the WOPI URL. string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain); // Get the common header. WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); string identifierForLock = Guid.NewGuid().ToString("N"); // Lock this file. WopiAdapter.Lock(wopiTargetFileUrl, commonHeaders, identifierForLock); try { // Get file content URL. string wopiFileContentsLevelUrl = TokenAndRequestUrlHelper.GetSubResourceUrl(wopiTargetFileUrl, WOPISubResourceUrlType.FileContentsLevel); // Get the common header. commonHeaders = HeadersHelper.GetCommonHeaders(wopiFileContentsLevelUrl); string exceptedUpdateContent = "WOPI PUT file test"; byte[] bodycontents = Encoding.UTF8.GetBytes(exceptedUpdateContent); string identifier = Guid.NewGuid().ToString("N"); int statusCode = 0; HttpWebResponse errorResponse = null; try { // Update a file on the WOPI server. WOPIHttpResponse httpWebResponseOfPutFile = WopiAdapter.PutFile(wopiFileContentsLevelUrl, commonHeaders, null, bodycontents, identifier); statusCode = httpWebResponseOfPutFile.StatusCode; } catch (WebException webEx) { errorResponse = this.GetErrorResponseFromWebException(webEx); statusCode = this.GetStatusCodeFromHTTPResponse(errorResponse); } // Verify MS-WOPI requirement: MS-WOPI_R690 this.Site.CaptureRequirementIfAreEqual( 409, statusCode, 690, @"[In PutFile] Status code ""409"" means ""Lock mismatch""."); if (Common.IsRequirementEnabled("MS-WOPI", 685003, this.Site)) { // Verify MS-WOPI requirement: MS-WOPI_R685003 this.Site.CaptureRequirementIfIsTrue( errorResponse.Headers.Get("X-WOPI-Lock") != null, 685003, @"[In PutFile] This header [X-WOPI-Lock] MUST be included when responding with the 409 status code. "); // Verify MS-WOPI requirement: MS-WOPI_R980001 this.Site.CaptureRequirementIfIsTrue( errorResponse.Headers.Get("X-WOPI-Lock") != null, 980001, @"[In PutFile] an X-WOPI-Lock response header containing the value of the current lock on the file MUST be included when using this response code [409]."); Boolean VerifyR685005 = false; for (int i = 0; i < errorResponse.Headers.Count; i++) { if (errorResponse.Headers.AllKeys[i] == "X-WOPI-Lock") { VerifyR685005 = true; break; } } // Verify MS-WOPI requirement: MS-WOPI_R685005 this.Site.CaptureRequirementIfIsTrue( VerifyR685005, 685005, @"[In PutFile] X-WOPI-Lock is a string."); } if (Common.IsRequirementEnabled("MS-WOPI", 685009001, this.Site)) { // Verify MS-WOPI requirement: MS-WOPI_R685009001 this.Site.CaptureRequirementIfIsTrue( string.IsNullOrEmpty(errorResponse.Headers.Get("X-WOPI-LockFailureReason")), 685009001, @"[In PutFile] Implementation does not include the header X-WOPI-LockFailureReason when responding with the 409 status code. (SharePoint Foundation 2010 and above follows this behavior)."); } if (Common.IsRequirementEnabled("MS-WOPI", 685012001, this.Site)) { // Verify MS-WOPI requirement: MS-WOPI_R685012001 this.Site.CaptureRequirementIfIsTrue( string.IsNullOrEmpty(errorResponse.Headers.Get("X-WOPI-LockedByOtherInterface")), 685012001, @"[In PutFile] Implementation does not include the header X-WOPI-LockedByOtherInterface when responding with the 409 status code. (SharePoint Foundation 2010 and above follows this behavior)."); } } finally { // Release a lock for editing a file. commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl); WopiAdapter.UnLock(wopiTargetFileUrl, commonHeaders, identifierForLock); } }