@Test
  public void shouldNotContinueWhenTemplateNoLongerExists() {
    when(goConfigService.isAuthorizedToEditTemplate("template", currentUser)).thenReturn(true);

    DeleteTemplateConfigCommand command =
        new DeleteTemplateConfigCommand(
            pipelineTemplateConfig, result, goConfigService, currentUser);

    assertThat(command.canContinue(cruiseConfig), is(false));
  }
  @Test
  public void shouldNotContinueWithConfigSaveIfUserIsUnauthorized() {
    when(goConfigService.isAuthorizedToEditTemplate("template", currentUser)).thenReturn(false);

    DeleteTemplateConfigCommand command =
        new DeleteTemplateConfigCommand(
            pipelineTemplateConfig, result, goConfigService, currentUser);

    assertThat(command.canContinue(cruiseConfig), is(false));
    assertThat(result.toString(), containsString("UNAUTHORIZED_TO_EDIT"));
  }
Beispiel #3
0
 public boolean isAuthorizedToEditTemplate(String templateName, Username username) {
   return goConfigService.isAuthorizedToEditTemplate(templateName, username);
 }