public override IEnumerator <WebTestRequest> GetRequestEnumerator() { var defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields(); // Do initial login var logonGet = AssertAndValidationHelper.GetLogonGetRequest(); yield return(logonGet); var logonPost = AssertAndValidationHelper.GetLogonPostRequest(this); yield return(logonPost); var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest); var packageId = $"UploadPackageFromUI.{DateTimeOffset.UtcNow.Ticks}"; var packageCreationHelper = new PackageCreationHelper(); var packageFullPath = packageCreationHelper.CreatePackage(packageId).Result; var uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath); yield return(uploadPostRequest); //This second get request to upload is to put us on the new "Verify Page" // which is just the upload page in a different state. // This is to get the RequestVerificationToken for the folloing request. (upload and verify were merged onto the same page). var uploadRequest2 = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest2); var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.GetPackagePageUrl(packageId, "1.0.0"), packageId); yield return(verifyUploadPostRequest); }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { ExtractHiddenFields defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields(); //Do initial login WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest(); yield return(logonGet); logonGet = null; WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this); yield return(logonPost); logonPost = null; WebTestRequest uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest); if (this.LastResponse.ResponseUri.ToString().Contains("verify-upload")) { WebTestRequest cancelGet = AssertAndValidationHelper.GetCancelGetRequest(); yield return(cancelGet); cancelGet = null; uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest); } uploadRequest = null; //Upload a new package. string packageId = this.Name + DateTime.Now.Ticks.ToString(); string version = "1.0.0"; string minClientVersion = "2.3"; string packageFullPath = PackageCreationHelper.CreatePackage(packageId, version, minClientVersion); WebTestRequest uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath); yield return(uploadPostRequest); uploadPostRequest = null; WebTestRequest verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl); verifyUploadRequest.ExtractValues += new EventHandler <ExtractionEventArgs>(defaultExtractionRule.Extract); yield return(verifyUploadRequest); verifyUploadRequest = null; WebTestRequest verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.GetPackagePageUrl(packageId, "1.0.0"), packageId); yield return(verifyUploadPostRequest); verifyUploadPostRequest = null; }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { //run this test only if read-only mode is set. This is to avoid false failures while doing Run all tests locally. if (!EnvironmentSettings.ReadOnlyMode.Equals("True", StringComparison.OrdinalIgnoreCase)) { yield break; } var defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields(); // Do initial login var logonGet = AssertAndValidationHelper.GetLogonGetRequest(); yield return(logonGet); var logonPost = AssertAndValidationHelper.GetLogonPostRequest(this); yield return(logonPost); var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest); if (LastResponse.ResponseUri.ToString().Contains("verify-upload")) { // if there is a upload in progress, try to submit that upload instead of creating a new package (since we are just going to verify that upload doesn't go through). //Extract the package Id of the pending upload. var response = LastResponse.BodyString; var startIndex = response.IndexOf("<p>", StringComparison.Ordinal); var endIndex = response.IndexOf("</p>", startIndex, StringComparison.Ordinal); var packageId = response.Substring(startIndex + 3, endIndex - (startIndex + 3)); AddCommentToResult(packageId); //Adding the package ID to result for debugging. var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503); yield return(verifyUploadPostRequest); } else { // The API key is part of the nuget.config file that is present under the solution dir. var packageId = DateTime.Now.Ticks.ToString(); var packageCreationHelper = new PackageCreationHelper(); var packageFullPath = packageCreationHelper.CreatePackage(packageId).Result; var uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath); yield return(uploadPostRequest); var verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl); verifyUploadRequest.ExtractValues += defaultExtractionRule.Extract; yield return(verifyUploadRequest); var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503); yield return(verifyUploadPostRequest); } }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { // Temporary workaround for the SSL issue, which keeps the upload test from working with cloudapp.net sites if (!UrlHelper.BaseUrl.Contains("nugettest.org") && !UrlHelper.BaseUrl.Contains("nuget.org")) { yield break; } var defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields(); // Do initial login var logonGet = AssertAndValidationHelper.GetLogonGetRequest(); yield return(logonGet); var logonPost = AssertAndValidationHelper.GetLogonPostRequest(this); yield return(logonPost); var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest); if (LastResponse.ResponseUri.ToString().Contains("verify-upload")) { // If there is a upload in progress, try to submit that upload instead of creating a new package (since we are just going to verify that upload goes through UI). // Extract the package Id of the pending upload. var response = LastResponse.BodyString; var startIndex = response.IndexOf("<p>", StringComparison.Ordinal); var endIndex = response.IndexOf("</p>", startIndex, StringComparison.Ordinal); var packageId = response.Substring(startIndex + 3, endIndex - (startIndex + 3)); AddCommentToResult(packageId); //Adding the package ID to result for debugging. var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503); yield return(verifyUploadPostRequest); } else { // The API key is part of the nuget.config file that is present under the solution dir. var packageId = DateTime.Now.Ticks.ToString(); var packageCreationHelper = new PackageCreationHelper(); var packageFullPath = packageCreationHelper.CreatePackage(packageId).Result; var uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath); yield return(uploadPostRequest); var verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl); verifyUploadRequest.ExtractValues += defaultExtractionRule.Extract; yield return(verifyUploadRequest); var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.GetPackagePageUrl(packageId, "1.0.0"), packageId); yield return(verifyUploadPostRequest); } }
public override IEnumerator<WebTestRequest> GetRequestEnumerator() { ExtractHiddenFields defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields(); //Do initial login WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest(); yield return logonGet; logonGet = null; WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this); yield return logonPost; logonPost = null; WebTestRequest uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return uploadRequest; uploadRequest = null; string packageId = DateTime.Now.Ticks.ToString(); string packageFullPath = PackageCreationHelper.CreatePackage(packageId); WebTestRequest uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath); yield return uploadPostRequest; uploadPostRequest = null; WebTestRequest verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0"); yield return verifyUploadPostRequest; verifyUploadPostRequest = null; System.Threading.Thread.Sleep(60000); WebTestRequest packageRequest = new WebTestRequest(UrlHelper.GetPackagePageUrl(packageId)); ValidationRuleFindText findTextRule = AssertAndValidationHelper.GetValidationRuleForFindText("Contact Us"); packageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(findTextRule.Validate); yield return packageRequest; packageRequest = null; // Log off WebTestRequest logOffGet = AssertAndValidationHelper.GetLogOffGetRequest(); yield return logOffGet; logOffGet = null; packageRequest = new WebTestRequest(UrlHelper.GetPackagePageUrl(packageId)); //Rule to check manage my packages contains a html link to the newly uploaded package. ValidationRuleFindText reportAbuseValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText("Report Abuse"); packageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(reportAbuseValidationRule.Validate); yield return packageRequest; packageRequest = null; }