Search in sources :

Example 26 with Facility

use of cz.metacentrum.perun.core.api.Facility 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)

Example 27 with Facility

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

the class ServicesManagerEntryIntegrationTest method addDestinationSameDestinationDifferentAdmin.

@Test(expected = PrivilegeException.class)
public void addDestinationSameDestinationDifferentAdmin() throws Exception {
    System.out.println(CLASS_NAME + "addDestinationSameDestinationDifferentAdmin");
    vo = setUpVo();
    facility = setUpFacility();
    resource = setUpResource();
    service = setUpService();
    Destination testDestination = new Destination(0, "TestDestination", Destination.DESTINATIONHOSTTYPE);
    member = setUpMember();
    Member memberTwo = setUpMember();
    // Creates second facility
    Facility secondFacility = new Facility(0, "TestSecondFacility", "TestDescriptionText");
    assertNotNull(perun.getFacilitiesManager().createFacility(sess, secondFacility));
    // Set users as admins of different facilities
    User userOne = perun.getUsersManagerBl().getUserByMember(sess, member);
    perun.getFacilitiesManager().addAdmin(sess, facility, userOne);
    User userTwo = perun.getUsersManagerBl().getUserByMember(sess, memberTwo);
    perun.getFacilitiesManager().addAdmin(sess, secondFacility, userTwo);
    // Sets userOne as actor in this test with role facility admin for facility
    AuthzRoles authzRoles = new AuthzRoles(Role.FACILITYADMIN, facility);
    sess.getPerunPrincipal().setRoles(authzRoles);
    sess.getPerunPrincipal().setUser(userOne);
    // Adds destination to facility
    perun.getServicesManager().addDestination(sess, service, facility, testDestination);
    assertTrue(perun.getServicesManager().getDestinations(sess, service, facility).size() == 1);
    // Change actor in this test to userTwo
    authzRoles = new AuthzRoles(Role.FACILITYADMIN, secondFacility);
    sess.getPerunPrincipal().setRoles(authzRoles);
    sess.getPerunPrincipal().setUser(userTwo);
    // Adds same destination to secondFacility -> should throw exception
    perun.getServicesManager().addDestination(sess, service, secondFacility, testDestination);
}
Also used : Destination(cz.metacentrum.perun.core.api.Destination) RichDestination(cz.metacentrum.perun.core.api.RichDestination) User(cz.metacentrum.perun.core.api.User) AuthzRoles(cz.metacentrum.perun.core.impl.AuthzRoles) Facility(cz.metacentrum.perun.core.api.Facility) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 28 with Facility

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

the class ServicesManagerEntryIntegrationTest method setUpNonClusterFacilityWithTwoHosts.

private Facility setUpNonClusterFacilityWithTwoHosts() throws Exception {
    Facility facility = new Facility();
    facility.setName("ServicesManagerTestNonClusterFacility");
    facility = perun.getFacilitiesManager().createFacility(sess, facility);
    // add first host
    Host host1 = new Host();
    host1.setHostname("testing_host_1");
    // add second host
    Host host2 = new Host();
    host2.setHostname("testing_host_2");
    List<Host> hosts = new ArrayList<Host>();
    hosts.add(host1);
    hosts.add(host2);
    perun.getFacilitiesManager().addHosts(sess, hosts, facility);
    return facility;
}
Also used : ArrayList(java.util.ArrayList) Host(cz.metacentrum.perun.core.api.Host) Facility(cz.metacentrum.perun.core.api.Facility)

Example 29 with Facility

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

the class ServicesManagerEntryIntegrationTest method setUpClusterFacility.

private Facility setUpClusterFacility() throws Exception {
    Facility facility = new Facility();
    facility.setName("ServicesManagerTestClusterFacility");
    facility = perun.getFacilitiesManager().createFacility(sess, facility);
    // add one host
    Host host = new Host();
    host.setHostname("test.test");
    List<Host> hosts = new ArrayList<Host>();
    hosts.add(host);
    perun.getFacilitiesManager().addHosts(sess, hosts, facility);
    return facility;
}
Also used : ArrayList(java.util.ArrayList) Host(cz.metacentrum.perun.core.api.Host) Facility(cz.metacentrum.perun.core.api.Facility)

Example 30 with Facility

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

the class urn_perun_facility_attribute_def_def_homeMountPointsTest method testCheckAttributeValue.

/**
	 * Test of checkAttributeValue method, of class urn_perun_facility_attribute_def_def_homeMountPoints.
	 * with all properly set
	 */
@Test
public void testCheckAttributeValue() throws Exception {
    System.out.println("testCheckAttributeValue()");
    ArrayList<String> homeMountPts = new ArrayList<String>();
    homeMountPts.add("/mnt/mymountpoint1");
    homeMountPts.add("/mnt/mymountpoint2");
    attribute.setValue(homeMountPts);
    classInstance.checkAttributeValue(session, new Facility(), attribute);
}
Also used : ArrayList(java.util.ArrayList) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

Aggregations

Facility (cz.metacentrum.perun.core.api.Facility)188 Test (org.junit.Test)95 User (cz.metacentrum.perun.core.api.User)81 Attribute (cz.metacentrum.perun.core.api.Attribute)75 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)61 Resource (cz.metacentrum.perun.core.api.Resource)52 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)51 ArrayList (java.util.ArrayList)48 Group (cz.metacentrum.perun.core.api.Group)24 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)23 Member (cz.metacentrum.perun.core.api.Member)22 PerunSession (cz.metacentrum.perun.core.api.PerunSession)20 RichFacility (cz.metacentrum.perun.core.api.RichFacility)20 Host (cz.metacentrum.perun.core.api.Host)19 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)18 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)17 RichUser (cz.metacentrum.perun.core.api.RichUser)16 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)15 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)14 Vo (cz.metacentrum.perun.core.api.Vo)13