use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class SecurityTeamsManagerImpl method getBlacklist.
@Override
public List<User> getBlacklist(PerunSession sess, List<SecurityTeam> securityTeams) throws InternalErrorException {
try {
Set<User> blacklisted = new HashSet<>();
List<User> list;
for (SecurityTeam st : securityTeams) {
list = jdbc.query("select " + UsersManagerImpl.userMappingSelectQuery + " from users inner join (" + "select blacklists.user_id from blacklists where security_team_id=?" + ") " + Compatibility.getAsAlias("blacklisted_ids") + " ON users.id=blacklisted_ids.user_id", UsersManagerImpl.USER_MAPPER, st.getId());
blacklisted.addAll(list);
}
return new ArrayList<>(blacklisted);
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method removeSecurityTeam.
@Test
public void removeSecurityTeam() throws Exception {
System.out.println(CLASS_NAME + "removeSecurityTeam");
SecurityTeam st0 = setUpSecurityTeam0();
SecurityTeam st1 = setUpSecurityTeam1();
List<SecurityTeam> expected = new ArrayList<>();
expected.add(st0);
expected.add(st1);
setUpAssignSecurityTeams(facility, expected);
setUpSecurityTeam2();
facilitiesManagerEntry.removeSecurityTeam(sess, facility, st0);
expected.remove(st0);
List<SecurityTeam> actual = facilitiesManagerEntry.getAssignedSecurityTeams(sess, facility);
assertTrue("Facility should have only 1 security team.", actual.size() == 1);
assertTrue("Facility shouldn't have security team 0 assigned.", !actual.contains(st0));
assertTrue("Facility should have security team 1 assigned.", actual.contains(st1));
}
use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method removeSecurityTeamSecurityTeamNotExists.
@Test(expected = SecurityTeamNotExistsException.class)
public void removeSecurityTeamSecurityTeamNotExists() throws Exception {
System.out.println(CLASS_NAME + "removeSecurityTeamSecurityTeamNotExists");
List<SecurityTeam> expected = new ArrayList<>();
expected.add(setUpSecurityTeam0());
expected.add(setUpSecurityTeam1());
setUpAssignSecurityTeams(facility, expected);
setUpSecurityTeam2();
// should throw an exception
facilitiesManagerEntry.removeSecurityTeam(sess, facility, new SecurityTeam(0, "name", "dsc"));
}
use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method assignSecurityTeamAlreadyAssigned.
@Test(expected = SecurityTeamAlreadyAssignedException.class)
public void assignSecurityTeamAlreadyAssigned() throws Exception {
System.out.println(CLASS_NAME + "assignSecurityTeamAlreadyAssigned");
SecurityTeam st0 = setUpSecurityTeam0();
List<SecurityTeam> expected = new ArrayList<>();
expected.add(st0);
expected.add(setUpSecurityTeam1());
setUpAssignSecurityTeams(facility, expected);
setUpSecurityTeam2();
// should throw an exception
facilitiesManagerEntry.assignSecurityTeam(sess, facility, st0);
}
use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method removeSecurityTeamFacilityNotExists.
@Test(expected = FacilityNotExistsException.class)
public void removeSecurityTeamFacilityNotExists() throws Exception {
System.out.println(CLASS_NAME + "removeSecurityTeamFacilityNotExists");
SecurityTeam st0 = setUpSecurityTeam0();
setUpSecurityTeam1();
// should throw an exception
facilitiesManagerEntry.removeSecurityTeam(sess, new Facility(0, "Name"), st0);
}
Aggregations