use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method removeAllDestinationsWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void removeAllDestinationsWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "removeAllDestinationsWhenServiceNotExists");
facility = setUpFacility();
perun.getServicesManager().removeAllDestinations(sess, new Service(), facility);
// shouldn't find service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method addHostSameDestinationDifferentAdmin.
@Test(expected = PrivilegeException.class)
public void addHostSameDestinationDifferentAdmin() throws Exception {
System.out.println(CLASS_NAME + "addHostSameDestinationDifferentAdmin");
// Initialize host, destination and service
String hostName = "TestHost";
Host host = new Host(0, hostName);
Destination destination = new Destination(0, hostName, Destination.DESTINATIONHOSTTYPE);
Service service = new Service(0, "testService");
ServicesManager servicesManagerEntry = perun.getServicesManager();
service = servicesManagerEntry.createService(sess, service);
// Creates second facility
Facility secondFacility = new Facility(0, "TestSecondFacility", "TestDescriptionText");
assertNotNull(perun.getFacilitiesManager().createFacility(sess, secondFacility));
// Set up two members
Member memberOne = setUpMember(vo);
Member memberTwo = setUpMember(vo);
// Set users as admins of different facilities
User userOne = perun.getUsersManagerBl().getUserByMember(sess, memberOne);
facilitiesManagerEntry.addAdmin(sess, facility, userOne);
User userTwo = perun.getUsersManagerBl().getUserByMember(sess, memberTwo);
facilitiesManagerEntry.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
servicesManagerEntry.addDestination(sess, service, facility, destination);
assertTrue(servicesManagerEntry.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 host as destination to secondFacility with different admin -> should throw exception
facilitiesManagerEntry.addHost(sess, host, secondFacility);
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRequiredGroupAttributesFromOneServiceWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void getRequiredGroupAttributesFromOneServiceWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "getRequiredGroupAttributesFromOneServiceWhenServiceNotExists");
vo = setUpVo();
group = setUpGroup();
attributesManager.getRequiredAttributes(sess, new Service(), group);
// shouldn't find service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRequiredGroupResourceAttributesFromOneServiceWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void getRequiredGroupResourceAttributesFromOneServiceWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "getRequiredGroupResourceAttributesFromOneServiceWhenServiceNotExists");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
group = setUpGroup();
attributesManager.getRequiredAttributes(sess, new Service(), resource, group);
// shouldn't find service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method addHostsStringsSameDestinationDifferentAdmin.
@Test(expected = PrivilegeException.class)
public void addHostsStringsSameDestinationDifferentAdmin() throws Exception {
System.out.println(CLASS_NAME + "addHostsStringsSameDestinationDifferentAdmin");
// Sets list of hostnames
String hostName = "testHostOne";
List<String> listOfHosts = new ArrayList<String>();
listOfHosts.add(hostName);
hostName = "testHostTwo";
listOfHosts.add(hostName);
// Initialize destination and service
Destination destination = new Destination(0, hostName, Destination.DESTINATIONHOSTTYPE);
Service service = new Service(0, "testService");
ServicesManager servicesManagerEntry = perun.getServicesManager();
service = servicesManagerEntry.createService(sess, service);
// Creates second facility
Facility secondFacility = new Facility(0, "TestSecondFacility", "TestDescriptionText");
assertNotNull(perun.getFacilitiesManager().createFacility(sess, secondFacility));
// Set up two members
Member memberOne = setUpMember(vo);
Member memberTwo = setUpMember(vo);
// Set users as admins of different facilities
User userOne = perun.getUsersManagerBl().getUserByMember(sess, memberOne);
facilitiesManagerEntry.addAdmin(sess, facility, userOne);
User userTwo = perun.getUsersManagerBl().getUserByMember(sess, memberTwo);
facilitiesManagerEntry.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
servicesManagerEntry.addDestination(sess, service, facility, destination);
assertTrue(servicesManagerEntry.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 host as destination to secondFacility with different admin -> should throw exception
facilitiesManagerEntry.addHosts(sess, secondFacility, listOfHosts);
}
Aggregations