use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class RoleConfigUpdateCommandTest method shouldUpdateExistingRole.
@Test
public void shouldUpdateExistingRole() throws Exception {
PluginRoleConfig oldRole = new PluginRoleConfig("foo", "ldap");
PluginRoleConfig updatedRole = new PluginRoleConfig("foo", "github");
cruiseConfig.server().security().getRoles().add(oldRole);
RoleConfigCommand command = new RoleConfigUpdateCommand(null, updatedRole, null, null, null, null, null);
command.update(cruiseConfig);
assertThat(cruiseConfig.server().security().getRoles().findByName(new CaseInsensitiveString("foo")), is(equalTo(updatedRole)));
}
use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class RoleConfigUpdateCommandTest method shouldNotContinueWithConfigSaveIfRequestIsNotFresh.
@Test
public void shouldNotContinueWithConfigSaveIfRequestIsNotFresh() {
PluginRoleConfig oldRole = new PluginRoleConfig("foo", "ldap");
PluginRoleConfig updatedRole = new PluginRoleConfig("foo", "github");
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
cruiseConfig.server().security().getRoles().add(oldRole);
when(entityHashingService.md5ForEntity(oldRole)).thenReturn("md5");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
RoleConfigCommand command = new RoleConfigUpdateCommand(goConfigService, updatedRole, null, currentUser, result, entityHashingService, "bad-md5");
assertThat(command.canContinue(cruiseConfig), is(false));
assertThat(result.toString(), containsString("STALE_RESOURCE_CONFIG"));
}
use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class CcTrayJobStatusChangeHandlerTest method shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus.
@Test
public void shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus() throws Exception {
Users viewers = new AllowedUsers(s("viewer1", "viewer2"), Collections.singleton(new PluginRoleConfig("admin", "ldap")));
ProjectStatus oldStatusInCache = new ProjectStatus(projectNameFor("job1"), "OldActivity", "OldStatus", "OldLabel", new Date(), webUrlFor("job1"));
oldStatusInCache.updateViewers(viewers);
when(cache.get(projectNameFor("job1"))).thenReturn(oldStatusInCache);
CcTrayJobStatusChangeHandler handler = new CcTrayJobStatusChangeHandler(cache);
ProjectStatus newStatus = handler.statusFor(JobInstanceMother.building("job1"), new HashSet<>());
assertThat(newStatus.viewers(), is(viewers));
}
use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class AllowedUsersTest method usersShouldHaveViewPermissionIfTheyBelongToAllowedPluginRoles.
@Test
public void usersShouldHaveViewPermissionIfTheyBelongToAllowedPluginRoles() throws Exception {
PluginRoleConfig admin = new PluginRoleConfig("go_admins", "ldap");
pluginRoleUsersStore.assignRole("foo", admin);
AllowedUsers users = new AllowedUsers(Collections.emptySet(), Collections.singleton(admin));
assertTrue(users.contains("FOO"));
assertTrue(users.contains("foo"));
assertFalse(users.contains("bar"));
}
use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class RoleConfigCreateCommandTest method shouldAddPluginRoleConfig.
@Test
public void shouldAddPluginRoleConfig() throws Exception {
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
PluginRoleConfig role = new PluginRoleConfig("blackbird", "ldap");
RoleConfigCreateCommand command = new RoleConfigCreateCommand(null, role, extension, null, null);
command.update(cruiseConfig);
assertThat(cruiseConfig.server().security().getRoles().findByName(new CaseInsensitiveString("blackbird")), equalTo(role));
}
Aggregations