コード例 #1
0
 public void UploadPackageIfNecessary(string packageName, string version, string minClientVersion, string title, string tags, string description)
 {
     if (!PackageExists(packageName, version, UrlHelper.V2FeedRootUrl))
     {
         AssertAndValidationHelper.UploadNewPackageAndVerify(packageName, version, minClientVersion, title, tags, description);
     }
 }
コード例 #2
0
 public void UploadPackageIfNecessary(string packageName, string version)
 {
     if (!PackageExists(packageName, version))
     {
         AssertAndValidationHelper.UploadNewPackageAndVerify(packageName, version);
     }
 }
コード例 #3
0
 public void UploadPackageWithNuGetCommandLineTest()
 {
     if (UrlHelper.BaseUrl.Contains("nugettest.org") || UrlHelper.BaseUrl.Contains("nuget.org"))
     {
         AssertAndValidationHelper.UploadNewPackageAndVerify(DateTime.Now.Ticks.ToString());
     }
 }
コード例 #4
0
        public void UploadMultipleVersionOfPackage()
        {
            string packageId = "TestMultipleVersion" + "." + DateTime.Now.Ticks.ToString();

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "1.0.0");
            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "2.0.0");
            int actualCount = ClientSDKHelper.GetVersionCount(packageId);

            Assert.IsTrue(actualCount.Equals(2), " 2 versions of package {0} not found after uploading. Actual versions found {1}", packageId, actualCount);
        }
コード例 #5
0
        public void FindPackagesByIdTest()
        {
            string packageId = "TestV2FeedFindPackagesById" + "." + DateTime.Now.Ticks.ToString();

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "1.0.0");
            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "2.0.0");
            string url = UrlHelper.V2FeedRootUrl + @"/FindPackagesById()?id='" + packageId + "'";

            string[] expectedTexts = new string[] { @"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='1.0.0')</id>", @"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='2.0.0')</id>" };
            Assert.IsTrue(ODataHelper.ContainsResponseText(url, expectedTexts));
        }
コード例 #6
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 contact owner.
            WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest();

            yield return(logonGet);

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

            yield return(logonPost);

            logonPost = null;

            WebTestRequest conactOwnerRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.GetContactOwnerPageUrl(packageId));

            yield return(conactOwnerRequest);

            conactOwnerRequest = null;

            WebTestRequest conactOwnerPostRequest = new WebTestRequest(UrlHelper.GetContactOwnerPageUrl(packageId));

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

            contactOwnerRequestBody.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            contactOwnerRequestBody.FormPostParameters.Add("Message", "Test");
            conactOwnerPostRequest.Body = contactOwnerRequestBody;

            //Make sure that the package page shows the message saying that the mail has been sent.
            ValidationRuleFindText findTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.ContactOwnersText + packageId);

            conactOwnerPostRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(findTextRule.Validate);
            yield return(conactOwnerPostRequest);

            conactOwnerPostRequest = null;

            //Wait for a 30 sec to make sure that the mail reaches properly.
            System.Threading.Thread.Sleep(30 * 1000);

            //Cross check with the pop3 client to check if the message actually has been received.
            string subject = string.Empty;

            Assert.IsTrue(MailHelper.IsMailSentForContactOwner(packageId, out subject), "Contact owners message not sent to the owner properly. Actual subject : {0}", subject);
        }
コード例 #7
0
 public void FindPackagesByIdTest()
 {
     // 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"))
     {
         string packageId = "TestV2FeedFindPackagesById" + "." + DateTime.Now.Ticks.ToString();
         AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "1.0.0");
         AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "2.0.0");
         string   url           = UrlHelper.V2FeedRootUrl + @"/FindPackagesById()?id='" + packageId + "'";
         string[] expectedTexts = new string[] { @"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='1.0.0')</id>", @"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='2.0.0')</id>" };
         Assert.IsTrue(ODataHelper.ContainsResponseText(url, expectedTexts));
     }
 }
コード例 #8
0
        public void FindPackagesByIdTest()
        {
            string packageId = "TestV2FeedFindPackagesById" + "." + DateTime.Now.Ticks.ToString();

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "1.0.0");
            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, "2.0.0");
            WebRequest request = WebRequest.Create(UrlHelper.V2FeedRootUrl + @"/FindPackagesById()?id='" + packageId + "'");
            // Get the response.
            WebResponse  response     = request.GetResponse();
            StreamReader sr           = new StreamReader(response.GetResponseStream());
            string       responseText = sr.ReadToEnd();

            Assert.IsTrue(responseText.Contains(@"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='1.0.0')</id>"));
            Assert.IsTrue(responseText.Contains(@"<id>" + UrlHelper.V2FeedRootUrl + "Packages(Id='" + packageId + "',Version='2.0.0')</id>"));
        }
コード例 #9
0
 public static void CheckIfBaseTestPackageExists()
 {
     //Check if the BaseTestPackage exists in current source and if not upload it. This will be used by the download related tests.
     try
     {
         if (!ClientSDKHelper.CheckIfPackageExistsInSource(Constants.TestPackageId, UrlHelper.V2FeedRootUrl))
         {
             AssertAndValidationHelper.UploadNewPackageAndVerify(Constants.TestPackageId);
         }
     }
     catch (AssertFailedException)
     {
         Assert.Inconclusive("The initialization method to pre-upload test package has failed. Hence failing all the tests. Make sure that a package by name {0} exists @ {1} before running tests. Check test run error for details", Constants.TestPackageId, UrlHelper.BaseUrl);
     }
 }
コード例 #10
0
 public static void AssemblyInit(TestContext context)
 {
     //Check if functional tests is enabled. If not, do an assert inconclusive.
     if (!EnvironmentSettings.RunFunctionalTests.Equals("True", StringComparison.OrdinalIgnoreCase))
     {
         Assert.Inconclusive("Functional tests are disabled in the current run. Please set environment variable RunFuntionalTests to True to enable them");
     }
     //Check if the BaseTestPackage exists in current source and if not upload it. This will be used by the download related tests.
     try
     {
         if (!ClientSDKHelper.CheckIfPackageExistsInSource(Constants.TestPackageId, UrlHelper.V2FeedRootUrl))
         {
             AssertAndValidationHelper.UploadNewPackageAndVerify(Constants.TestPackageId);
         }
     }
     catch (AssertFailedException)
     {
         Assert.Inconclusive("The initialization method to pre-upload test package has failed. Hence failing all the tests. Make sure that a package by name {0} exists @ {1} before running tests. Check test run error for details", Constants.TestPackageId, UrlHelper.BaseUrl);
     }
 }
コード例 #11
0
        public void GetUpdates1052RegressionTest()
        {
            // Use the same package name, but force the version to be unique.
            string packageName = "NuGetGallery.FunctionalTests.ODataTests.GetUpdates1052RegressionTest";
            string ticks       = DateTime.Now.Ticks.ToString();
            string version1    = new System.Version(ticks.Substring(0, 6) + "." + ticks.Substring(6, 6) + "." + ticks.Substring(12, 6)).ToString();
            string version2    = new System.Version(Convert.ToInt32((ticks.Substring(0, 6)) + 1).ToString() + "." + ticks.Substring(6, 6) + "." + ticks.Substring(12, 6)).ToString();

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageName, version1);
            AssertAndValidationHelper.UploadNewPackageAndVerify(packageName, version2);

            WebRequest request = WebRequest.Create(UrlHelper.V2FeedRootUrl + @"/GetUpdates()?packageIds='NuGetGallery.FunctionalTests.ODataTests.GetUpdates1052RegressionTest%7CNuGetGallery.FunctionalTests.ODataTests.GetUpdates1052RegressionTest%7COwin%7CMicrosoft.Web.Infrastructure%7CMicrosoft.AspNet.Identity.Core%7CMicrosoft.AspNet.Identity.EntityFramework%7CMicrosoft.AspNet.Identity.Owin%7CMicrosoft.AspNet.Web.Optimization%7CRespond%7CWebGrease%7CjQuery%7CjQuery.Validation%7CMicrosoft.Owin.Security.Twitter%7CMicrosoft.Owin.Security.OAuth%7CMicrosoft.Owin.Security.MicrosoftAccount%7CMicrosoft.Owin.Security.Google%7CMicrosoft.Owin.Security.Facebook%7CMicrosoft.Owin.Security.Cookies%7CMicrosoft.Owin%7CMicrosoft.Owin.Host.SystemWeb%7CMicrosoft.Owin.Security%7CModernizr%7CMicrosoft.jQuery.Unobtrusive.Validation%7CMicrosoft.AspNet.WebPages%7CMicrosoft.AspNet.Razor%7Cbootstrap%7CAntlr%7CMicrosoft.AspNet.Mvc%7CNewtonsoft.Json%7CEntityFramework'&versions='" + version1 + "%7C" + version2 + "%7C1.0%7C1.0.0.0%7C1.0.0%7C1.0.0%7C1.0.0%7C1.1.1%7C1.2.0%7C1.5.2%7C1.10.2%7C1.11.1%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.6.2%7C3.0.0%7C3.0.0%7C3.0.0%7C3.0.0%7C3.4.1.9004%7C5.0.0%7C5.0.6%7C6.0.0'&includePrerelease=false&includeAllVersions=false&targetFrameworks='net45'&versionConstraints='%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C'");
            // Get the response.
            WebResponse  response     = request.GetResponse();
            StreamReader sr           = new StreamReader(response.GetResponseStream());
            string       responseText = sr.ReadToEnd();

            // Verify at least one package is in the output.
            Assert.IsTrue(responseText.Contains(@"<title type=""text"">NuGetGallery.FunctionalTests.ODataTests.GetUpdates1052RegressionTest</title>"));
            Assert.IsTrue(responseText.Contains(@"<d:Version>" + version2 + "</d:Version><d:NormalizedVersion>" + version2 + "</d:NormalizedVersion>"));
        }
コード例 #12
0
 public void UploadPackageWithNuGetCommandLineTest()
 {
     AssertAndValidationHelper.UploadNewPackageAndVerify(DateTime.Now.Ticks.ToString());
 }