Search in sources :

Example 11 with Service

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

the class ServicesManagerEntryIntegrationTest method removeAllDestinationsWithFacility.

@Test
public void removeAllDestinationsWithFacility() throws Exception {
    System.out.println(CLASS_NAME + "removeAllDestinationsWithFacility");
    List<Service> services = setUpServices();
    facility = setUpFacility();
    destination = setUpDestination();
    Destination dest1 = perun.getServicesManager().addDestination(sess, services.get(0), facility, destination);
    Destination dest2 = perun.getServicesManager().addDestination(sess, services.get(1), facility, destination);
    List<Destination> destinations = perun.getServicesManagerBl().getDestinations(sess, facility);
    assertTrue("There need to be dest1", destinations.contains(dest1));
    assertTrue("There need to be dest2", destinations.contains(dest2));
    perun.getServicesManagerBl().removeAllDestinations(sess, facility);
    destinations = perun.getServicesManagerBl().getDestinations(sess, facility);
    assertTrue("All destinations should be removed", destinations.isEmpty());
}
Also used : Destination(cz.metacentrum.perun.core.api.Destination) RichDestination(cz.metacentrum.perun.core.api.RichDestination) Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 12 with Service

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

the class ServicesManagerEntryIntegrationTest method updateServiceWhenServiceNotExists.

@Test(expected = ServiceNotExistsException.class)
public void updateServiceWhenServiceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "updateServiceWhenServiceNotExists");
    perun.getServicesManager().updateService(sess, new Service());
// shouldn't find Service
}
Also used : Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 13 with Service

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

the class ServicesManagerEntryIntegrationTest method removeServiceFromServicesPackageWhenServiceNotExists.

@Test(expected = ServiceNotExistsException.class)
public void removeServiceFromServicesPackageWhenServiceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "removeServiceFromServicesPackageWhenServiceNotExists");
    service = setUpService();
    assertNotNull("unable to create service in DB", service);
    servicesPackage = setUpServicesPackage(service);
    perun.getServicesManager().removeServiceFromServicesPackage(sess, servicesPackage, new Service());
// shouldn't find service
}
Also used : Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 14 with Service

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

the class AttributesManagerEntry method getRequiredAttributes.

public List<Attribute> getRequiredAttributes(PerunSession sess, List<Service> services, Resource resource) throws PrivilegeException, InternalErrorException, ResourceNotExistsException, ServiceNotExistsException {
    Utils.checkPerunSession(sess);
    getPerunBl().getResourcesManagerBl().checkResourceExists(sess, resource);
    for (Service s : services) getPerunBl().getServicesManagerBl().checkServiceExists(sess, s);
    List<Attribute> attributes = attributesManagerBl.getRequiredAttributes(sess, services, resource);
    Iterator<Attribute> attrIter = attributes.iterator();
    //Choose to which attributes has the principal access
    while (attrIter.hasNext()) {
        Attribute attrNext = attrIter.next();
        if (!AuthzResolver.isAuthorizedForAttribute(sess, ActionType.READ, attrNext, resource, null))
            attrIter.remove();
        else
            attrNext.setWritable(AuthzResolver.isAuthorizedForAttribute(sess, ActionType.WRITE, attrNext, resource, null));
    }
    return attributes;
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) Service(cz.metacentrum.perun.core.api.Service)

Example 15 with Service

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

the class AttributesManagerEntryIntegrationTest method getServiceRequiredResourceAttributes.

@Test
public void getServiceRequiredResourceAttributes() throws Exception {
    System.out.println(CLASS_NAME + "getServiceRequiredResourceAttributes");
    vo = setUpVo();
    facility = setUpFacility();
    resource = setUpResource();
    service = setUpService();
    attributes = setUpRequiredAttributes();
    perun.getResourcesManager().assignService(sess, resource, service);
    Service service2 = setUpService2();
    Attribute attr = setUpResourceRequiredAttributeForService(service2);
    perun.getResourcesManager().assignService(sess, resource, service2);
    List<Service> serviceList = new ArrayList<>();
    serviceList.add(service);
    List<Attribute> reqAttr = attributesManager.getRequiredAttributes(sess, serviceList, resource);
    assertNotNull("unable to get required resource attributes for its services", reqAttr);
    assertTrue("should have only 1 req resource attribute", reqAttr.size() == 1);
    serviceList.add(service2);
    reqAttr = attributesManager.getRequiredAttributes(sess, serviceList, resource);
    assertNotNull("unable to get required resource attributes for its services", reqAttr);
    assertTrue("should have only 1 req resource attribute", reqAttr.size() == 2);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) ArrayList(java.util.ArrayList) Service(cz.metacentrum.perun.core.api.Service) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

Service (cz.metacentrum.perun.core.api.Service)66 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)44 Test (org.junit.Test)44 ArrayList (java.util.ArrayList)11 Facility (cz.metacentrum.perun.core.api.Facility)10 Destination (cz.metacentrum.perun.core.api.Destination)9 Member (cz.metacentrum.perun.core.api.Member)8 ExecService (cz.metacentrum.perun.taskslib.model.ExecService)8 User (cz.metacentrum.perun.core.api.User)6 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)6 Attribute (cz.metacentrum.perun.core.api.Attribute)5 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)5 Group (cz.metacentrum.perun.core.api.Group)5 Host (cz.metacentrum.perun.core.api.Host)5 Resource (cz.metacentrum.perun.core.api.Resource)5 RichDestination (cz.metacentrum.perun.core.api.RichDestination)5 RichUser (cz.metacentrum.perun.core.api.RichUser)5 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)4 PerunClient (cz.metacentrum.perun.core.api.PerunClient)4 PerunPrincipal (cz.metacentrum.perun.core.api.PerunPrincipal)4