private static IEnumerable <WebTestRequest> UploadPackage(WebTest test, PackageToUploadInternal packageToUpload) { var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest); var uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(test, packageToUpload.FullPath); 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 following request. (upload and verify were merged onto the same page). var uploadRequest2 = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest2); var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(test, packageToUpload.Id, packageToUpload.Version, UrlHelper.GetPackagePageUrl(packageToUpload.Id, packageToUpload.Version), packageToUpload.Id, packageToUpload.Owner); yield return(verifyUploadPostRequest); }
/// <summary> /// Returns the POST WebRequest for logon with appropriate form parameters set. /// Individual WebTests can use this. /// </summary> /// <returns></returns> public static WebTestRequest GetVerifyPackagePostRequestForPackage(WebTest test, string packageId, string packageVersion, string expectedResponseUrl, string expectedText, int expectedResponseCode = 200) { WebTestRequest verifyUploadPostRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl); verifyUploadPostRequest.Method = "POST"; verifyUploadPostRequest.ExpectedHttpStatusCode = expectedResponseCode; verifyUploadPostRequest.ExpectedResponseUrl = expectedResponseUrl; FormPostHttpBody verifyUploadPostRequestBody = new FormPostHttpBody(); verifyUploadPostRequestBody.FormPostParameters.Add("__RequestVerificationToken", test.Context["$HIDDEN1.__RequestVerificationToken"].ToString()); verifyUploadPostRequestBody.FormPostParameters.Add("Id", packageId); verifyUploadPostRequestBody.FormPostParameters.Add("Version", packageVersion); verifyUploadPostRequestBody.FormPostParameters.Add("LicenseUrl", ""); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.VersionTitle", ""); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.Description", "Package description"); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.Summary", ""); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.IconUrl", ""); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.ProjectUrl", ""); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.Authors", "bhuvak"); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.CopyrightText", "Copyright 2013"); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.Tags", " windows8 "); verifyUploadPostRequestBody.FormPostParameters.Add("Edit.ReleaseNotes", ""); verifyUploadPostRequest.Body = verifyUploadPostRequestBody; ValidationRuleFindText postUploadText = AssertAndValidationHelper.GetValidationRuleForFindText(expectedText); verifyUploadPostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(postUploadText.Validate); return(verifyUploadPostRequest); }
private static IEnumerable <WebTestRequest> UploadPackage(WebTest test, PackageToUploadInternal packageToUpload) { // Navigate to the upload page. var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest); // Cancel any pending uploads. // We can't upload the new package if any uploads are pending. var cancelUploadPostRequest = AssertAndValidationHelper.GetCancelUploadPostRequestForPackage(test); yield return(cancelUploadPostRequest); // Upload the new package. var uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(test, packageToUpload.FullPath); yield return(uploadPostRequest); // Verify the new package. var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(test, packageToUpload.Id, packageToUpload.Version, UrlHelper.GetPackagePageUrl(packageToUpload.Id, packageToUpload.Version), packageToUpload.Id, packageToUpload.Owner); yield return(verifyUploadPostRequest); }
/// <summary> /// Returns a WebRequest for the given Url. /// </summary> /// <param name="url"></param> /// <returns></returns> public static WebTestRequest GetHttpRequestForUrl(string url) { WebTestRequest getRequest = new WebTestRequest(url); ExtractHiddenFields extractionRule1 = AssertAndValidationHelper.GetDefaultExtractHiddenFields(); getRequest.ExtractValues += new EventHandler <ExtractionEventArgs>(extractionRule1.Extract); return(getRequest); }
private static IEnumerable <WebTestRequest> Login(WebTest test) { var defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields(); // Do initial login var logonGet = AssertAndValidationHelper.GetLogonGetRequest(); yield return(logonGet); var logonPost = AssertAndValidationHelper.GetLogonPostRequest(test); yield return(logonPost); }