public void MSSITESS_S03_TC01_GetUpdatedFormDigest()
{
Site.Assume.IsTrue(Common.IsRequirementEnabled(5361, this.Site), @"Test is executed only when R5361Enabled is set to true.");
#region Variables
string currentFormDigest = string.Empty;
string newFormDigest = string.Empty;
int formDigestTimeout = int.Parse(Common.GetConfigurationPropertyValue(Constants.ExpireTimePeriodBySecond, this.Site));
string formDigestValid = null;
string formDigestExpired = null;
string formDigestReNewed = null;
string webPageUrl = Common.GetConfigurationPropertyValue(Constants.WebPageUrl, this.Site);
#endregion Variables
// Initialize the web service with an authenticated account.
this.sitessAdapter.InitializeWebService(UserAuthenticationOption.Authenticated);
// Invoke the GetUpdatedFormDigest operation.
currentFormDigest = this.sitessAdapter.GetUpdatedFormDigest();
formDigestValid = this.sutAdapter.PostWebForm(currentFormDigest, webPageUrl);
Site.Assert.IsTrue(formDigestValid.Contains(Constants.PostWebFormResponse), "digest accept");
// 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);
formDigestExpired = this.sutAdapter.PostWebForm(currentFormDigest, webPageUrl);
if (Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointFoundation2013 ||
Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointServer2013 ||
Common.GetConfigurationPropertyValue(Constants.SutVersion,this.Site) == Constants.SharePointServer2016)
{
Site.Assert.IsTrue(formDigestExpired.Contains(Constants.TimeOutInformationForSP2013AndSP2016), "digest expired");
}
else
{
Site.Assert.IsTrue(formDigestExpired.Contains(Constants.TimeOutInformationForSP2007AndSP2010), "digest expired");
}
// Invoke the GetUpdatedFormDigest operation again, the returned security validation is expected to be different with the last one.
newFormDigest = this.sitessAdapter.GetUpdatedFormDigest();
formDigestReNewed = this.sutAdapter.PostWebForm(newFormDigest, webPageUrl);
Site.Assert.IsTrue(formDigestReNewed.Contains(Constants.PostWebFormResponse), "New digest accept");
#region Capture requirements
// If the validation token changed, the following requirement can be captured.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R192");
// Verify MS-SITESS requirement: MS-SITESS_R192
Site.CaptureRequirementIfAreNotEqual<string>(
currentFormDigest,
newFormDigest,
192,
@"[In GetUpdatedFormDigest] In this case [when the client request an updated security validation] the server MUST return a new security validation to the client.");
// If code can run to here, it means that Microsoft Windows SharePoint Services 3.0 and above support method GetUpdatedFormDigest.
Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R5361, Microsoft Windows SharePoint Services 3.0 and above support method GetUpdatedFormDigest.");
// Verify MS-SITESS requirement: MS-SITESS_R5361
Site.CaptureRequirement(
5361,
@"[In Appendix B: Product Behavior] <9> Section 3.1.4.6: Implementation does support this operation [GetUpdatedFormDigest].(Windows SharePoint Services 3.0 and above follow this behavior.)");
#endregion Capture requirements
}