UploadNewPackageAndVerify() public static method

Creates a package with the specified Id and Version and uploads it and checks if the upload has suceeded. This will be used by test classes which tests scenarios on top of upload.
public static UploadNewPackageAndVerify ( string packageId, string version = "1.0.0" ) : void
packageId string
version string
return void
Esempio n. 1
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");
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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;
        }