Beispiel #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);
        }
Beispiel #2
0
        public void AnonymousPushModeNotAcceptInvalidValueWhenCreatingRepo()
        {
            app.NavigateTo <RepositoryController>(c => c.Create());
            var form = app.FindFormFor <RepositoryDetailModel>();

            form.Field(f => f.Name).SetValueTo(ITH.MakeName());
            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);
        }