コード例 #1
0
 @Test
 public void shouldReturnTheCorrectLocalizedMessageWhenUserDoesNotHavePermissionToDelete()
     throws IOException, NoSuchEnvironmentException {
   configHelper.addEnvironments("foo");
   configHelper.turnOnSecurity();
   configHelper.addAdmins("super_hero");
   HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
   service.deleteEnvironment(
       service.getEnvironmentConfig("foo"),
       new Username(new CaseInsensitiveString("evil_hacker")),
       result);
   assertThat(
       result.message(localizer),
       is(
           "Failed to delete environment 'foo'. User 'evil_hacker' does not have permission to update environments"));
 }
コード例 #2
0
  @Test
  public void shouldDeleteAnEnvironment() throws Exception {
    String environmentName = "dev";
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    goConfigService.addEnvironment(
        new BasicEnvironmentConfig(new CaseInsensitiveString(environmentName)));

    assertTrue(goConfigService.hasEnvironmentNamed(new CaseInsensitiveString(environmentName)));
    service.deleteEnvironment(
        service.getEnvironmentConfig(environmentName),
        new Username(new CaseInsensitiveString("foo")),
        result);
    assertFalse(goConfigService.hasEnvironmentNamed(new CaseInsensitiveString(environmentName)));
    assertThat(
        result.message(localizer), containsString("Environment 'dev' was deleted successfully."));
  }