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);
}
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);
}
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());
}
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);
}
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;
}
Aggregations