Search in sources :

Example 51 with Attribute

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);
}
Also used : PerunSession(cz.metacentrum.perun.core.api.PerunSession) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

Example 52 with Attribute

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.");
}
Also used : PerunSession(cz.metacentrum.perun.core.api.PerunSession) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

Example 53 with Attribute

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");
}
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 54 with Attribute

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);
}
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 55 with Attribute

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

Aggregations

Attribute (cz.metacentrum.perun.core.api.Attribute)1689 Test (org.junit.Test)615 ArrayList (java.util.ArrayList)492 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)489 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)478 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)313 User (cz.metacentrum.perun.core.api.User)301 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)280 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)231 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)221 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)218 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)197 Facility (cz.metacentrum.perun.core.api.Facility)190 Resource (cz.metacentrum.perun.core.api.Resource)187 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)180 List (java.util.List)177 LinkedHashMap (java.util.LinkedHashMap)158 Before (org.junit.Before)156 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)145 Method (java.lang.reflect.Method)140