Search in sources :

Example 71 with Facility

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");
}
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 72 with Facility

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());
}
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 73 with Facility

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");
}
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 74 with Facility

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()));
}
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 75 with Facility

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

Facility (cz.metacentrum.perun.core.api.Facility)188 Test (org.junit.Test)95 User (cz.metacentrum.perun.core.api.User)81 Attribute (cz.metacentrum.perun.core.api.Attribute)75 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)61 Resource (cz.metacentrum.perun.core.api.Resource)52 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)51 ArrayList (java.util.ArrayList)48 Group (cz.metacentrum.perun.core.api.Group)24 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)23 Member (cz.metacentrum.perun.core.api.Member)22 PerunSession (cz.metacentrum.perun.core.api.PerunSession)20 RichFacility (cz.metacentrum.perun.core.api.RichFacility)20 Host (cz.metacentrum.perun.core.api.Host)19 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)18 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)17 RichUser (cz.metacentrum.perun.core.api.RichUser)16 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)15 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)14 Vo (cz.metacentrum.perun.core.api.Vo)13