Search in sources :

Example 76 with Resource

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

the class urn_perun_user_facility_attribute_def_def_basicDefaultGIDTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_facility_attribute_def_def_basicDefaultGID();
    session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
    attrDef = session.getPerunBl().getAttributesManagerBl().getAttributeDefinition(session, AttributesManager.NS_USER_FACILITY_ATTR_DEF + "basicDefaultGID");
    user = new User();
    facility = new Facility(1, "testFa");
    basic = new Attribute();
    namespaceAttribute = new Attribute();
    namespaceAttribute.setValue("test");
    allowedResources = new ArrayList<>();
    allowedResourcesWithSameGid = new ArrayList<>();
    resource1 = new Resource(1, "test1", "desc", 1);
    resource2 = new Resource(2, "test2", "desc", 1);
    resource3 = new Resource(3, "test3", "desc", 1);
}
Also used : 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) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) Before(org.junit.Before)

Example 77 with Resource

use of cz.metacentrum.perun.core.api.Resource 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");
}
Also used : User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) ArrayList(java.util.ArrayList) Resource(cz.metacentrum.perun.core.api.Resource) Matchers.anyString(org.mockito.Matchers.anyString) Facility(cz.metacentrum.perun.core.api.Facility) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) Before(org.junit.Before)

Example 78 with Resource

use of cz.metacentrum.perun.core.api.Resource 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());
}
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) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

Example 79 with Resource

use of cz.metacentrum.perun.core.api.Resource 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 80 with Resource

use of cz.metacentrum.perun.core.api.Resource 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()));
}
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) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Facility(cz.metacentrum.perun.core.api.Facility) Test(org.junit.Test)

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