@Test
 public void shouldReturnTrueIfUserHasOperatePermission() {
   PipelineConfigs group = createWithPipeline(PipelineConfigMother.pipelineConfig("pipeline1"));
   group
       .getAuthorization()
       .getOperationConfig()
       .add(new AdminUser(new CaseInsensitiveString("jez")));
   assertThat(group.hasOperatePermission(new CaseInsensitiveString("jez"), null), is(true));
 }
Example #2
0
  public boolean hasOperatePermissionForGroup(
      final CaseInsensitiveString username, String groupName) {
    CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();

    if (!cruiseConfig.isSecurityEnabled()) {
      return true;
    }

    if (isUserAdmin(new Username(username))) {
      return true;
    }

    PipelineConfigs group = cruiseConfig.getGroups().findGroup(groupName);
    return isUserAdminOfGroup(username, group)
        || group.hasOperatePermission(
            username, new UserRoleMatcherImpl(cruiseConfig.server().security()));
  }