Example #1
0
 protected void assertFails(Fixture fixture, Map<String, List<String>> users) {
   LdapImpl ldap = fixture.ldap;
   for (String user : users.keySet()) {
     assertEquals(1, users.get(user).size());
     try {
       String dn = ldap.findDN(user);
       assertNotNull(dn);
       fixture.createUserWithGroup(this, dn, users.get(user).get(0));
       assertNotNull(fixture.createUser(user, "password", true));
       fixture.login(user, users.get(user).get(0), "password");
       // Parsing afterwards to force an explosion to reproduce #2557
       assertEquals(user, ldap.findExperimenter(user).getOmeName());
       fail("user didn't fail");
     } catch (ValidationException e) {
       if (e.getMessage().equals("No group found for: cn=user,ou=attributeFilter")) {
         // Good. This is the expected result for #8357
       } else {
         throw e;
         // This means that we couldn't insert.
         // See the thread on case-sensitivity in #2557
       }
     } catch (ApiUsageException e) {
       // If not a ValidationException, but otherwise an
       // ApiUsageException, then this will be the
       // "Cannot find unique DN" which we are looking for.
     } catch (SecurityViolation sv) {
       // e.g. User 466 is not a member of group 54 and cannot login
       // Also good.
     }
   }
 }
Example #2
0
  @RolesAllowed("user")
  public void deleteImages(java.util.Set<Long> ids, boolean force)
      throws SecurityViolation, ValidationException, ApiUsageException {

    if (ids == null || ids.size() == 0) {
      return; // EARLY EXIT!
    }

    for (Long id : ids) {
      try {
        deleteImage(id, force);
      } catch (SecurityViolation sv) {
        throw new SecurityViolation("Error while deleting image " + id + "\n" + sv.getMessage());
      } catch (ValidationException ve) {
        throw new ValidationException("Error while deleting image " + id + "\n" + ve.getMessage());
      } catch (ApiUsageException aue) {
        throw new ApiUsageException("Error while deleting image " + id + "\n" + aue.getMessage());
      }
    }
  };