Search in sources :

Example 1 with SecurityTeam

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);
    }
}
Also used : User(cz.metacentrum.perun.core.api.User) ArrayList(java.util.ArrayList) SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) HashSet(java.util.HashSet)

Example 2 with SecurityTeam

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));
}
Also used : ArrayList(java.util.ArrayList) SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 3 with SecurityTeam

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"));
}
Also used : ArrayList(java.util.ArrayList) SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 4 with SecurityTeam

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);
}
Also used : ArrayList(java.util.ArrayList) SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 5 with SecurityTeam

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);
}
Also used : SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) BanOnFacility(cz.metacentrum.perun.core.api.BanOnFacility) Facility(cz.metacentrum.perun.core.api.Facility) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

SecurityTeam (cz.metacentrum.perun.core.api.SecurityTeam)37 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)30 Test (org.junit.Test)30 ArrayList (java.util.ArrayList)4 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)3 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)3 AuthzRoles (cz.metacentrum.perun.core.impl.AuthzRoles)3 Facility (cz.metacentrum.perun.core.api.Facility)2 Group (cz.metacentrum.perun.core.api.Group)2 ContactGroup (cz.metacentrum.perun.core.api.ContactGroup)1 Host (cz.metacentrum.perun.core.api.Host)1 User (cz.metacentrum.perun.core.api.User)1 BanNotExistsException (cz.metacentrum.perun.core.api.exceptions.BanNotExistsException)1 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)1 RelationExistsException (cz.metacentrum.perun.core.api.exceptions.RelationExistsException)1 SecurityTeamExistsException (cz.metacentrum.perun.core.api.exceptions.SecurityTeamExistsException)1 SecurityTeamNotExistsException (cz.metacentrum.perun.core.api.exceptions.SecurityTeamNotExistsException)1 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)1 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)1 HashSet (java.util.HashSet)1