예제 #1
0
        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))
            {
                WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);
                yield return(registerPageRequest);

                registerPageRequest = null;

                WebTestRequest registerPagePostRequest = new WebTestRequest(UrlHelper.RegisterPageUrl);
                registerPagePostRequest.Method = "POST";
                registerPagePostRequest.ExpectedResponseUrl = UrlHelper.RegistrationPendingPageUrl;
                //create a form and set the UserName, Email and password as form post parameters.
                //We just need to set some unique user name and Email.
                FormPostHttpBody registerNewUserFormPost = new FormPostHttpBody();
                registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
                registerNewUserFormPost.FormPostParameters.Add("LinkingAccount", "false");
                registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks.ToString() + "@live.com"); //add a dummy mail account. This will be fixed once we incorporate the logic to delete user.
                registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, DateTime.Now.Ticks.ToString() + "NewAccount");
                registerNewUserFormPost.FormPostParameters.Add(Constants.RegisterPasswordFormField, "xxxxxxxx");
                registerPagePostRequest.Body = registerNewUserFormPost;
                registerPagePostRequest.ExpectedHttpStatusCode = 503;
                //Validate the response to make sure that it shows the error message for read-only mode.
                ValidationRuleFindText ReadOnlyModeTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.ReadOnlyModeError);
                registerPagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(ReadOnlyModeTextRule.Validate);
                yield return(registerPagePostRequest);

                registerPagePostRequest = null;
            }
        }
예제 #2
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.RegisterPageUrl);

            yield return(registerPageRequest);

            registerPageRequest = null;

            WebTestRequest registerPagePostRequest = new WebTestRequest(UrlHelper.RegisterPageUrl);

            registerPagePostRequest.Method = "POST";
            registerPagePostRequest.ExpectedResponseUrl = UrlHelper.RegisterPageUrl; // the same page will be the response url.
            //create a form and set the UserName, Email and password as form post parameters.
            //We just need to set some unique user name and Email.
            FormPostHttpBody registerNewUserFormPost = new FormPostHttpBody();

            registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks.ToString() + "@gmail.com");
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, DateTime.Now.Ticks.ToString());
            registerNewUserFormPost.FormPostParameters.Add(Constants.PasswordFormField, "1qq1qq1qq");
            registerNewUserFormPost.FormPostParameters.Add(Constants.ConfirmPasswordFormField, "1qq1qq1qq");
            registerPagePostRequest.Body = registerNewUserFormPost;
            //Validate the response to make sure that it has the pending confirmation text in it.
            ValidationRuleFindText PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.ReadOnlyModeRegisterNewUserText);

            registerPagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(PendingConfirmationTextRule.Validate);
            yield return(registerPagePostRequest);

            registerPagePostRequest = null;
        }
예제 #3
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);

            yield return(registerPageRequest);

            registerPageRequest = null;

            WebTestRequest registerPagePostRequest = new WebTestRequest(UrlHelper.RegisterPageUrl);

            registerPagePostRequest.Method = "POST";
            registerPagePostRequest.ExpectedResponseUrl = UrlHelper.RegistrationPendingPageUrl;
            //create a form and set the UserName, Email and password as form post parameters.
            //We just need to set some unique user name and Email.
            FormPostHttpBody registerNewUserFormPost = new FormPostHttpBody();

            registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add("LinkingAccount", "false");
            registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks.ToString() + "@live.com"); //add a dummy mail account. This will be fixed once we incorporate the logic to delete user.
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, DateTime.Now.Ticks.ToString() + "NewAccount");
            registerNewUserFormPost.FormPostParameters.Add(Constants.RegisterPasswordFormField, "xxxxxxxx");
            registerPagePostRequest.Body = registerNewUserFormPost;
            //Validate the response to make sure that it has the pending confirmation text in it.
            ValidationRuleFindText PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserPendingConfirmationText);

            registerPagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(PendingConfirmationTextRule.Validate);
            yield return(registerPagePostRequest);

            registerPagePostRequest = null;
        }
예제 #4
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //Do initial login
            WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest();

            yield return(logonGet);

            logonGet = null;

            WebTestRequest           logonPostRequest = AssertAndValidationHelper.GetLogonPostRequest(this);
            ValidateHtmlTagInnerText loggedOnUserNameValidationRule;

            if (UrlHelper.BaseUrl.Contains("qa.nugettest.org"))
            {
                loggedOnUserNameValidationRule = AssertAndValidationHelper.GetValidationRuleForHtmlTagInnerText(HtmlTextWriterTag.A.ToString(), HtmlTextWriterAttribute.Href.ToString(), "/account", "TestNuGetAccount");
            }
            else
            {
                loggedOnUserNameValidationRule = AssertAndValidationHelper.GetValidationRuleForHtmlTagInnerText(HtmlTextWriterTag.A.ToString(), HtmlTextWriterAttribute.Href.ToString(), "/account", "NugetTestAccount");
            }
            logonPostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(loggedOnUserNameValidationRule.Validate);

            yield return(logonPostRequest);

            logonPostRequest = null;
        }
예제 #5
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);

            yield return(registerPageRequest);

            registerPageRequest = null;

            WebTestRequest registerPagePostRequest = new WebTestRequest(UrlHelper.SignInPageUrl);

            registerPagePostRequest.Method = "POST";
            registerPagePostRequest.ExpectedResponseUrl = UrlHelper.SignInPageUrl;
            //create a form and set the UserName, Email and password as form post parameters.
            //We just need to set some unique user name and Email.
            FormPostHttpBody registerNewUserFormPost = new FormPostHttpBody();

            registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add("ReturnUrl", "/");
            registerNewUserFormPost.FormPostParameters.Add("LinkingAccount", "false");
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameOrEmailFormField, DateTime.Now.Ticks.ToString() + "@live.com");
            registerNewUserFormPost.FormPostParameters.Add(Constants.PasswordFormField, EnvironmentSettings.TestAccountPassword);

            registerPagePostRequest.Body = registerNewUserFormPost;
            //Validate the response to make sure that it doesn't have the pending confirmation text in it.
            ValidationRuleFindText PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserPendingConfirmationText, false);

            registerPagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(PendingConfirmationTextRule.Validate);
            yield return(registerPagePostRequest);

            registerPagePostRequest = null;
        }
        /// <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);
        }
예제 #7
0
        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;

            // The API key is part of the nuget.config file that is present under the solution dir.
            string packageId       = DateTime.Now.Ticks.ToString();
            string packageFullPath = PackageCreationHelper.CreatePackage(packageId);

            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");

            yield return(verifyUploadPostRequest);

            verifyUploadPostRequest = null;
        }
예제 #8
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //send a request to home page and check for default home page text.
            WebTestRequest         homePageRequest            = new WebTestRequest(UrlHelper.BaseUrl);
            ValidationRuleFindText homePageTextValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.HomePageText);

            homePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(homePageTextValidationRule.Validate);
            yield return(homePageRequest);

            homePageRequest = null;
        }
예제 #9
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest uploadPackageRequest = new WebTestRequest(UrlHelper.UploadPageUrl);

            uploadPackageRequest.ExpectedResponseUrl = UrlHelper.LogonPageUrlOnPackageUpload;
            ValidateHtmlTagInnerText logOnFormValidationRule = AssertAndValidationHelper.GetValidationRuleForHtmlTagInnerText(HtmlTextWriterTag.Label.ToString(), HtmlTextWriterAttribute.For.ToString(), "SignIn_UserNameOrEmail", "Username or Email");

            uploadPackageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(logOnFormValidationRule.Validate);
            yield return(uploadPackageRequest);

            uploadPackageRequest = null;
        }
예제 #10
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //Upload a new package.
            string packageId = this.Name + DateTime.Now.Ticks.ToString();
            string version   = "1.0.0";

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, version);

            //Do initial login to be able to perform delete ops.
            WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest();

            yield return(logonGet);

            logonGet = null;
            WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);

            yield return(logonPost);

            logonPost = null;

            string deletePackagePageUrl = UrlHelper.GetPackageDeletePageUrl(packageId, version);


            WebTestRequest deletePackageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(deletePackagePageUrl);

            yield return(deletePackageRequest);

            deletePackageRequest = null;

            WebTestRequest deletePackagePagePostRequest = new WebTestRequest(deletePackagePageUrl);

            deletePackagePagePostRequest.Method = "POST";
            //once the listing is done, it should return back to the packages page.
            deletePackagePagePostRequest.ExpectedResponseUrl = UrlHelper.GetPackagePageUrl(packageId, version);
            FormPostHttpBody deletePackagePostRequestForm = new FormPostHttpBody();

            deletePackagePostRequestForm.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            deletePackagePostRequestForm.FormPostParameters.Add("Listed", this.Context["$HIDDEN1.Listed"].ToString());
            deletePackagePagePostRequest.Body = deletePackagePostRequestForm;

            //Make sure that the package page shows the message saying that it has been unlisted.
            ValidationRuleFindText findTextRule = new ValidationRuleFindText();

            findTextRule.FindText = Constants.UnListedPackageText;
            deletePackagePagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(findTextRule.Validate);
            yield return(deletePackagePagePostRequest);

            deletePackagePagePostRequest = null;

            //check if it shows up in search and cross check with client SDK.
            Assert.IsTrue(ClientSDKHelper.IsPackageVersionUnListed(packageId, version), "Package not returned as unlisted by Nuget core after unlisting it in gallery");
        }
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.RegisterPageUrl);

            yield return(registerPageRequest);

            registerPageRequest = null;

            WebTestRequest registerPagePostRequest = new WebTestRequest(UrlHelper.RegisterPageUrl);

            //create a form and set the UserName, Email and password as form post parameters.
            //We just need to set some unique user name and Email.
            registerPagePostRequest.Method = "POST";
            registerPagePostRequest.ExpectedResponseUrl = UrlHelper.RegistrationPendingPageUrl;
            FormPostHttpBody registerNewUserFormPost = new FormPostHttpBody();

            registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks.ToString() + "@live.com");
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, EnvironmentSettings.TestAccountName);  // This account already exists; we expect this to fail.
            registerNewUserFormPost.FormPostParameters.Add(Constants.PasswordFormField, "xxxxxxx");
            registerNewUserFormPost.FormPostParameters.Add(Constants.ConfirmPasswordFormField, "xxxxxxx");
            registerPagePostRequest.Body = registerNewUserFormPost;
            //Validate the response to make sure that it has the pending confirmation text in it.
            ValidationRuleFindText PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserPendingConfirmationText, false);

            registerPagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(PendingConfirmationTextRule.Validate);
            yield return(registerPagePostRequest);

            registerPagePostRequest = null;

            registerPagePostRequest        = new WebTestRequest(UrlHelper.RegisterPageUrl);
            registerPagePostRequest.Method = "POST";
            registerPagePostRequest.ExpectedResponseUrl = UrlHelper.RegistrationPendingPageUrl;
            registerNewUserFormPost = new FormPostHttpBody();
            registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks.ToString() + "@live.com");
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, Convert.ToChar(4).ToString());  // This is an invalid username; we expect this to fail, too.
            registerNewUserFormPost.FormPostParameters.Add(Constants.PasswordFormField, "xxxxxxx");
            registerNewUserFormPost.FormPostParameters.Add(Constants.ConfirmPasswordFormField, "xxxxxxx");
            registerPagePostRequest.Body = registerNewUserFormPost;
            //Validate the response to make sure that it lacks the pending confirmation text.
            PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserPendingConfirmationText, false);
            registerPagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(PendingConfirmationTextRule.Validate);
            //Validate the error is handled.  We should end up on the same page again.
            ValidationRuleFindText ErrorHandledTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.CreateNewAccountText);

            registerPagePostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(ErrorHandledTextRule.Validate);
            yield return(registerPagePostRequest);

            registerPagePostRequest = null;
        }
예제 #12
0
        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))
            {
                //Do initial login to be able to perform package management.
                WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest();
                yield return(logonGet);

                logonGet = null;
                WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);
                yield return(logonPost);

                logonPost = null;

                WebTestRequest      accountPageRequest = new WebTestRequest(UrlHelper.AccountPageUrl);
                ExtractHiddenFields extractionRule1    = AssertAndValidationHelper.GetDefaultExtractHiddenFields();
                accountPageRequest.ExtractValues += new EventHandler <ExtractionEventArgs>(extractionRule1.Extract);
                yield return(accountPageRequest);

                accountPageRequest = null;

                WebTestRequest unsubscribeRequest = new WebTestRequest(UrlHelper.AccountUnscribeUrl);
                unsubscribeRequest.Method = "POST";
                unsubscribeRequest.ExpectedHttpStatusCode = 503;
                FormPostHttpBody unsubscribeRequestBody = new FormPostHttpBody();
                unsubscribeRequestBody.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
                unsubscribeRequest.Body = unsubscribeRequestBody;
                //check for read-only status.
                ValidationRuleFindText readonlyValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.ReadOnlyModeError);
                unsubscribeRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(readonlyValidationRule.Validate);
                yield return(unsubscribeRequest);

                unsubscribeRequest = null;

                WebTestRequest resetApiKeyRequest = new WebTestRequest(UrlHelper.AccountApiKeyResetUrl);
                resetApiKeyRequest.Method = "POST";
                resetApiKeyRequest.ExpectedHttpStatusCode = 503;
                FormPostHttpBody resetApiKeyRequestBody = new FormPostHttpBody();
                resetApiKeyRequestBody.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
                resetApiKeyRequest.Body = resetApiKeyRequestBody;
                //Check for read-only error
                resetApiKeyRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(readonlyValidationRule.Validate);
                yield return(resetApiKeyRequest);

                resetApiKeyRequest = null;
            }
        }
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //send a request to home page and check for default home page text.
            WebTestRequest         pageRequest = new WebTestRequest(UrlHelper.BaseUrl);
            ValidationRuleFindText homePageTextValidationRuleLogo      = AssertAndValidationHelper.GetValidationRuleForFindText(@"<a href=""http://outercurve.org""><img src=""/Content/Logos/outercurve.png"" alt=""Outercurve Foundation"" /></a>");
            ValidationRuleFindText homePageTextValidationRuleCopyright = AssertAndValidationHelper.GetValidationRuleForFindText(@"&copy; 2014 Outercurve Foundation");
            ValidationRuleFindText homePageTextValidationRuleTOU       = AssertAndValidationHelper.GetValidationRuleForFindText(@"<a href=""/policies/Terms"">Terms of Use</a>");
            ValidationRuleFindText homePageTextValidationRulePrivacy   = AssertAndValidationHelper.GetValidationRuleForFindText(@"<a href=""/policies/Privacy"">Privacy Policy</a>");

            pageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(homePageTextValidationRuleLogo.Validate);
            pageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(homePageTextValidationRuleCopyright.Validate);
            pageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(homePageTextValidationRuleTOU.Validate);
            pageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(homePageTextValidationRulePrivacy.Validate);
            yield return(pageRequest);

            pageRequest = null;
        }
예제 #14
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //send a request to the stats/totals to get the initial count.
            WebTestRequest statsRequestBeforeDownload = GetWebRequestForAggregateStats();

            yield return(statsRequestBeforeDownload);

            statsRequestBeforeDownload = null;

            int aggregateStatsBeforeDownload = GetAggregateStatsFromContext();

            //upload a new package and download it.
            string packageId = DateTime.Now.Ticks.ToString() + this.Name;

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId);
            AssertAndValidationHelper.DownloadPackageAndVerify(packageId);

            //wait either the download count changes or till 5 minutes which ever is earlier.
            int waittime = 0;
            int aggregateStatsAfterDownload = aggregateStatsBeforeDownload;

            while (aggregateStatsAfterDownload == aggregateStatsBeforeDownload && waittime <= 300)
            {
                //send a request stats to keep polling the new download count.
                statsRequestBeforeDownload = GetWebRequestForAggregateStats();
                yield return(statsRequestBeforeDownload);

                statsRequestBeforeDownload = null;

                aggregateStatsAfterDownload = GetAggregateStatsFromContext();
                System.Threading.Thread.Sleep(30 * 1000);//sleep for 30 seconds.
                waittime += 30;
            }

            //send a request to home page and check aggregate stats numbers.
            WebTestRequest         pageRequest = new WebTestRequest(UrlHelper.BaseUrl);
            ValidationRuleFindText homePageTextValidationRuleAggStats = AssertAndValidationHelper.GetValidationRuleForFindText(aggregateStatsAfterDownload.ToString("N0"));

            pageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(homePageTextValidationRuleAggStats.Validate);
            yield return(pageRequest);

            pageRequest = null;

            //check download count. New download count should be old one + 1.
            Assert.IsTrue(aggregateStatsBeforeDownload < aggregateStatsAfterDownload, "Aggregate stats count is not increased by 1 after downloading. Aggregate stats before download :{0}. Stats after download : {1}", aggregateStatsBeforeDownload, aggregateStatsAfterDownload);
        }
예제 #15
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest statsPageRequest = new WebTestRequest(UrlHelper.StatsPageUrl);

            //Checks for the prescene of a link to jqeury package. It is harded to Jquery for now as there is no API exposed for stats
            //and also Jquery is going to be one of the top 10 for now.
            ValidateHtmlTagInnerText jQueryPackageValidationRule = AssertAndValidationHelper.GetValidationRuleForHtmlTagInnerText(HtmlTextWriterTag.A.ToString(), HtmlTextWriterAttribute.Href.ToString(), "/packages/jQuery/", "jQuery");

            statsPageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(jQueryPackageValidationRule.Validate);
            //validation rule to check for the default text in stats page.
            ValidationRuleFindText StatsPageDefaultTextValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.StatsPageDefaultText);

            statsPageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(StatsPageDefaultTextValidationRule.Validate);

            yield return(statsPageRequest);

            statsPageRequest = null;
        }
예제 #16
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //Use a predefined test package.
            string         packageId          = Constants.TestPackageId;
            WebTestRequest packagePageRequest = new WebTestRequest(UrlHelper.BaseUrl + @"/Packages/" + packageId);

            //Rule to check if the title contains the package id and the latest stable version of the package.
            ValidationRuleFindText packageTitleValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(packageId + " " + ClientSDKHelper.GetLatestStableVersion(packageId));

            packagePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(packageTitleValidationRule.Validate);
            //rule to check that the download count is present in the response.
            ValidationRuleFindText downloadCountValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(ClientSDKHelper.GetFormattedDownLoadStatistics(packageId));

            packagePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(downloadCountValidationRule.Validate);

            yield return(packagePageRequest);

            packagePageRequest = null;
        }
예제 #17
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            // take package names from the data source
            string         packageId          = Constants.TestPackageId;
            WebTestRequest packagePageRequest = new WebTestRequest(UrlHelper.BaseUrl + @"/Packages/" + packageId);

            //Rule to check if the title contains the package id and the latest stable version of the package.
            ValidateHtmlTagInnerText packageTitleValidationRule = AssertAndValidationHelper.GetValidationRuleForHtmlTagInnerText(HtmlTextWriterTag.Title.ToString(), string.Empty, string.Empty, "NuGet Gallery | " + packageId + " " + ClientSDKHelper.GetLatestStableVersion(packageId));

            packagePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(packageTitleValidationRule.Validate);
            //rule to check that the download count is present in the response.
            ValidationRuleFindText downloadCountValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(ClientSDKHelper.GetFormattedDownLoadStatistics(packageId));

            packagePageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(downloadCountValidationRule.Validate);

            yield return(packagePageRequest);

            packagePageRequest = null;
        }
예제 #18
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //send a request to the stats/totals to get the initial count.
            WebTestRequest statsRequestBeforeDownload = GetWebRequestForAggregateStats();

            yield return(statsRequestBeforeDownload);

            statsRequestBeforeDownload = null;

            int aggregateStatsBeforeDownload = GetAggregateStatsFromContext();

            //upload a new package and download it.
            string packageId = DateTime.Now.Ticks.ToString() + this.Name;

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId);
            AssertAndValidationHelper.DownloadPackageAndVerify(packageId);

            //wait either the download count changes or till 5 minutes which ever is earlier.
            int waittime = 0;
            int aggregateStatsAfterDownload = aggregateStatsBeforeDownload;

            while (aggregateStatsAfterDownload == aggregateStatsBeforeDownload && waittime <= 300)
            {
                //send a request stats to keep polling the new download count.
                statsRequestBeforeDownload = GetWebRequestForAggregateStats();
                yield return(statsRequestBeforeDownload);

                statsRequestBeforeDownload = null;

                aggregateStatsAfterDownload = GetAggregateStatsFromContext();
                System.Threading.Thread.Sleep(30 * 1000);//sleep for 30 seconds.
                waittime += 30;
            }

            //check download count. New download count should be old one + 1.
            Assert.IsTrue(aggregateStatsBeforeDownload == (aggregateStatsAfterDownload - 1), "Aggregate stats count is not increased by 1 after downloading. Aggregate stats before download :{0}. Stats after download : {1}", aggregateStatsBeforeDownload, aggregateStatsAfterDownload);
        }
예제 #19
0
        public void DownloadPackageWithNuGetCoreTest()
        {
            string packageId = Constants.TestPackageId; //try to down load a pre-defined test package - BaseTestPackage.

            AssertAndValidationHelper.DownloadPackageAndVerify(packageId);
        }
        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;

            // The API key is part of the nuget.config file that is present under the solution dir.
            string packageId       = DateTime.Now.Ticks.ToString();
            string packageFullPath = CmdLineHelper.CreatePackage(packageId);

            WebTestRequest uploadPostRequest = new WebTestRequest(UrlHelper.UploadPageUrl);

            uploadPostRequest.Method = "POST";
            uploadPostRequest.ExpectedResponseUrl = UrlHelper.VerifyUploadPageUrl;
            FormPostHttpBody uploadPostBody = new FormPostHttpBody();

            uploadPostBody.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            uploadPostBody.FormPostParameters.Add(new FileUploadParameter("UploadFile", packageFullPath, "application/x-zip-compressed", true));
            uploadPostRequest.Body = uploadPostBody;
            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 = new WebTestRequest(UrlHelper.VerifyUploadPageUrl);

            verifyUploadPostRequest.Method = "POST";
            verifyUploadPostRequest.ExpectedResponseUrl = UrlHelper.GetPackagePageUrl(packageId) + "/1.0.0";
            FormPostHttpBody verifyUploadPostRequestBody = new FormPostHttpBody();

            verifyUploadPostRequestBody.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            verifyUploadPostRequestBody.FormPostParameters.Add("Listed", "true");
            verifyUploadPostRequestBody.FormPostParameters.Add("Listed", this.Context["$HIDDEN1.Listed"].ToString());
            verifyUploadPostRequest.Body = verifyUploadPostRequestBody;
            yield return(verifyUploadPostRequest);

            verifyUploadPostRequest = null;
        }
예제 #21
0
        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))
            {
                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;
                if (this.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.
                    string response       = this.LastResponse.BodyString;
                    int    referenceIndex = response.IndexOf("<h4>Package ID</h4>");
                    int    startIndex     = response.IndexOf("<p>");
                    int    endIndex       = response.IndexOf("</p>", startIndex);
                    string packageId      = response.Substring(startIndex + 3, endIndex - (startIndex + 3));
                    this.AddCommentToResult(packageId); //Adding the package ID to result for debugging.
                    WebTestRequest verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503);
                    yield return(verifyUploadPostRequest);

                    verifyUploadPostRequest = null;
                }
                else
                {
                    // The API key is part of the nuget.config file that is present under the solution dir.
                    string packageId       = DateTime.Now.Ticks.ToString();
                    string packageFullPath = PackageCreationHelper.CreatePackage(packageId);

                    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.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503);
                    yield return(verifyUploadPostRequest);

                    verifyUploadPostRequest = null;
                }
            }
        }
예제 #22
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            ExtractHiddenFields defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields();

            //Upload a new package.
            string packageId = this.Name + DateTime.Now.Ticks.ToString();
            string version   = "1.0.0";

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, version);

            //Do initial login to be able to perform edit.
            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;

            // The API key is part of the nuget.config file that is present under the solution dir.
            string packageFullPath = PackageCreationHelper.CreatePackage(packageId);

            WebTestRequest uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath);

            yield return(uploadPostRequest);

            uploadPostRequest = null;

            WebTestRequest verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl);

            yield return(verifyUploadRequest);

            verifyUploadRequest = null;

            WebTestRequest verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0");

            yield return(verifyUploadPostRequest);

            verifyUploadPostRequest = null;

            WebTestRequest verifyEditRequest = AssertAndValidationHelper.GetEditGetRequestForPackage(packageId, "1.0.0");

            verifyEditRequest.ExtractValues += new EventHandler <ExtractionEventArgs>(defaultExtractionRule.Extract);
            yield return(verifyEditRequest);

            verifyEditRequest = null;

            WebTestRequest         verifyEditPostRequest        = AssertAndValidationHelper.GetEditPackagePostRequest(this, packageId, "1.0.0", description: "This is a new description.", authors: "clayco", copyright: "Copyright 2014", tags: "Tag1 Tag2", summary: "This is a summary.");
            ValidationRuleFindText newDescriptionValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(@"This is a new description.");
            ValidationRuleFindText pendingEditValidationRule    = AssertAndValidationHelper.GetValidationRuleForFindText(@"An edit is pending for this package version.");

            verifyEditPostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(newDescriptionValidationRule.Validate);
            verifyEditPostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(pendingEditValidationRule.Validate);
            yield return(verifyEditPostRequest);

            verifyEditPostRequest = null;

            // wait a minute.
            System.Threading.Thread.Sleep(60000);
            WebTestRequest         verifyProcessedRequest      = new WebTestRequest(UrlHelper.GetPackagePageUrl(packageId, "1.0.0"));
            ValidationRuleFindText noPendingEditValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(@"An edit is pending for this package version.", false);

            verifyProcessedRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(newDescriptionValidationRule.Validate);
            verifyProcessedRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(noPendingEditValidationRule.Validate);
            yield return(verifyProcessedRequest);

            verifyProcessedRequest = null;
        }
예제 #23
0
        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"))
            {
                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"))
                {
                    // 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.
                    string response       = this.LastResponse.BodyString;
                    int    referenceIndex = response.IndexOf("<h4>Package ID</h4>");
                    int    startIndex     = response.IndexOf("<p>");
                    int    endIndex       = response.IndexOf("</p>", startIndex);
                    string packageId      = response.Substring(startIndex + 3, endIndex - (startIndex + 3));
                    this.AddCommentToResult(packageId);   //Adding the package ID to result for debugging.
                    WebTestRequest verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503);
                    yield return(verifyUploadPostRequest);

                    verifyUploadPostRequest = null;
                }
                else
                {
                    uploadRequest = null;

                    // The API key is part of the nuget.config file that is present under the solution dir.
                    string packageId       = DateTime.Now.Ticks.ToString();
                    string packageFullPath = PackageCreationHelper.CreatePackage(packageId);

                    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;
                }
            }
        }