public static async Task Update() { // Arrange var group = new Response.ApplicationGroup(); var permission = new Response.Permission(); var permissions = new Response.PermissionsSetId { Permissions = new[] { permission, } }; var mock = Substitute.For <IFor>(); mock .IdentitiesAsync() .Returns(new Response.ApplicationGroups { Identities = new[] { group } }); mock .PermissionSetAsync(group) .Returns(permissions); // Act var target = new ManagePermissions(mock); await target.SetToAsync(4); // Assert await mock .Received() .UpdateAsync(group, permissions, permission); permission .PermissionId .ShouldBe(4); }
public async Task ReconcileIntegrationTest() { var client = new VstsRestClient(_config.Organization, _config.Token); var projectId = (await client.GetAsync(Project.Properties(_config.Project))).Id; await ManagePermissions .ForRepository(client, projectId, RepositoryId) .Permissions(Permissions.DeleteRepository) .SetToAsync(PermissionId.Allow); var rule = new NobodyCanDeleteTheRepository(client); (await rule.EvaluateAsync(projectId, RepositoryId)) .ShouldBe(false); await rule.ReconcileAsync(projectId, RepositoryId); await Policy .Handle <Exception>() .WaitAndRetryAsync(Constants.NumRetries, t => TimeSpan.FromSeconds(t)) .ExecuteAsync(async() => { (await rule.EvaluateAsync(projectId, RepositoryId)).ShouldBe(true); }); }
public async Task ReconcileIntegrationTest() { var client = new VstsRestClient(_config.Organization, _config.Token); var projectId = (await client.GetAsync(Project.Properties(_config.Project))).Id; var releasePipeline = await client.GetAsync(ReleaseManagement.Definition(_config.Project, "1")) .ConfigureAwait(false); await ManagePermissions .ForReleasePipeline(client, projectId, releasePipeline.Id, releasePipeline.Path) .Permissions(Release.DeleteReleasePipelines) .SetToAsync(PermissionId.Allow); var rule = new NobodyCanDeleteReleases(client); (await rule.EvaluateAsync(projectId, releasePipeline)) .ShouldBe(false); await rule.ReconcileAsync(projectId, releasePipeline.Id); await Policy .Handle <Exception>() .WaitAndRetryAsync(Constants.NumRetries, t => TimeSpan.FromSeconds(t)) .ExecuteAsync(async() => { (await rule.EvaluateAsync(projectId, releasePipeline)).ShouldBe(true); }); }
public async Task ReconcileIntegrationTest() { var project = await _client.GetAsync(Project.ProjectById(_config.Project)); var buildPipeline = await _client.GetAsync(Builds.BuildDefinition(project.Id, "2")) .ConfigureAwait(false); await ManagePermissions .ForBuildPipeline(_client, project.Id, buildPipeline.Id, buildPipeline.Path) .Permissions(Build.DeleteBuilds) .SetToAsync(PermissionId.Allow); var rule = new NobodyCanDeleteBuilds(_client); (await rule.EvaluateAsync(project, buildPipeline)) .ShouldBe(false); await rule.ReconcileAsync(project.Id, buildPipeline.Id); await Policy .Handle <Exception>() .WaitAndRetryAsync(Constants.NumRetries, t => TimeSpan.FromSeconds(t)) .ExecuteAsync(async() => { (await rule.EvaluateAsync(project, buildPipeline)).ShouldBe(true); }); }
public async Task ReconcileIntegrationTestForMasterBranchPermission() { var repositoryId = "6435e3f0-15b7-4302-814d-4ab586e61f8b"; var client = new VstsRestClient(_config.Organization, _config.Token); var projectId = (await client.GetAsync(Project.Properties(_config.Project))).Id; await ManagePermissions .ForMasterBranch(client, projectId, repositoryId) .Permissions(Permissions.BypassPoliciesPullRequest) .SetToAsync(PermissionId.Allow); var rule = new NobodyCanBypassPolicies(client); (await rule.EvaluateAsync(projectId, repositoryId)) .ShouldBe(false); await rule.ReconcileAsync(projectId, repositoryId); await Policy .Handle <Exception>() .WaitAndRetryAsync(Constants.NumRetries, t => TimeSpan.FromSeconds(t)) .ExecuteAsync(async() => { (await rule.EvaluateAsync(projectId, repositoryId)).ShouldBe(true); }); }
public static async Task ValidateIgnore() { // Arrange var fixture = new Fixture().Customize(new AutoNSubstituteCustomization { ConfigureMembers = true }); fixture.Customize <Response.ApplicationGroup>(ctx => ctx .With(x => x.FriendlyDisplayName, "some-name")); fixture.Customize <Response.Permission>(ctx => ctx .With(x => x.PermissionId, 1) .With(x => x.PermissionBit, 1234)); var mock = fixture.Create <IFor>(); // Act var target = new ManagePermissions(mock); var result = await target .Ignore("some-name") .Permissions(1234) .Allow(4) .ValidateAsync(); // Assert result.ShouldBe(true); }
private void administradorPermisosToolStripMenuItem_Click(object sender, EventArgs e) { ManagePermissions dlg = new ManagePermissions(this.user[0].Name); dlg.MdiParent = this; dlg.Show(); }
private void button3_Click(object sender, EventArgs e) { if (dgvAccessLevels.SelectedRows.Count > 0) { ManagePermissions aeal = new ManagePermissions(); aeal.AccessLevelId = accessLevels[dgvAccessLevels.SelectedRows[0].Index].Id; aeal.ShowDialog(); if (aeal.DialogResult == DialogResult.OK) { Rebind(); } } }
private void managePermissionsToolStripMenuItem_Click(object sender, EventArgs e) { ManagePermissions permiss = new ManagePermissions(this); permiss.WindowState = FormWindowState.Normal; foreach (Form form in Application.OpenForms) { if (form.GetType() == typeof(ManagePermissions)) { form.Activate(); return; } } permiss.MdiParent = this; permiss.Show(); }
public static async Task Allow() { // Arrange var fixture = new Fixture().Customize(new AutoNSubstituteCustomization { ConfigureMembers = true }); fixture.Customize <Response.Permission>(ctx => ctx .With(x => x.PermissionId, 1)); var mock = fixture.Create <IFor>(); // Act var target = new ManagePermissions(mock); await target.Allow(1).SetToAsync(4); // Assert await mock .Received(0) .UpdateAsync(Arg.Any <Response.ApplicationGroup>(), Arg.Any <Response.PermissionsSetId>(), Arg.Any <Response.Permission>()); }
public static async Task ForIgnoreOthers() { // Arrange var fixture = new Fixture().Customize(new AutoNSubstituteCustomization { ConfigureMembers = true }); fixture.Customize <Response.ApplicationGroup>(ctx => ctx .With(x => x.FriendlyDisplayName, "some-name")); var mock = fixture.Create <IFor>(); // Act var target = new ManagePermissions(mock); await target.For("some-other").SetToAsync(4); // Assert await mock .Received(0) .UpdateAsync(Arg.Any <Response.ApplicationGroup>(), Arg.Any <Response.PermissionsSetId>(), Arg.Any <Response.Permission>()); }
public static async Task ValidateFalse() { // Arrange var fixture = new Fixture().Customize(new AutoNSubstituteCustomization { ConfigureMembers = true }); fixture.Customize <Response.Permission>(ctx => ctx .With(x => x.PermissionId, 1) .With(x => x.PermissionBit, 1234)); var mock = fixture.Create <IFor>(); // Act var target = new ManagePermissions(mock); var result = await target .Permissions(1234) .Allow(4) .ValidateAsync(); // Assert result.ShouldBe(false); }
public async Task ReconcileIntegrationTest() { var client = new VstsRestClient(_config.Organization, _config.Token); await ManagePermissions .ForTeamProject(client, _config.Project) .Permissions((4, "52d39943-cb85-4d7f-8fa8-c6baac873819")) .SetToAsync(PermissionId.Allow); var rule = new NobodyCanDeleteTheTeamProject(client); (await rule.EvaluateAsync(_config.Project)) .ShouldBe(false); await rule.ReconcileAsync(_config.Project); await Policy .Handle <Exception>() .WaitAndRetryAsync(Constants.NumRetries, t => TimeSpan.FromSeconds(t)) .ExecuteAsync(async() => { (await rule.EvaluateAsync(_config.Project)).ShouldBe(true); }); }
public ActionResult ManagePermissions(ManagePermissions model, FormCollection form, string Command) { if (Command == "Assign") { if (!string.IsNullOrEmpty(form["ddlRole"]) && !string.IsNullOrEmpty(form["ddlView"])) { model.RoleName = form["ddlRole"]; model.ViewName = form["ddlView"]; dtObj = new System.Data.DataTable(); dtObj = BLObj.checkPermissionForRole(model.RoleName, model.ViewName); if (dtObj.Rows.Count > 0) { getDisplayData(ref model); ViewBag.ClassName = "bg-danger text-danger"; ViewBag.ResultMessage = "Selected role has already been granted access to selected view !"; } else { BLObj.setPermisssionForRole(model.RoleName, Convert.ToInt32(model.ViewName)); getDisplayData(ref model); ViewBag.ClassName = "bg-success text-success"; ViewBag.ResultMessage = "Selected role granted access to selected view successfully !"; } } else { getDisplayData(ref model); ViewBag.ClassName = "bg-danger text-danger"; ViewBag.ResultMessage = "Please select role and view name!"; } } else if (Command == "Remove") { if (!string.IsNullOrEmpty(form["ddlRole"]) && !string.IsNullOrEmpty(form["ddlView"])) { model.RoleName = form["ddlRole"]; model.ViewName = form["ddlView"]; dtObj = BLObj.checkPermissionForRole(model.RoleName, model.ViewName); if (dtObj.Rows.Count > 0) { BLObj.removePermissionForRole(model.RoleName, Convert.ToInt32(model.ViewName)); getDisplayData(ref model); ViewBag.ClassName = "bg-success text-success"; ViewBag.ResultMessage = "Selected View Access denied to selected role successfully !"; } else { getDisplayData(ref model); ViewBag.ClassName = "bg-danger text-danger"; ViewBag.ResultMessage = "Selected View has already been denied access to selected role!"; } } else { getDisplayData(ref model); ViewBag.ClassName = "bg-danger text-danger"; ViewBag.ResultMessage = "Please select role and view name!"; } } return View(model); }
public ActionResult ManagePermissions(string RoleName) { var model = new ManagePermissions(); model.RoleName = RoleName; getDisplayData(ref model); if (Request.IsAjaxRequest()) { return PartialView("_webgridManagePermissions", model); } return View(model); }
private void getDisplayData(ref ManagePermissions model) { List<SelectListItem> ListRoles = new List<SelectListItem>(); var AllRoleNames = Roles.GetAllRoles(); foreach (var role in AllRoleNames) { ListRoles.Add(new SelectListItem { Text = role, Value = role }); } model.ListRoles = ListRoles; System.Data.DataTable dt = new System.Data.DataTable(); dt = BLObj.GetAllViewNames(); List<SelectListItem> ListViews = new List<SelectListItem>(); foreach (System.Data.DataRow dr in dt.Rows) { ListViews.Add(new SelectListItem { Value = dr[0].ToString(), Text = dr[1].ToString() }); } model.ListViews = ListViews; List<ManagePermissions> ListGridData = new List<ManagePermissions>(); System.Data.DataTable dt1 = new System.Data.DataTable(); if (!string.IsNullOrEmpty(model.RoleName)) { dt1 = BLObj.getParticularRolesPermissions(model.RoleName); } else { dt1 = BLObj.getAllRolesPermissions(); } foreach (System.Data.DataRow dr in dt1.Rows) { ListGridData.Add(new ManagePermissions { id = Convert.ToInt32(dr[0].ToString()), RoleName = dr[1].ToString(), ViewName = dr[2].ToString() }); } model.ModelList = ListGridData; }
private ManagePermissions Permissions(string projectId, string itemId, string itemPath) => ManagePermissions .ForReleasePipeline(_client, projectId, itemId, itemPath) .Permissions(Release.DeleteReleasePipelines, Release.AdministerReleasePermissions, Release.DeleteReleases) .Allow(PermissionId.NotSet, PermissionId.Deny, PermissionId.DenyInherited) .Ignore("Project Collection Administrators");