Пример #1
0
        /// <summary>
        /// This method is used to validate EnumerateChildren response captures.
        /// </summary>
        /// <param name="response">A parameter represents the response from server.</param>
        private void ValidateEnumerateChildrenResponse(WOPIHttpResponse response)
        {
            // All folder children messages are follow this format. If test suite receive a succeed response, capture this requirement.
            this.Site.CaptureRequirement(
                699,
                @"[In HTTP://server/<...>/wopi*/folder/<id>/children] The contents of a folder being accessed by WOPI are identified by the following URI:
                          HTTP://server/<...>/wopi*/folder/<id>/children");

            // All folder children messages are follow this format. If test suite receive a succeed response, capture this requirement.
            this.Site.CaptureRequirement(
                700,
                @"[In HTTP://server/<...>/wopi*/folder/<id>/children] The syntax URI parameters are defined by the following ABNF:
                          id = STRING");

            string            jsonString        = WOPIResponseHelper.ReadHTTPResponseBodyToString(response);
            EnumerateChildren enumerateChildren = WOPISerializerHelper.JsonToObject <EnumerateChildren>(jsonString);

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-WOPI_R712");

            // Verify MS-WOPI requirement: MS-WOPI_R712
            // If the value is not null indicating the JSON string has been converted to EnumerateChildren type object successfully.
            this.Site.CaptureRequirementIfIsNotNull(
                enumerateChildren,
                712,
                @"[In Response Body] The response body is JSON (as specified in [RFC4627]) with the following parameters:
                          JSON:
                          {
                          ""Children"":
                            [{
                              ""Name"":""<name>"",
                              ""Url"":""<url>"",
                              ""Version"":""<version>""
                             },
                          }");
        }
Пример #2
0
        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.");
        }
Пример #3
0
        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).");
        }