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 validate CheckFolderInfo response captures.
        /// </summary>
        /// <param name="response">A parameter represents the response from server.</param>
        private void ValidateCheckFolderInfoResponse(WOPIHttpResponse response)
        {
            string          jsonString      = WOPIResponseHelper.ReadHTTPResponseBodyToString(response);
            CheckFolderInfo checkFolderInfo = WOPISerializerHelper.JsonToObject <CheckFolderInfo>(jsonString);

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

            // Verify MS-WOPI requirement: MS-WOPI_R602
            // The object is not null means JSON string can change to object. JSON to object check all require and optional item.
            this.Site.CaptureRequirementIfIsNotNull(
                checkFolderInfo,
                602,
                @"[In Response Body] The response body is JSON (as specified in [RFC4627]) with the following parameters:
                          JSON:
                          {
                          ""FolderName"":{""type"":""string"",""optional"":false},
                          ""BreadcrumbBrandIconUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""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},
                          ""FileSharingUrl"":{""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},
                          ""HostViewUrl"":{""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},
                          ""SignoutUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""SupportsSecureStore"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""TenantId""{""type"":""string"",""default"":"""",""optional"":true},
                          ""TermsOfUseUrl"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""UserCanWrite"":{""type"":""bool"",""default"":false,""optional"":true},
                          ""UserFriendlyName"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""UserId"":{""type"":""string"",""default"":"""",""optional"":true},
                          ""WebEditingDisabled"":{""type"":""bool"",""default"":false,""optional"":true},
                          }");

            this.ValidateURL(checkFolderInfo.CloseUrl, "CloseUrl");
            this.ValidateURL(checkFolderInfo.FileSharingUrl, "FileSharingUrl");
            this.ValidateURL(checkFolderInfo.HostEmbeddedEditUrl, "HostEmbeddedEditUrl");
            this.ValidateURL(checkFolderInfo.HostEmbeddedViewUrl, "HostEmbeddedViewUrl");
            this.ValidateURL(checkFolderInfo.PrivacyUrl, "PrivacyUrl");
            this.ValidateURL(checkFolderInfo.SignoutUrl, "SignoutUrl");
        }
Exemple #3
0
        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.");
            }
        }