コード例 #1
0
        /// <summary>
        /// This operation is used to request renewal of an expired security validation token, also known as a message digest, and the new security validation token’s expiration time.
        /// </summary>
        /// <param name="url">Specify a page URL with which the returned security validation token information is associated.</param>
        /// <returns>The result of GetUpdatedFormDigestInformation operation that contains a security validation token generated by the protocol server, the security validation token’s expiration time in seconds, and other information.</returns>
        public FormDigestInformation GetUpdatedFormDigestInformation(string url)
        {
            // Check whether GetUpdatedFormDigestInformation operation succeeds.
            FormDigestInformation getUpdatedFormDigestInfoResult = null;

            getUpdatedFormDigestInfoResult = this.service.GetUpdatedFormDigestInformation(url);

            // Verify the GetUpdatedFormDigestInformationResponse structure.
            this.VerifyGetUpdatedFormDigestInformation(getUpdatedFormDigestInfoResult);
            return(getUpdatedFormDigestInfoResult);
        }
コード例 #2
0
ファイル: GraphClient.cs プロジェクト: janardhan96/TeamGraph
 public string GetFormDigestFromWebService(string siteUrl)
 {
     try
     {
         using (SKSitesWebService objSite = CreateWebService <SKSitesWebService>())
         {
             FormDigestInformation formDigest = objSite.GetUpdatedFormDigestInformation(siteUrl);
             var site = objSite.GetSite(siteUrl);
             return(formDigest.DigestValue);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
コード例 #3
0
        public void MSSITESS_S03_TC02_GetUpdatedFormDigestInformation()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5381, this.Site), @"Test is executed only when R5381Enabled is set to true.");

            string webPageUrl = Common.GetConfigurationPropertyValue(Constants.WebPageUrl, this.Site);
            FormDigestInformation currentInfo = new FormDigestInformation();
            FormDigestInformation newInfo     = new FormDigestInformation();
            string urlStr            = string.Empty;
            int    formDigestTimeout = int.Parse(Common.GetConfigurationPropertyValue(Constants.ExpireTimePeriodBySecond, this.Site));
            string currentSite       = Common.GetConfigurationPropertyValue(Constants.SiteCollectionUrl, this.Site);

            // Initialize the web service with an authenticated account.
            this.sitessAdapter.InitializeWebService(UserAuthenticationOption.Authenticated);

            // Invoke the GetUpdatedFormDigestInformation operation.
            currentInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(urlStr);

            var formDigestValid = this.sutAdapter.PostWebForm(currentInfo.DigestValue, webPageUrl);

            Site.Assert.IsTrue(formDigestValid.Contains(Constants.PostWebFormResponse), "digest accept");

            // If the DigestValue is the valid security validation token, R500 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R500, the DigestValue is {0}.", currentInfo.DigestValue);

            // Verify MS-SITESS requirement: MS-SITESS_R500
            Site.CaptureRequirement(
                500,
                @"[In FormDigestInformation] DigestValue: Security validation token generated by the protocol server.");

            // This sleep is just to wait for security validation returned by the server to expire and add 10 s for buffer, not wait for the server to complete operation or return response.
            Thread.Sleep((1000 * formDigestTimeout) + 10000);

            var formDigestExpired = this.sutAdapter.PostWebForm(currentInfo.DigestValue, webPageUrl);

            if (Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointFoundation2013 ||
                Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointFoundation2013SP1 ||
                Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointServer2013 ||
                Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointServer2016 ||
                Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointServer2019)
            {
                Site.Assert.IsTrue(formDigestExpired.Contains(Constants.TimeOutInformationForSP2013AndSP2016), "digest expired");
            }
            else
            {
                Site.Assert.IsTrue(formDigestExpired.Contains(Constants.TimeOutInformationForSP2007AndSP2010), "digest expired");
            }

            // If the security validation token do expire after specified timeout seconds, R501 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R501, the TimeoutSeconds is {0}.", currentInfo.TimeoutSeconds);

            // Verify MS-SITESS requirement: MS-SITESS_R501
            Site.CaptureRequirement(
                501,
                @"[In FormDigestInformation] TimeoutSeconds: The time in seconds in which the security validation token will expire after the protocol server generates the security validation token server.");

            // Invoke the GetUpdatedFormDigestInformation operation again, the returned security validation is expected to be different with the last one.
            newInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(urlStr);

            var formDigestReNewed = this.sutAdapter.PostWebForm(newInfo.DigestValue, webPageUrl);

            Site.Assert.IsTrue(formDigestReNewed.Contains(Constants.PostWebFormResponse), "New digest accept");

            FormDigestInformation nullInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(null);

            string expectUrl    = currentSite.TrimEnd('/');
            string actualUrl    = nullInfo.WebFullUrl.TrimEnd('/');
            bool   isVerifyR550 = expectUrl.Equals(actualUrl, StringComparison.CurrentCultureIgnoreCase);

            #region Capture requirements
            // If the url is the current requested site, R550 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R550, the actual URL is {0}.", actualUrl);

            // Verify MS-SITESS requirement: MS-SITESS_R550
            Site.CaptureRequirementIfIsTrue(
                isVerifyR550,
                550,
                @"[In GetUpdatedFormDigestInformation] [url:] If this element is omitted altogether, the protocol server MUST return the FormDigestInformation of the current requested site (2).");
            #endregion Capture requirements

            FormDigestInformation emptyInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(urlStr);

            #region Capture requirements
            expectUrl = currentSite.TrimEnd('/');
            actualUrl = emptyInfo.WebFullUrl.TrimEnd('/');
            bool isVerifyR551 = expectUrl.Equals(actualUrl, StringComparison.CurrentCultureIgnoreCase);

            // If the url is the current requested site, R551 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R551, the actual URL is {0}.", actualUrl);

            // Verify MS-SITESS requirement: MS-SITESS_R551
            Site.CaptureRequirementIfIsTrue(
                isVerifyR551,
                551,
                @"[In GetUpdatedFormDigestInformation] [url:] If this element is included as an empty string, the protocol server MUST return the FormDigestInformation of the current requested site (2).");
            #endregion Capture requirements

            urlStr = Common.GetConfigurationPropertyValue(Constants.SiteCollectionUrl, this.Site);
            FormDigestInformation otherInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(urlStr);

            #region Capture requirements
            expectUrl = urlStr.TrimEnd('/');
            actualUrl = otherInfo.WebFullUrl.TrimEnd('/');
            bool isVerifyR405 = expectUrl.Equals(actualUrl, StringComparison.CurrentCultureIgnoreCase);

            // If the url is a requested site, R405 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R405, the actual URL is {0}.", actualUrl);

            // Verify MS-SITESS requirement: MS-SITESS_R405
            Site.CaptureRequirementIfIsTrue(
                isVerifyR405,
                405,
                @"[In GetUpdatedFormDigestInformation] [url:] Otherwise[If this element is neither omitted altogether nor included as an empty string], the protocol server MUST return the FormDigestInformation of the site that contains the page specified by this element.");

            // If code can run to here, it means that Microsoft SharePoint Foundation 2010 and above support method GetUpdatedFormDigestInformation.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R5381, Microsoft SharePoint Foundation 2010 and above support method GetUpdatedFormDigestInformation.");

            // Verify MS-SITESS requirement: MS-SITESS_R5381
            Site.CaptureRequirement(
                5381,
                @"[In Appendix B: Product Behavior] Implementation does support this method [GetUpdatedFormDigestInformation]. (Microsoft SharePoint Foundation 2010 and above follow this behavior.)");
            #endregion Capture requirements
        }