public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);

            yield return(registerPageRequest);

            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", Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add("LinkingAccount", "false");
            registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks + "@live.com"); //add a dummy mail account.
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, DateTime.Now.Ticks + "NewAccount");
            registerNewUserFormPost.FormPostParameters.Add(Constants.RegisterPasswordFormField, "xxxxxxxx");
            registerPagePostRequest.Body = registerNewUserFormPost;

            // Validate the response to make sure that it has the confirmation text in it.
            var pendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserConfirmationText);

            registerPagePostRequest.ValidateResponse += pendingConfirmationTextRule.Validate;
            yield return(registerPagePostRequest);
        }
예제 #2
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))
            {
                var registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);
                yield return(registerPageRequest);

                var 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.
                var registerNewUserFormPost = new FormPostHttpBody();
                registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", Context["$HIDDEN1.__RequestVerificationToken"].ToString());
                registerNewUserFormPost.FormPostParameters.Add("LinkingAccount", "false");
                registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks + "@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 + "NewAccount");
                registerNewUserFormPost.FormPostParameters.Add(Constants.RegisterPasswordFormField, "xxXxx1xx");
                registerPagePostRequest.Body = registerNewUserFormPost;
                registerPagePostRequest.ExpectedHttpStatusCode = 503;
                // Validate the response to make sure that it shows the error message for read-only mode.
                var readOnlyModeTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.ReadOnlyModeError);
                registerPagePostRequest.ValidateResponse += readOnlyModeTextRule.Validate;
                yield return(registerPagePostRequest);
            }
        }
예제 #3
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            var defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields();

            // Do initial login
            var logonGet = AssertAndValidationHelper.GetLogonGetRequest();

            yield return(logonGet);

            var logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);

            yield return(logonPost);

            var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);

            yield return(uploadRequest);

            var packageId             = $"UploadPackageFromUI.{DateTimeOffset.UtcNow.Ticks}";
            var packageCreationHelper = new PackageCreationHelper();
            var packageFullPath       = packageCreationHelper.CreatePackage(packageId).Result;
            var uploadPostRequest     = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath);

            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 folloing request. (upload and verify were merged onto the same page).
            var uploadRequest2 = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);

            yield return(uploadRequest2);

            var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.GetPackagePageUrl(packageId, "1.0.0"), packageId);

            yield return(verifyUploadPostRequest);
        }
예제 #4
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;

            //Upload a new package.
            string packageId        = this.Name + DateTime.Now.Ticks.ToString();
            string version          = "1.0.0";
            string minClientVersion = "2.3";
            string packageFullPath  = PackageCreationHelper.CreatePackage(packageId, version, minClientVersion);

            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;
        }
예제 #5
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);
        }
        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))
            {
                yield break;
            }

            var defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields();

            // Do initial login
            var logonGet = AssertAndValidationHelper.GetLogonGetRequest();

            yield return(logonGet);

            var logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);

            yield return(logonPost);

            var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);

            yield return(uploadRequest);

            if (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.
                var response   = LastResponse.BodyString;
                var startIndex = response.IndexOf("<p>", StringComparison.Ordinal);
                var endIndex   = response.IndexOf("</p>", startIndex, StringComparison.Ordinal);
                var packageId  = response.Substring(startIndex + 3, endIndex - (startIndex + 3));
                AddCommentToResult(packageId);   //Adding the package ID to result for debugging.
                var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503);
                yield return(verifyUploadPostRequest);
            }
            else
            {
                // The API key is part of the nuget.config file that is present under the solution dir.
                var packageId             = DateTime.Now.Ticks.ToString();
                var packageCreationHelper = new PackageCreationHelper();
                var packageFullPath       = packageCreationHelper.CreatePackage(packageId).Result;

                var uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath);
                yield return(uploadPostRequest);

                var verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl);
                verifyUploadRequest.ExtractValues += defaultExtractionRule.Extract;
                yield return(verifyUploadRequest);

                var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503);
                yield return(verifyUploadPostRequest);
            }
        }
예제 #7
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"))
            {
                yield break;
            }

            var defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields();

            // Do initial login
            var logonGet = AssertAndValidationHelper.GetLogonGetRequest();

            yield return(logonGet);

            var logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);

            yield return(logonPost);

            var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);

            yield return(uploadRequest);

            if (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.
                var response   = LastResponse.BodyString;
                var startIndex = response.IndexOf("<p>", StringComparison.Ordinal);
                var endIndex   = response.IndexOf("</p>", startIndex, StringComparison.Ordinal);
                var packageId  = response.Substring(startIndex + 3, endIndex - (startIndex + 3));
                AddCommentToResult(packageId);   //Adding the package ID to result for debugging.
                var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.VerifyUploadPageUrl, Constants.ReadOnlyModeError, 503);
                yield return(verifyUploadPostRequest);
            }
            else
            {
                // The API key is part of the nuget.config file that is present under the solution dir.
                var packageId             = DateTime.Now.Ticks.ToString();
                var packageCreationHelper = new PackageCreationHelper();
                var packageFullPath       = packageCreationHelper.CreatePackage(packageId).Result;

                var uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath);
                yield return(uploadPostRequest);

                var verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl);
                verifyUploadRequest.ExtractValues += defaultExtractionRule.Extract;
                yield return(verifyUploadRequest);

                var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0", UrlHelper.GetPackagePageUrl(packageId, "1.0.0"), packageId);
                yield return(verifyUploadPostRequest);
            }
        }
예제 #8
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);

            uploadRequest = null;

            //Upload a new package.
            string packageId        = this.Name + DateTime.Now.Ticks.ToString();
            string version          = "1.0.0";
            string minClientVersion = "2.3";
            string packageFullPath  = PackageCreationHelper.CreatePackage(packageId, version, minClientVersion);

            //Do initial login to be able to perform package management.
            logonGet = AssertAndValidationHelper.GetLogonGetRequest();
            yield return(logonGet);

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

            logonPost = null;

            System.Threading.Thread.Sleep(60000);
            WebTestRequest packageRequest = new WebTestRequest(UrlHelper.GetPackagePageUrl(packageId));
            //Rule to check manage my packages contains a html link to the newly uploaded package.
            ValidationRuleFindText requiredMinVersionValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(minClientVersion);

            packageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(requiredMinVersionValidationRule.Validate);
            yield return(packageRequest);

            packageRequest = null;
        }
예제 #9
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;
            uploadRequest = null;

            string packageId = DateTime.Now.Ticks.ToString();
            string packageFullPath = PackageCreationHelper.CreatePackage(packageId);

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

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

            System.Threading.Thread.Sleep(60000);
            WebTestRequest packageRequest = new WebTestRequest(UrlHelper.GetPackagePageUrl(packageId));    
            ValidationRuleFindText findTextRule = AssertAndValidationHelper.GetValidationRuleForFindText("Contact Us");
            packageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(findTextRule.Validate);
            yield return packageRequest;
            packageRequest = null;

            // Log off
            WebTestRequest logOffGet = AssertAndValidationHelper.GetLogOffGetRequest();
            yield return logOffGet;
            logOffGet = null;

            packageRequest = new WebTestRequest(UrlHelper.GetPackagePageUrl(packageId));
            //Rule to check manage my packages contains a html link to the newly uploaded package.     
            ValidationRuleFindText reportAbuseValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText("Report Abuse");
            packageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(reportAbuseValidationRule.Validate);
            yield return packageRequest;
            packageRequest = null;   

        }