Permalink
Browse files

Cleaning up WebUI tests

  • Loading branch information...
1 parent e50dce0 commit 4bda742f7d1dd8e4e19b1e5dda8c2995adbfb9cd @bhuvak bhuvak committed Jun 12, 2014
Showing with 44 additions and 760 deletions.
  1. +3 −34 tests/NuGetGallery.FunctionalTests.Helpers/AssertAndValidationHelper.cs
  2. +2 −1 tests/NuGetGallery.FunctionalTests.Helpers/Constants.cs
  3. +0 −11 tests/NuGetGallery.FunctionalTests/NuGetGallery.FunctionalTests.csproj
  4. +0 −46 tests/NuGetGallery.FunctionalTests/WebUITests/AccountManagement/InvalidLogonTest.cs
  5. +1 −0 tests/NuGetGallery.FunctionalTests/WebUITests/AccountManagement/LogonTest.cs
  6. +0 −65 tests/NuGetGallery.FunctionalTests/WebUITests/AccountManagement/RegisterInvalidUserTest.cs
  7. +4 −3 tests/NuGetGallery.FunctionalTests/WebUITests/AccountManagement/RegisterNewUserTest.cs
  8. +0 −31 tests/NuGetGallery.FunctionalTests/WebUITests/AccountManagement/UploadPackageWithoutLoginTest.cs
  9. +1 −0 tests/NuGetGallery.FunctionalTests/WebUITests/BasicPages/HomePageValidationTest.cs
  10. +1 −0 tests/NuGetGallery.FunctionalTests/WebUITests/BasicPages/OutercurveBrandingValidationTest.cs
  11. +2 −1 tests/NuGetGallery.FunctionalTests/WebUITests/BasicPages/PackagesPageTest.cs
  12. +0 −48 tests/NuGetGallery.FunctionalTests/WebUITests/BasicPages/SecurityHeaderTest.cs
  13. +1 −0 tests/NuGetGallery.FunctionalTests/WebUITests/BasicPages/StatisticsPageTest.cs
  14. +0 −64 tests/NuGetGallery.FunctionalTests/WebUITests/PackageManagement/ContactOwnerTest.cs
  15. +0 −74 tests/NuGetGallery.FunctionalTests/WebUITests/PackageManagement/ContactUsAndReportAbuseLinkTest.cs
  16. +0 −70 tests/NuGetGallery.FunctionalTests/WebUITests/PackageManagement/DeletePackageTest.cs
  17. +0 −92 tests/NuGetGallery.FunctionalTests/WebUITests/PackageManagement/EditPackageTest.cs
  18. +0 −43 tests/NuGetGallery.FunctionalTests/WebUITests/PackageManagement/ManagePackagesPageTest.cs
  19. +0 −92 tests/NuGetGallery.FunctionalTests/WebUITests/UploadAndDownload/AggregateStatsAfterDownload.cs
  20. +29 −19 tests/NuGetGallery.FunctionalTests/WebUITests/UploadAndDownload/UploadPackageFromUI.cs
  21. +0 −66 ...llery.FunctionalTests/WebUITests/UploadAndDownload/UploadPackageWithMinClientVersionFromUITest.cs
@@ -71,16 +71,7 @@ public static WebTestRequest GetLogonGetRequest()
{
return GetHttpRequestForUrl(UrlHelper.LogonPageUrl);
}
-
- /// <summary>
- /// Returns the GET WebRequest for logon.
- /// </summary>
- /// <returns></returns>
- public static WebTestRequest GetEditGetRequestForPackage(string packageId, string version)
- {
- return GetHttpRequestForUrl(String.Format(UrlHelper.EditPageUrl, packageId, version));
- }
-
+
/// <summary>
/// Returns the GET WebRequest for Log Off.
/// </summary>
@@ -117,29 +108,7 @@ public static WebTestRequest GetLogonPostRequest(WebTest test, string accountNam
logonRequestFormPostBody.FormPostParameters.Add(NuGetGallery.FunctionTests.Helpers.Constants.PasswordFormField, EnvironmentSettings.TestAccountPassword);
logonPostRequest.Body = logonRequestFormPostBody;
return logonPostRequest;
- }
-
- public static WebTestRequest GetEditPackagePostRequest(WebTest test, string packageId, string version, string title = null, string description = null, string summary = null, string iconUrl = null, string projectUrl = null, string authors = null, string copyright = null, string tags = null, string releaseNotes = null)
- {
- WebTestRequest editPackagePostRequest = new WebTestRequest(String.Format(UrlHelper.EditPageUrl, packageId, version));
- editPackagePostRequest.Method = "POST";
- editPackagePostRequest.ExpectedResponseUrl = UrlHelper.GetPackagePageUrl(packageId, version);
- //Assert.Fail("ExpectedResponseUrl is " + editPackagePostRequest.ExpectedResponseUrl);
- FormPostHttpBody logonRequestFormPostBody = new FormPostHttpBody();
- logonRequestFormPostBody.FormPostParameters.Add("__RequestVerificationToken", test.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
- logonRequestFormPostBody.FormPostParameters.Add("Edit.VersionTitle", title);
- logonRequestFormPostBody.FormPostParameters.Add("Edit.Description", description);
- logonRequestFormPostBody.FormPostParameters.Add("Edit.Summary", summary);
- logonRequestFormPostBody.FormPostParameters.Add("Edit.IconUrl", iconUrl);
- logonRequestFormPostBody.FormPostParameters.Add("Edit.ProjectUrl", projectUrl);
- logonRequestFormPostBody.FormPostParameters.Add("Edit.Authors", authors);
- logonRequestFormPostBody.FormPostParameters.Add("Edit.Copyright", copyright);
- logonRequestFormPostBody.FormPostParameters.Add("Edit.Tags", tags);
- logonRequestFormPostBody.FormPostParameters.Add("Edit.ReleaseNotes", releaseNotes);
-
- editPackagePostRequest.Body = logonRequestFormPostBody;
- return editPackagePostRequest;
- }
+ }
/// <summary>
/// Returns the POST WebRequest for logon with appropriate form parameters set.
@@ -179,7 +148,7 @@ public static WebTestRequest GetVerifyPackagePostRequestForPackage(WebTest test,
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.Authors", "nugettest");
verifyUploadPostRequestBody.FormPostParameters.Add("Edit.CopyrightText", "Copyright 2013");
verifyUploadPostRequestBody.FormPostParameters.Add("Edit.Tags", " windows8 ");
verifyUploadPostRequestBody.FormPostParameters.Add("Edit.ReleaseNotes", "");
@@ -16,7 +16,8 @@ public static class Constants
#region PredefinedText
public const string HomePageText = "What is NuGet?";
- public const string RegisterNewUserPendingConfirmationText = "Your account is now registered!";
+ public const string InvalidUserText = "A unique user with that username or email address and password does not exist";
+ public const string RegisterNewUserConfirmationText = "Your account is now registered!";
public const string UserAlreadyExistsText = "User already exists";
public const string ReadOnlyModeRegisterNewUserText = "503 : Please try again later! (Read-only)";
public const string SearchTerm = "elmah";
@@ -92,26 +92,15 @@
<Compile Include="ODataTests\FeedTests\CuratedFeedTest.cs" />
<Compile Include="ClientIntegrationTests\UploadAndDownload\PackageVersionTest.cs" />
<Compile Include="GalleryTestBase.cs" />
- <Compile Include="WebUITests\AccountManagement\InvalidLogonTest.cs" />
<Compile Include="WebUITests\BasicPages\OutercurveBrandingValidationTest.cs" />
- <Compile Include="WebUITests\BasicPages\SecurityHeaderTest.cs" />
- <Compile Include="WebUITests\PackageManagement\ContactOwnerTest.cs" />
- <Compile Include="WebUITests\PackageManagement\ContactUsAndReportAbuseLinkTest.cs" />
- <Compile Include="WebUITests\PackageManagement\EditPackageTest.cs" />
<Compile Include="WebUITests\ReadOnlyMode\RegisterNewUserInReadOnlyModeTest.cs" />
- <Compile Include="WebUITests\UploadAndDownload\UploadPackageWithMinClientVersionFromUITest.cs" />
- <Compile Include="WebUITests\PackageManagement\DeletePackageTest.cs" />
- <Compile Include="WebUITests\PackageManagement\ManagePackagesPageTest.cs" />
- <Compile Include="WebUITests\UploadAndDownload\AggregateStatsAfterDownload.cs" />
<Compile Include="WebUITests\UploadAndDownload\UploadPackageFromUI.cs" />
<Compile Include="WebUITests\AccountManagement\LogonTest.cs" />
<Compile Include="WebUITests\BasicPages\PackagesPageTest.cs" />
<Compile Include="WebUITests\BasicPages\HomePageValidationTest.cs" />
<Compile Include="ODataTests\FeedTests\V2FeedTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="WebUITests\AccountManagement\RegisterInvalidUserTest.cs" />
<Compile Include="WebUITests\BasicPages\StatisticsPageTest.cs" />
- <Compile Include="WebUITests\AccountManagement\UploadPackageWithoutLoginTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NuGetGallery.FunctionalTests.Helpers\NuGetGallery.FunctionalTests.Helpers.csproj">
@@ -1,46 +0,0 @@
-using Microsoft.VisualStudio.TestTools.WebTesting;
-using Microsoft.VisualStudio.TestTools.WebTesting.Rules;
-using NuGetGallery.FunctionalTests.Helpers;
-using NuGetGallery.FunctionTests.Helpers;
-using System;
-using System.Collections.Generic;
-
-namespace NuGetGallery.FunctionalTests
-{
- /// <summary>
- /// Tries to login with a POST request with the credentials retrieved from the data source. Validates that the response has the logged in user name.
- /// </summary>
- public class InvalidLogonTest : WebTest
- {
- public InvalidLogonTest()
- {
- this.PreAuthenticate = true;
- }
- 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;
- }
- }
-}
-
@@ -9,6 +9,7 @@ namespace NuGetGallery.FunctionalTests
{
/// <summary>
/// Tries to login with a POST request with the credentials retrieved from the data source. Validates that the response has the logged in user name.
+ /// priority : p0
/// </summary>
public class LogonTest : WebTest
{
@@ -1,65 +0,0 @@
-using Microsoft.VisualStudio.TestTools.WebTesting;
-using Microsoft.VisualStudio.TestTools.WebTesting.Rules;
-using NuGetGallery.FunctionalTests.Helpers;
-using NuGetGallery.FunctionTests.Helpers;
-using System;
-using System.Collections.Generic;
-
-namespace NuGetGallery.FunctionalTests
-{
- /// <summary>
- /// Attempts to register an invalid user and confirms that the process failed.
- /// </summary>
- public class RegisterInvalidUserTest : WebTest
- {
- public RegisterInvalidUserTest()
- {
- this.PreAuthenticate = true;
- }
-
- public override IEnumerator<WebTestRequest> GetRequestEnumerator()
- {
- WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);
- 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("LinkingAccount", "false");
- 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");
- 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("LinkingAccount", "false");
- 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");
- 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.
- PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserPendingConfirmationText, false);
- registerPagePostRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(PendingConfirmationTextRule.Validate);
- yield return registerPagePostRequest;
- registerPagePostRequest = null;
- }
- }
-}
-
@@ -9,6 +9,7 @@ namespace NuGetGallery.FunctionalTests
{
/// <summary>
/// Sends http POST request to register a new user and checks that a pending confirmation page is shown as response.
+ /// priority : p0
/// </summary>
public class RegisterNewUserTest : WebTest
{
@@ -31,12 +32,12 @@ public override IEnumerator<WebTestRequest> GetRequestEnumerator()
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.EmailAddressFormField, DateTime.Now.Ticks.ToString() + "@live.com"); //add a dummy mail account.
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);
+ //Validate the response to make sure that it has the confirmation text in it.
+ ValidationRuleFindText PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserConfirmationText);
registerPagePostRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(PendingConfirmationTextRule.Validate);
yield return registerPagePostRequest;
registerPagePostRequest = null;
@@ -1,31 +0,0 @@
-using Microsoft.VisualStudio.TestTools.WebTesting;
-using Microsoft.VisualStudio.TestTools.WebTesting.Rules;
-using NuGetGallery.FunctionalTests.Helpers;
-using NuGetGallery.FunctionTests.Helpers;
-using System;
-using System.Collections.Generic;
-using System.Web.UI;
-
-namespace NuGetGallery.FunctionalTests
-{
- /// <summary>
- /// Tries to hit upload package page without logging in and checks if the log on form is displayed in the response.
- /// </summary>
- public class UploadPackageWithoutLoginTest : WebTest
- {
- public UploadPackageWithoutLoginTest()
- {
- this.PreAuthenticate = true;
- }
-
- 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;
- }
- }
-}
@@ -9,6 +9,7 @@ namespace NuGetGallery.FunctionalTests
{
/// <summary>
/// Sends http request to gallery home page checks for the default home page text in the reponse.
+ /// priority : p0
/// </summary>
public class HomePageValidationTest : WebTest
{
@@ -9,6 +9,7 @@ namespace NuGetGallery.FunctionalTests
{
/// <summary>
/// Sends http request to gallery home page checks for the default home page text in the reponse.
+ /// priority : p1
/// </summary>
public class OutercurveBrandingValidationTest : WebTest
{
@@ -9,6 +9,7 @@ namespace NuGetGallery.FunctionalTests
{
/// <summary>
/// Sends http request to individual package pages and checks the response for appropriate title and download count.
+ /// priority : p1
/// </summary>
public class PackagesPageTest : WebTest
{
@@ -19,7 +20,7 @@ public PackagesPageTest()
public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
- // take package names from the data source
+ //Use a predefined test package.
string packageId = Constants.TestPackageId;
WebTestRequest packagePageRequest = new WebTestRequest(UrlHelper.BaseUrl + @"/Packages/" + packageId);
Oops, something went wrong.

0 comments on commit 4bda742

Please sign in to comment.