Exemplo n.º 1
0
 @Test
 public void shouldReturnFalseIfViewPermissionIsNotDefined() {
   PipelineConfigs group = createWithPipeline(PipelineConfigMother.pipelineConfig("pipeline1"));
   group
       .getAuthorization()
       .getOperationConfig()
       .add(new AdminUser(new CaseInsensitiveString("jez")));
   assertThat(group.hasViewPermission(new CaseInsensitiveString("jez"), null), is(false));
 }
Exemplo n.º 2
0
  public boolean hasViewPermissionForGroup(String userName, String pipelineGroupName) {
    CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();

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

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

    PipelineConfigs group = cruiseConfig.getGroups().findGroup(pipelineGroupName);
    return isUserAdminOfGroup(username, group)
        || group.hasViewPermission(
            username, new UserRoleMatcherImpl(cruiseConfig.server().security()));
  }
Exemplo n.º 3
0
 @Test
 public void shouldReturnTrueIfUserHasViewPermission() {
   PipelineConfigs group = createWithPipeline(PipelineConfigMother.pipelineConfig("pipeline1"));
   group.getAuthorization().getViewConfig().add(new AdminUser(new CaseInsensitiveString("jez")));
   assertThat(group.hasViewPermission(new CaseInsensitiveString("jez"), null), is(true));
 }