/// <summary> /// A method used to initialize the test suite. It is used in test class level initialization. /// </summary> /// <param name="testSite">A parameter represents the ITestSite instance which contain the test context information.</param> public static void InitializeTestSuite(ITestSite testSite) { if (null == testSite) { throw new ArgumentNullException("testSite"); } try { if (!TestSuiteHelper.HasInitialized) { TestSuiteHelper.InitializeHelper(testSite); } TestSuiteHelper.PerformDiscoveryProcess( currentTestClientName, wopiSutControlAdapter, testSite); } catch (Exception) { TestSuiteHelper.CleanUpDiscoveryProcess(currentTestClientName, wopiSutControlAdapter); throw; } }
public static void ClassInitialize(TestContext testContext) { TestClassBase.Initialize(testContext); // Execute the MS-WOPI initialization if (!TestSuiteHelper.VerifyRunInSupportProducts(TestSuiteBase.BaseTestSite)) { return; } TestSuiteHelper.InitializeTestSuite(TestSuiteBase.BaseTestSite); WopiAdapter = TestSuiteHelper.WOPIProtocolAdapter; SutController = TestSuiteHelper.WOPISutControladapter; WopiSutManageCodeControlAdapter = TestSuiteHelper.WOPIManagedCodeSUTControlAdapter; CurrentTestClientName = TestSuiteHelper.CurrentTestClientName; if (string.IsNullOrEmpty(UploadedFileUrl)) { UploadedFileUrl = Common.GetConfigurationPropertyValue("UploadedFileUrl", TestSuiteBase.BaseTestSite); } if (string.IsNullOrEmpty(TargetDocLibraryListName)) { TargetDocLibraryListName = Common.GetConfigurationPropertyValue("MSWOPIDocLibraryName", TestSuiteBase.BaseTestSite); } if (null == AddedFilesRecorder) { AddedFilesRecorder = new List <string>(); } }
public static void MSWOPISharedTestClassCleanup() { // Execute the MS-WOPI clean up. TestSuiteHelper.CleanUpDiscoveryProcess(CurrentTestClientName, SutController); // Execute the SharedTest class level's clean up SharedTestSuiteBase.Cleanup(); }
/// <summary> /// A method is used to verify whether test suite run in support products. If the value of "SutVersion" property in common configuration file is not included in "SupportProducts" property in "MS-WOPI_TestSuite.deployment.ptfconfig", the "MS-WOPI_Supported" SHOULDMAY property will always equal to false. And the unsupported initialization logic will not be executed in unsupported products. /// </summary> /// <param name="siteInstance">A parameter represents the site instance.</param> /// <returns>Return 'true' indicating the test suite is running in support products. The initialization logics should be performed.</returns> public static bool VerifyRunInSupportProducts(ITestSite siteInstance) { if (null == siteInstance) { throw new ArgumentNullException("siteInstance"); } TestSuiteHelper.MergeWOPIPtfConfigFiles(siteInstance); return(Common.GetConfigurationPropertyValue <bool>("MS-WOPI_Supported", siteInstance)); }
public static void ClassCleanup() { TestSuiteHelper.CleanUpDiscoveryProcess(CurrentTestClientName, SutController); string discoveryListenerLog = DiscoveryRequestListener.GetLogs(typeof(DiscoveryRequestListener)); BaseTestSite.Log.Add(LogEntryKind.Debug, discoveryListenerLog); // Clean up all the added files. DeleteCollectedFiles(AddedFilesRecorder); TestClassBase.Cleanup(); }
/// <summary> /// A method is used to check whether the SUT product supports the MS-WOPI protocol. If the SUT does not support, this method will raise an inconclusive assertion. /// </summary> /// <param name="site">A parameter represents the site.</param> public static void PerformSupportProductsCheck(ITestSite site) { TestSuiteHelper.CheckInputParameterNullOrEmpty <ITestSite>(site, "siteInstance", "PerformSupportProductsCheck"); if (!hasCheckSupportWOPI) { isCurrentSUTSupportWOPI = Common.GetConfigurationPropertyValue <bool>("MS-WOPI_Supported", site); hasCheckSupportWOPI = true; } if (!isCurrentSUTSupportWOPI) { SutVersion currentSutVersion = Common.GetConfigurationPropertyValue <SutVersion>("SutVersion", site); site.Assume.Inconclusive(@"The server does not support this specification [MS-WOPI]. It is determined by ""MS-WOPI_Supported"" SHOULDMAY property of the [{0}_{1}_SHOULDMAY.deployment.ptfconfig] configuration file.", WopiProtocolShortName, currentSutVersion); } }
public static void MSWOPISharedTestClassInitialize(TestContext testContext) { // Execute the MS-FSSHTTP test cases' initialization SharedTestSuiteBase.Initialize(testContext); // Execute the MS-WOPI initialization if (!TestSuiteHelper.VerifyRunInSupportProducts(MS_WOPI_S14_AllocateExtendedGuidRange.BaseTestSite)) { return; } TestSuiteHelper.InitializeTestSuite(MS_WOPI_S14_AllocateExtendedGuidRange.BaseTestSite); SutController = TestSuiteHelper.WOPISutControladapter; WopiSutManageCodeControlAdapter = TestSuiteHelper.WOPIManagedCodeSUTControlAdapter; CurrentTestClientName = TestSuiteHelper.CurrentTestClientName; }
/// <summary> /// This method is used to merge the configuration of the WOPI and FSSHTTP. /// </summary> /// <param name="site">A parameter represents the site.</param> protected override void MergeConfigurationFile(ITestSite site) { // Merge configuration for share test case. TestSuiteHelper.MergeConfigurationFileForShare(this.Site); }
/// <summary> /// This method is used to get WOPI token and add headers. /// </summary> /// <param name="requestFileUrl">A parameter represents the file URL.</param> /// <param name="userName">A parameter represents the user name we used.</param> /// <param name="password">A parameter represents the password of the user.</param> /// <param name="domain">A parameter represents the domain.</param> protected override void InitializeContext(string requestFileUrl, string userName, string password, string domain) { // Get WOPI token and add headers for the file exists. TestSuiteHelper.InitializeContextForShare(requestFileUrl, userName, password, domain, CellStoreOperationType.NormalCellStore, this.Site); }
public void TestCaseLevelInitializeMethod() { TestSuiteHelper.PerformSupportProductsCheck(this.Site); TestSuiteHelper.PerformSupportCobaltCheck(this.Site); }
/// <summary> /// A method used to delete collected files. If a collected file URL is not a valid file URL, this method will ignore it. If not all the valid file URLs are processed successfully, this method will raise an InvalidOperationException. /// </summary> /// <param name="collectedFiles">A parameter represents the collected file URLs.</param> private static void DeleteCollectedFiles(List <string> collectedFiles) { if (null == collectedFiles || 0 == collectedFiles.Count) { BaseTestSite.Log.Add(LogEntryKind.Debug, "There are no added files, skip the delete process."); return; } StringBuilder invalidUrlRecorder = new StringBuilder(); StringBuilder validUrlRecorder = new StringBuilder(); StringBuilder logsForValidUrlRecorder = new StringBuilder(); foreach (string fileUrlItem in collectedFiles) { if (string.IsNullOrEmpty(fileUrlItem)) { continue; } string errorMsg; if (!TryVerifyFileUrl(fileUrlItem, out errorMsg)) { invalidUrlRecorder.AppendLine(string.Format(@"Invalid file URL:[{0}], Error:[{1}]", fileUrlItem, errorMsg)); continue; } // Construct the SUT controller input parameter. validUrlRecorder.Append(fileUrlItem + ","); // Log the files the test suite plan to delete. string fileName = TestSuiteHelper.GetFileNameFromFullUrl(fileUrlItem); logsForValidUrlRecorder.AppendLine(string.Format(@"File name:[{0}] File URL:[{1}]", fileName, fileUrlItem)); } if (invalidUrlRecorder.Length != 0) { BaseTestSite.Log.Add( LogEntryKind.Debug, "There are some invalid URLs for collected files, test suite will skip these file URLs:\r\n{0}", invalidUrlRecorder.ToString()); } BaseTestSite.Log.Add( LogEntryKind.Debug, "Test suite prepare to delete these collected files:\r\n{0}", logsForValidUrlRecorder.ToString()); // Call SUT controller method to delete files. string uploadedfilesUrls = validUrlRecorder.ToString(0, validUrlRecorder.Length - 1); bool areFilesDeletedSuccessful = false; try { areFilesDeletedSuccessful = SutController.DeleteUploadedFilesOnSUT(TargetDocLibraryListName, uploadedfilesUrls); } finally { AddedFilesRecorder.Clear(); } if (!areFilesDeletedSuccessful) { throw new InvalidOperationException("Not all the collected files are deleted successfully."); } }
public void MSWOPITestCaseInitialize() { this.InitializeCounterForPerTestCase(); TestSuiteHelper.PerformSupportProductsCheck(this.Site); }
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."); }
/// <summary> /// This method is used to initialize the share test case helper. This method will also initialize all helpers which are required to initialize during test suite running. /// </summary> /// <param name="siteInstance">A parameter represents the ITestSite instance.</param> public static void InitializeHelper(ITestSite siteInstance) { TestSuiteHelper.CheckInputParameterNullOrEmpty <ITestSite>(siteInstance, "siteInstance", "InitializeHelper"); if (string.IsNullOrEmpty(currentTestClientName)) { currentTestClientName = Common.GetConfigurationPropertyValue("TestClientName", siteInstance); } if (null == wopiSutControlAdapter) { wopiSutControlAdapter = siteInstance.GetAdapter <IMS_WOPISUTControlAdapter>(); } if (null == wopiSutManagedCodeControlAdapter) { wopiSutManagedCodeControlAdapter = siteInstance.GetAdapter <IMS_WOPIManagedCodeSUTControlAdapter>(); } if (null == wopiProtocolAdapter) { wopiProtocolAdapter = siteInstance.GetAdapter <IMS_WOPIAdapter>(); } InitializeRequiredHelpers(wopiSutManagedCodeControlAdapter, siteInstance); if (string.IsNullOrEmpty(relativeSourceFileUrl)) { relativeSourceFileUrl = Common.GetConfigurationPropertyValue("NormalFile", siteInstance); } progId = Common.GetConfigurationPropertyValue("ProgIdForDiscoveryProcess", siteInstance); // Setting the endpoint name according to the current http transport. if (string.IsNullOrEmpty(currentSharedTestCasesEndpointName)) { TransportProtocol currentTransport = Common.GetConfigurationPropertyValue <TransportProtocol>("TransportType", siteInstance); switch (currentTransport) { case TransportProtocol.HTTP: { currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTP", siteInstance); break; } case TransportProtocol.HTTPS: { currentSharedTestCasesEndpointName = Common.GetConfigurationPropertyValue("SharedTestCaseEndPointNameForHTTPS", siteInstance); break; } default: { throw new InvalidOperationException(string.Format("The test suite only support HTTP or HTTPS transport. Current:[{0}]", currentTransport)); } } } // Set the protocol name of current test suite siteInstance.DefaultProtocolDocShortName = WopiProtocolShortName; hasInitializedHelperStatus = true; }