Ejemplo n.º 1
0
        /// <summary>
        /// This method is used to validate CheckFileInfo response captures.
        /// </summary>
        /// <param name="response">A parameter represents the response from server.</param>
        private void ValidateCheckFileInfoResponse(WOPIHttpResponse response)
        {
            string        jsonString    = WOPIResponseHelper.ReadHTTPResponseBodyToString(response);
            CheckFileInfo checkFileInfo = WOPISerializerHelper.JsonToObject <CheckFileInfo>(jsonString);

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

            // Verify MS-WOPI requirement: MS-WOPI_R273
            // If the value is not null indicating the JSON string has been converted to CheckFileInfo type object successfully.
            this.Site.CaptureRequirementIfIsNotNull(
                checkFileInfo,
                273,
                @"[In Response Body] The response body is JavaScript Object Notation (JSON) (as specified in [RFC4627]) with the following parameters:
                          JSON:
                          {
                          ""AllowExternalMarketplace"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""BaseFileName"":{""type"":""string"",""optional"":false},
                          ""BreadcrumbBrandName"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""BreadcrumbBrandUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""BreadcrumbDocName"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""BreadcrumbDocUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""BreadcrumbFolderName"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""BreadcrumbFolderUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""ClientUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""CloseButtonClosesWindow"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""CloseUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""DisableBrowserCachingOfUserContent"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""DisablePrint"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""DisableTranslation"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""DownloadUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""FileSharingUrl"":{""type"":""string"",""default"":"""",""optional"":true}, 
                          ""FileUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""HostAuthenticationId""{""type"":""string"",""default"":"""",""optional"":true},
                          ""HostEditUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""HostEmbeddedEditUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""HostEmbeddedViewUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""HostName"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""HostNotes"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""HostRestUrl""{""type"":""string"",""default"":"""",""optional"":true},
                          ""HostViewUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""IrmPolicyDescription"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""IrmPolicyTitle"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""OwnerId"":{""type"":""string"",""optional"":false},
                          ""PresenceProvider""{""type"":""string"",""default"":"""",""optional"":true},
                          ""PresenceUserId""{""type"":""string"",""default"":"""",""optional"":true},
                          ""PrivacyUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""ProtectInClient"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""ReadOnly"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""RestrictedWebViewOnly"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""SHA256"":{""type"":""string"",""optional"":false},
                          ""SignoutUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""Size"":{""type"":""int"",""optional"":false},
                          ""SupportsCoauth"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""SupportsCobalt"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""SupportsFolders"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""SupportsLocks"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""SupportsScenarioLinks"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""SupportsSecureStore"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""SupportsUpdate"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""TenantId""{""type"":""string"",""default"":"""",""optional"":true},
                          ""TermsOfUseUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""TimeZone""{""type"":""string"",""default"":"""",""optional"":true},
                          ""UserCanAttend"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""UserCanNotWriteRelative"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""UserCanPresent"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""UserCanWrite"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""UserFriendlyName"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""UserId"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""Version"":{""type"":""string"",""optional"":false}
                          ""WebEditingDisabled"":{""type"":""bool"",""default"":false,""optional"":true},
                          }");

            if (WOPISerializerHelper.CheckContainItem(jsonString, "ReadOnly"))
            {
                // Check whether "ReadOnly" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    925,
                    @"[In Response Body] ReadOnly is a Boolean value.");
            }

            if (WOPISerializerHelper.CheckContainItem(jsonString, "SupportsCoauth"))
            {
                // Check whether "SupportsCoauth" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    950,
                    @"[In Response Body] SupportsCoauth is a Boolean value.");
            }

            if (WOPISerializerHelper.CheckContainItem(jsonString, "SupportsCobalt"))
            {
                // Check whether "SupportsCobalt" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    775,
                    @"[In Response Body] SupportsCobalt is a Boolean value.");
            }

            if (WOPISerializerHelper.CheckContainItem(jsonString, "SupportsFolders"))
            {
                // Check whether "SupportsFolders" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    777,
                    @"[In Response Body] SupportsFolders is a Boolean value.");
            }

            if (WOPISerializerHelper.CheckContainItem(jsonString, "SupportsLocks"))
            {
                // Check whether "SupportsLocks" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    779,
                    @"[In Response Body] SupportsLocks is a Boolean value.");
            }

            if (WOPISerializerHelper.CheckContainItem(jsonString, "SupportsSecureStore"))
            {
                // Check whether "SupportsSecureStore" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    923,
                    @"[In Response Body] SupportsSecureStore is a Boolean value.");
            }

            if (WOPISerializerHelper.CheckContainItem(jsonString, "SupportsUpdate"))
            {
                // Check whether "SupportsUpdate" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    783,
                    @"[In Response Body] SupportsUpdate is a Boolean value.");
            }

            if (WOPISerializerHelper.CheckContainItem(jsonString, "UserCanNotWriteRelative"))
            {
                // Check whether "UserCanNotWriteRelative" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    920,
                    @"[In Response Body] UserCanNotWriteRelative is a Boolean value.");
            }

            if (WOPISerializerHelper.CheckContainItem(jsonString, "UserCanWrite"))
            {
                // Check whether "UserCanWrite" is in JSON. If JSON string contain this item,it must follow JSON response format.
                this.Site.CaptureRequirement(
                    928,
                    @"[In Response Body] UserCanWrite is a Boolean value.");
            }

            this.ValidateURL(checkFileInfo.CloseUrl, "CloseUrl");
            this.ValidateURL(checkFileInfo.DownloadUrl, "DownloadUrl");
            this.ValidateURL(checkFileInfo.FileSharingUrl, "FileSharingUrl");
            this.ValidateURL(checkFileInfo.HostViewUrl, "HostViewUrl");
        }
Ejemplo n.º 2
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).");
        }