use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_homeMountPointTest method SetUp.
@Before
public void SetUp() {
listOfMntPts = new Attribute();
classInstance = new urn_perun_user_facility_attribute_def_def_homeMountPoint();
session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
ArrayList<String> mntPts = new ArrayList<String>();
mntPts.add("/mnt/mnt1");
mntPts.add("/tmp/mnt2");
listOfMntPts.setValue(mntPts);
user = new User();
facility = new Facility();
resource = new Resource();
resource.setName("myResource");
resource.setDescription("desc");
resource1 = new Resource();
resource1.setId(1);
resource1.setName("myResource");
resource1.setDescription("desc");
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_homeMountPointTest method testFillAttributeOfUnknownUser.
/**
* Test of fillAttribute method, of class urn_perun_user_facility_attribute_def_def_homeMountPoint.
* with user who does not have an access at specified resource.
*/
@Test
public void testFillAttributeOfUnknownUser() throws Exception {
System.out.println("testFillAttributeOfUnknownUser()");
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(listOfMntPts);
Attribute atr = classInstance.fillAttribute(session, facility, user, new AttributeDefinition());
assertNull("User's homeMountPoint was filled even they don't have an account there.", atr.getValue());
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_homeMountPointTest method testCheckAttributeValueWronghomeMountPointFormathomeMountPointIsDirectory.
@Test(expected = WrongAttributeValueException.class)
public void testCheckAttributeValueWronghomeMountPointFormathomeMountPointIsDirectory() throws Exception {
System.out.println("testCheckAttributeValueWronghomeMountPointFormathomeMountPointIsDirectory()");
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(listOfMntPts);
Attribute attributeToCheck = new Attribute();
attributeToCheck.setValue("/mnt/mnt1/");
classInstance.checkAttributeValue(session, facility, user, attributeToCheck);
fail("Wrong homeMountPoint format should have thrown an exception");
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_homeMountPointTest method testFillAttribute.
/**
* Test of fillAttribute method, of class urn_perun_user_facility_attribute_def_def_homeMountPoint.
* with all parameters properly set.
*/
@Test
public void testFillAttribute() throws Exception {
System.out.println("testFillAttribute()");
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(listOfMntPts);
Attribute filledAttribute = classInstance.fillAttribute(session, facility, user, new AttributeDefinition());
assertTrue("A different homeMountPoint was filled than those available", (listOfMntPts.getValue()).equals(filledAttribute.getValue()));
}
use of cz.metacentrum.perun.core.api.Facility 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);
}
Aggregations