@Before
 public void setup() throws Exception {
   dataSource.reloadEveryTime();
   configHelper.usingCruiseConfigDao(goConfigDao);
   configHelper.onSetUp();
   response = new MockHttpServletResponse();
   configHelper.addSecurityWithPasswordFile();
   configHelper.addAdmins("admin");
   setCurrentUser("admin");
 }
Пример #2
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"));
 }
Пример #3
0
 @Test
 public void shouldReturnTheCorrectLocalizedMessageForNoPermission() throws IOException {
   configHelper.turnOnSecurity();
   configHelper.addAdmins("super_hero");
   HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
   service.createEnvironment(
       env(
           "foo-env",
           new ArrayList<String>(),
           new ArrayList<Map<String, String>>(),
           new ArrayList<String>()),
       new Username(new CaseInsensitiveString("evil_hacker")),
       result);
   assertThat(
       result.message(localizer),
       is(
           "Failed to add environment. User 'evil_hacker' does not have permission to add environments"));
 }
Пример #4
0
 @Test
 public void shouldReturnTheCorrectLocalizedMessageWhenUserDoesNotHavePermissionToUpdate()
     throws IOException {
   configHelper.addEnvironments("foo");
   configHelper.turnOnSecurity();
   configHelper.addAdmins("super_hero");
   HttpLocalizedOperationResult result =
       service.updateEnvironment(
           "foo",
           env(
               "foo-env",
               new ArrayList<String>(),
               new ArrayList<Map<String, String>>(),
               new ArrayList<String>()),
           new Username(new CaseInsensitiveString("evil_hacker")),
           goConfigDao.md5OfConfigFile());
   assertThat(
       result.message(localizer),
       is(
           "Failed to update environment 'foo'. User 'evil_hacker' does not have permission to update environments"));
 }