use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_accountExpirationTimeTest method testCheckAttributeValue.
@Test
public void testCheckAttributeValue() throws Exception {
System.out.println("testCheckAttributeValue()");
attributeToCheck.setValue(1000);
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Facility.class), anyString())).thenReturn(new Attribute() {
{
setValue(1500);
}
});
classInstance.checkAttributeValue(session, new Facility(), new User(), attributeToCheck);
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_accountExpirationTimeTest method testCheckAttributeValueHigherValueThanFacilityTime.
@Test(expected = WrongAttributeValueException.class)
public void testCheckAttributeValueHigherValueThanFacilityTime() throws Exception {
System.out.println("testCheckAttributeValueHigherValueThanFacilityTime()");
attributeToCheck.setValue(1000);
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Facility.class), anyString())).thenReturn(new Attribute() {
{
setValue(999);
}
});
classInstance.checkAttributeValue(session, new Facility(), new User(), attributeToCheck);
fail("Assigning lower accountExpirationTime than the time set at facility should throw exception.");
}
use of cz.metacentrum.perun.core.api.Attribute 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.Attribute 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.Attribute 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);
}
Aggregations