コード例 #1
0
        public void RepoAdminCannotRemoveThemselves()
        {
            var user = ITH.CreateUsers().Single();

            var repoId = ITH.CreateRepositoryOnWebInterface(ITH.MakeName());

            app.NavigateTo <RepositoryController>(c => c.Edit(repoId));
            var form = app.FindFormFor <RepositoryDetailModel>();

            // Set User0 to be admin for this repo
            var adminBox =
                form.WebApp.Browser.FindElementsByCssSelector(
                    string.Format("input[name=PostedSelectedAdministrators][value=\"{0}\"]", user.Id)).Single();

            ITH.SetCheckbox(adminBox, true);
            form.Submit();
            ITH.AssertThatNoValidationErrorOccurred();

            // Now, log in as the ordinary user
            ITH.LoginAsUser(user);

            app.NavigateTo <RepositoryController>(c => c.Edit(repoId));
            form = app.FindFormFor <RepositoryDetailModel>();

            var chkboxes = form.WebApp.Browser.FindElementsByCssSelector("input[name=PostedSelectedAdministrators]");

            ITH.SetCheckboxes(chkboxes, false);

            form.Submit();
            app.WaitForElementToBeVisible(By.CssSelector("div.validation-summary-errors"), TimeSpan.FromSeconds(1));
            ITH.AssertThatValidationErrorContains(Resources.Repository_Edit_CantRemoveYourself);
        }
コード例 #2
0
        public void RepoNameEnsureDuplicationDetectionStillAllowsEditOtherProperties()
        {
            var reponame = ITH.MakeName();
            var repo     = ITH.CreateRepositoryOnWebInterface(reponame);

            app.NavigateTo <RepositoryController>(c => c.Edit(repo));
            app.FindFormFor <RepositoryDetailModel>()
            .Field(f => f.Description).SetValueTo(reponame + "_other")
            .Submit();
            ITH.AssertThatNoValidationErrorOccurred();

            app.NavigateTo <RepositoryController>(c => c.Edit(repo)); // force refresh
            app.FindFormFor <RepositoryDetailModel>()
            .Field(f => f.Description).ValueShouldEqual(reponame + "_other");
        }
コード例 #3
0
        public void RepositoryCanBeSavedBySysAdminWithoutHavingAnyRepoAdmins()
        {
            var repoId = ITH.CreateRepositoryOnWebInterface(ITH.MakeName());

            app.NavigateTo <RepositoryController>(c => c.Edit(repoId));
            var form = app.FindFormFor <RepositoryDetailModel>();

            // Turn off all the admin checkboxes and save the form
            var chkboxes = form.WebApp.Browser.FindElementsByCssSelector("input[name=PostedSelectedAdministrators]");

            ITH.SetCheckboxes(chkboxes, false);

            form.Submit();
            ITH.AssertThatNoValidationErrorOccurred();
        }
コード例 #4
0
        public void CreateDuplicateRepoNameNotAllowed()
        {
            var reponame = ITH.MakeName();

            ITH.CreateRepositoryOnWebInterface(reponame);

            app.NavigateTo <RepositoryController>(c => c.Create());
            app.FindFormFor <RepositoryDetailModel>()
            .Field(f => f.Name).SetValueTo(reponame)
            .Submit();

            var field = app.FindFormFor <RepositoryDetailModel>()
                        .Field(f => f.Name);

            field.ShouldBeInvalid();
            Assert.AreEqual(Resources.Validation_Duplicate_Name, field.HasValidationMessage().Text);
        }
コード例 #5
0
        public void AnonymousPushModeNotAcceptInvalidValueWhenEditingRepo()
        {
            var repo_id = ITH.CreateRepositoryOnWebInterface(ITH.MakeName());

            app.NavigateTo <RepositoryController>(c => c.Edit(repo_id));
            var form = app.FindFormFor <RepositoryDetailModel>();

            ITH.SetCheckbox(form.Field(f => f.AllowAnonymous).Field, true);
            var select = new SelectElement(form.Field(f => f.AllowAnonymousPush).Field);

            select.SelectByValue(((int)RepositoryPushMode.Global).ToString());

            ITH.SetElementAttribute(select.Options[(int)RepositoryPushMode.Global], "value", "47");
            form.Submit();

            ITH.AssertThatValidationErrorContains(Resources.Repository_Edit_InvalidAnonymousPushMode);
        }
コード例 #6
0
        public void RepoNameEnsureDuplicationDetectionAsYouTypeWorksOnCreation()
        {
            var reponame = ITH.MakeName();

            ITH.CreateRepositoryOnWebInterface(reponame);

            app.NavigateTo <RepositoryController>(c => c.Create());
            app.FindFormFor <RepositoryDetailModel>()
            .Field(f => f.Name).SetValueTo(reponame)
            .Field(f => f.Description).Click();     // Set focus

            var validation = app.WaitForElementToBeVisible(By.CssSelector("input#Name~span.field-validation-error>span"), TimeSpan.FromSeconds(1), true);

            Assert.AreEqual(Resources.Validation_Duplicate_Name, validation.Text);

            var input = app.Browser.FindElementByCssSelector("input#Name");

            Assert.IsTrue(input.GetAttribute("class").Contains("input-validation-error"));
        }
コード例 #7
0
        public void RenameRepoToExistingRepoNameNotAllowedDifferentCase()
        {
            var reponame      = ITH.MakeName();
            var otherreponame = ITH.MakeName(reponame + "_other");

            ITH.CreateRepositoryOnWebInterface(reponame);
            var id2 = ITH.CreateRepositoryOnWebInterface(otherreponame);

            app.NavigateTo <RepositoryController>(c => c.Edit(id2));
            app.FindFormFor <RepositoryDetailModel>()
            .Field(f => f.Name).SetValueTo(reponame.ToUpper())
            .Submit();

            var field = app.FindFormFor <RepositoryDetailModel>()
                        .Field(f => f.Name);

            field.ShouldBeInvalid();
            Assert.AreEqual(Resources.Validation_Duplicate_Name, field.HasValidationMessage().Text);
        }
コード例 #8
0
        public void InvalidLinkifyRegexAsYouTypeInRepository()
        {
            var reponame    = ITH.MakeName();
            var repo_id     = ITH.CreateRepositoryOnWebInterface(reponame);
            var brokenRegex = @"\";

            app.NavigateTo <RepositoryController>(c => c.Edit(repo_id));
            app.FindFormFor <RepositoryDetailModel>()
            .Field(f => f.LinksUseGlobal).Click()
            .Field(f => f.LinksRegex).SetValueTo(brokenRegex)
            .Field(f => f.Description).Click();     // Set focus

            var validation = app.WaitForElementToBeVisible(By.CssSelector("input#LinksRegex~span.field-validation-error>span"), TimeSpan.FromSeconds(1), true);

            Assert.IsTrue(validation.Text.Contains(Resources.Validation_Invalid_Regex.Replace("{0}", "")));

            var input = app.Browser.FindElementByCssSelector("input#LinksRegex");

            Assert.IsTrue(input.GetAttribute("class").Contains("input-validation-error"));
        }
コード例 #9
0
        public void DropdownNavigationWorks()
        {
            var reponame      = ITH.MakeName();
            var otherreponame = ITH.MakeName(reponame + "_other");
            var repoId        = ITH.CreateRepositoryOnWebInterface(reponame);
            var otherrepoId   = ITH.CreateRepositoryOnWebInterface(otherreponame);

            app.NavigateTo <RepositoryController>(c => c.Detail(otherrepoId));

            var element  = app.Browser.FindElementByCssSelector("select#Repositories");
            var dropdown = new SelectElement(element);

            dropdown.SelectByText(reponame);
            Thread.Sleep(2000);

            app.UrlMapsTo <RepositoryController>(c => c.Detail(repoId));

            app.WaitForElementToBeVisible(By.CssSelector("select#Repositories"), TimeSpan.FromSeconds(10));
            dropdown = new SelectElement(app.Browser.FindElementByCssSelector("select#Repositories"));
            dropdown.SelectByText(otherreponame);
            Thread.Sleep(2000);

            app.UrlMapsTo <RepositoryController>(c => c.Detail(otherrepoId));
        }