Search in sources :

Example 81 with Resource

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

the class urn_perun_user_facility_attribute_def_def_shellTest method testCheckAttributeValueOfUnknownUser.

@Test(expected = WrongReferenceAttributeValueException.class)
public void testCheckAttributeValueOfUnknownUser() throws Exception {
    System.out.println("testCheckAttributeValueOfUnknownUser()");
    when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSession.class), any(Facility.class), any(User.class))).thenReturn(new ArrayList<Resource>());
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenReturn(listOfShells);
    Attribute atr = new Attribute();
    atr.setValue(("/bin/bash"));
    classInstance.checkAttributeValue(session, facility, user, atr);
}
Also used : PerunSession(cz.metacentrum.perun.core.api.PerunSession) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) Resource(cz.metacentrum.perun.core.api.Resource) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

Example 82 with Resource

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

the class urn_perun_user_facility_attribute_def_def_shellTest method testCheckAttributeValue.

/**
	 * Test of checkAttributeValue method, of class urn_perun_user_facility_attribute_def_def_shell.
	 * with all parameters properly set.
	 */
@Test
public void testCheckAttributeValue() throws Exception {
    System.out.println("testCheckAttributeValue()");
    Attribute attributeToCheck = new Attribute();
    attributeToCheck.setValue("/bin/bash");
    when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSession.class), any(Facility.class), any(User.class))).thenReturn(new ArrayList<Resource>() {

        {
            add(resource);
        }
    });
    when(session.getPerunBl().getFacilitiesManagerBl().getAssignedResources(any(PerunSession.class), any(Facility.class))).thenReturn(new ArrayList<Resource>() {

        {
            add(resource);
        }
    });
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), eq(AttributesManager.NS_RESOURCE_ATTR_DEF + ":shells"))).thenReturn(listOfShells);
    classInstance.checkAttributeValue(session, facility, user, attributeToCheck);
}
Also used : PerunSession(cz.metacentrum.perun.core.api.PerunSession) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) Resource(cz.metacentrum.perun.core.api.Resource) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

Example 83 with Resource

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

the class urn_perun_user_facility_attribute_def_def_shellTest method testCheckAttributeValueWithEmptyAttribute.

/**
	 * Test of checkAttributeValue method, of class urn_perun_user_facility_attribute_def_def_shell.
	 * with empty attribute.
	 */
public void testCheckAttributeValueWithEmptyAttribute() throws Exception {
    System.out.println("testCheckAttributeValueWithEmptyAttribute()");
    when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSession.class), any(Facility.class), any(User.class))).thenReturn(new ArrayList<Resource>() {

        {
            add(resource);
        }
    });
    when(session.getPerunBl().getFacilitiesManagerBl().getAssignedResources(any(PerunSession.class), any(Facility.class))).thenReturn(new ArrayList<Resource>() {

        {
            add(resource);
        }
    });
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenReturn(listOfShells);
    classInstance.checkAttributeValue(session, facility, user, new Attribute());
}
Also used : PerunSession(cz.metacentrum.perun.core.api.PerunSession) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) Resource(cz.metacentrum.perun.core.api.Resource) Facility(cz.metacentrum.perun.core.api.Facility)

Example 84 with Resource

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

the class FacilitiesManagerBlImpl method getAllowedUsers.

@Override
public List<User> getAllowedUsers(PerunSession sess, Facility facility) throws InternalErrorException {
    //Get all facilities resources
    List<Resource> resources = this.getAssignedResources(sess, facility);
    Set<User> users = new TreeSet<User>();
    for (Resource resource : resources) {
        users.addAll(getPerunBl().getResourcesManagerBl().getAllowedUsers(sess, resource));
    }
    return new ArrayList<>(users);
}
Also used : User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) TreeSet(java.util.TreeSet) Resource(cz.metacentrum.perun.core.api.Resource) RichResource(cz.metacentrum.perun.core.api.RichResource) ArrayList(java.util.ArrayList)

Example 85 with Resource

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

the class ServicesManagerBlImpl method getDataWithGroups.

public ServiceAttributes getDataWithGroups(PerunSession sess, Service service, Facility facility) throws InternalErrorException {
    ServiceAttributes serviceAttributes = new ServiceAttributes();
    serviceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility));
    List<Resource> resources = getPerunBl().getFacilitiesManagerBl().getAssignedResources(sess, facility);
    resources.retainAll(getAssignedResources(sess, service));
    for (Resource resource : resources) {
        ServiceAttributes resourceServiceAttributes = getDataWithGroups(sess, service, facility, resource);
        serviceAttributes.addChildElement(resourceServiceAttributes);
    }
    return serviceAttributes;
}
Also used : ServiceAttributes(cz.metacentrum.perun.core.api.ServiceAttributes) Resource(cz.metacentrum.perun.core.api.Resource)

Aggregations

Resource (cz.metacentrum.perun.core.api.Resource)176 Test (org.junit.Test)110 Attribute (cz.metacentrum.perun.core.api.Attribute)82 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)79 Facility (cz.metacentrum.perun.core.api.Facility)56 User (cz.metacentrum.perun.core.api.User)55 Group (cz.metacentrum.perun.core.api.Group)49 ArrayList (java.util.ArrayList)41 Vo (cz.metacentrum.perun.core.api.Vo)31 Member (cz.metacentrum.perun.core.api.Member)29 PerunSession (cz.metacentrum.perun.core.api.PerunSession)29 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)26 RichResource (cz.metacentrum.perun.core.api.RichResource)25 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)20 RichUser (cz.metacentrum.perun.core.api.RichUser)18 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)18 ContactGroup (cz.metacentrum.perun.core.api.ContactGroup)17 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)17 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)15 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)14