Search in sources :

Example 11 with SecurityTeam

use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.

the class SecurityTeamsManagerEntryIntegrationTest method testGetSecurityTeamsSecurityAdmin1.

@Test
public void testGetSecurityTeamsSecurityAdmin1() throws Exception {
    System.out.println(CLASS_NAME + "testGetSecurityTeamsSecurityAdmin1");
    AuthzRoles roles = sess.getPerunPrincipal().getRoles();
    try {
        setUpSecurityTeams();
        setUpUsers();
        List<SecurityTeam> expected = new ArrayList<>();
        expected.add(st0);
        expected.add(st1);
        sess.getPerunPrincipal().setRoles(new AuthzRoles(Role.SECURITYADMIN, expected));
        List<SecurityTeam> actual = securityTeamsManagerEntry.getSecurityTeams(sess);
        Collections.sort(expected);
        Collections.sort(actual);
        assertEquals(expected, actual);
    } finally {
        sess.getPerunPrincipal().setRoles(roles);
    }
}
Also used : AuthzRoles(cz.metacentrum.perun.core.impl.AuthzRoles) SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 12 with SecurityTeam

use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.

the class SecurityTeamsManagerEntryIntegrationTest method testGetSecurityTeamById.

@Test
public void testGetSecurityTeamById() throws Exception {
    System.out.println(CLASS_NAME + "testGetSecurityTeamById");
    SecurityTeam expected = setUpSecurityTeams().get(0);
    SecurityTeam actual = securityTeamsManagerEntry.getSecurityTeamById(sess, expected.getId());
    assertEquals(expected, actual);
}
Also used : SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 13 with SecurityTeam

use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.

the class SecurityTeamsManagerEntryIntegrationTest method testRemoveUserFromBlacklistSecurityTeamNotExists.

@Test(expected = SecurityTeamNotExistsException.class)
public void testRemoveUserFromBlacklistSecurityTeamNotExists() throws Exception {
    System.out.println(CLASS_NAME + "testRemoveUserFromBlacklistSecurityTeamNotExists");
    setUpSecurityTeams();
    setUpUsers();
    setUpFacilities();
    setUpBlacklists();
    SecurityTeam st = new SecurityTeam(0, "Security0", "Description test 0");
    securityTeamsManagerEntry.removeUserFromBlacklist(sess, st, u1);
}
Also used : SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 14 with SecurityTeam

use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.

the class SecurityTeamsManagerEntryIntegrationTest method testCreateSecurityTeamUniqueName.

@Test(expected = SecurityTeamExistsException.class)
public void testCreateSecurityTeamUniqueName() throws Exception {
    System.out.println(CLASS_NAME + "testCreateSecurityTeamUniqueName");
    securityTeamsManagerEntry.createSecurityTeam(sess, new SecurityTeam("UniqueName", "Desc 1"));
    securityTeamsManagerEntry.createSecurityTeam(sess, new SecurityTeam("UniqueName", "Desc 2"));
}
Also used : SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 15 with SecurityTeam

use of cz.metacentrum.perun.core.api.SecurityTeam in project perun by CESNET.

the class SecurityTeamsManagerEntryIntegrationTest method testUpdateSecurityTeam.

@Test
public void testUpdateSecurityTeam() throws Exception {
    System.out.println(CLASS_NAME + "testUpdateSecurityTeam");
    List<SecurityTeam> teams = setUpSecurityTeams();
    SecurityTeam expected = teams.get(0);
    expected.setName("Updated");
    SecurityTeam middle = securityTeamsManagerEntry.updateSecurityTeam(sess, expected);
    assertNotNull(middle);
    assertEquals(expected, middle);
    SecurityTeam actual = securityTeamsManagerEntry.getSecurityTeamById(sess, expected.getId());
    assertNotNull(actual);
    assertEquals(expected, actual);
}
Also used : SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) 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