Search in sources :

Example 66 with Resource

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

the class AttributesManagerEntryIntegrationTest method getResourceRequiredMemberGroupAttributesWorkWithUserWhenFakeResource.

@Test
public void getResourceRequiredMemberGroupAttributesWorkWithUserWhenFakeResource() throws Exception {
    System.out.println(CLASS_NAME + "getResourceRequiredMemberGroupAttributesWorkWithUserWhenFakeResource");
    vo = setUpVo();
    group = setUpGroup();
    member = setUpMember();
    facility = setUpFacility();
    resource = setUpResource();
    service = setUpService();
    attributes = setUpRequiredAttributes();
    perun.getResourcesManager().assignService(sess, resource, service);
    Resource fakeResource = new Resource();
    fakeResource.setName("AttrManTestResource2");
    fakeResource.setDescription("fake resource");
    perun.getResourcesManager().createResource(sess, fakeResource, vo, facility);
    List<Attribute> reqAttr = attributesManager.getResourceRequiredAttributes(sess, fakeResource, member, group, true);
    assertNotNull("unable to get required member group attributes for its services", reqAttr);
    assertTrue("Shouldn't return attribute, when there is no service on resource", reqAttr.size() == 0);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) Resource(cz.metacentrum.perun.core.api.Resource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 67 with Resource

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

the class AttributesManagerEntryIntegrationTest method removeResourceAttributesWhenResourceNotExists.

@Test(expected = ResourceNotExistsException.class)
public void removeResourceAttributesWhenResourceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "removeResourceAttributesWhenResourceNotExists");
    attributes = setUpResourceAttribute();
    attributesManager.removeAttributes(sess, new Resource(), attributes);
// shouldn't find resource
}
Also used : Resource(cz.metacentrum.perun.core.api.Resource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 68 with Resource

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

the class ModulesUtilsEntryIntegrationTest method getCommonGIDOfResourcesWithSameNameInSameNamespace.

@Test
public void getCommonGIDOfResourcesWithSameNameInSameNamespace() throws Exception {
    System.out.println(CLASS_NAME + "getCommonGIDOfResourcesWithSameNameInSameNamespace");
    vo = setUpVo();
    facility = setUpFacility();
    resource = setUpResource();
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(resource);
    Attribute minGID = new Attribute(perun.getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-minGID"));
    Attribute maxGID = new Attribute(perun.getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-maxGID"));
    minGID.setValue(100);
    maxGID.setValue(100500);
    perun.getAttributesManagerBl().setAttribute(sess, namespace, minGID);
    perun.getAttributesManagerBl().setAttribute(sess, namespace, maxGID);
    List<Attribute> attributes = setUpGroupNamesAndGIDForGroupAndResource();
    Attribute resourceGID = null;
    for (Attribute a : attributes) {
        if (a.getName().equals(AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGID-namespace:" + namespace)) {
            resourceGID = a;
            break;
        }
    }
    perun.getAttributesManagerBl().setAttribute(sess, resource, resourceGID);
    assertEquals(new Integer(112), modulesUtilsBl.getCommonGIDOfResourcesWithSameNameInSameNamespace((PerunSessionImpl) sess, resources, namespace, null));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) ArrayList(java.util.ArrayList) Resource(cz.metacentrum.perun.core.api.Resource) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 69 with Resource

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

the class ServicesManagerEntryIntegrationTest method setUpResource.

private Resource setUpResource() throws Exception {
    Resource resource = new Resource();
    resource.setName("ServicesManagerTestResource");
    resource.setDescription("Testovaci");
    resource = perun.getResourcesManager().createResource(sess, resource, vo, facility);
    return resource;
}
Also used : Resource(cz.metacentrum.perun.core.api.Resource)

Example 70 with Resource

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

the class urn_perun_user_facility_attribute_def_virt_defaultUnixGIDTest method getValueDefaultUGidIsSetTest.

@Test
public void getValueDefaultUGidIsSetTest() throws Exception {
    System.out.println("urn_perun_user_facility_attribute_def_virt_defaultUnixGID.getValueDefaultUGidIsSetTest ()");
    //setup
    dDefaultUnixGid.setValue(123);
    //phase one
    //UF:D:DefaultUnixGid attr
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSessionImpl.class), any(Facility.class), any(User.class), eq(AttributesManager.NS_USER_FACILITY_ATTR_DEF + ":defaultUnixGID"))).thenReturn(dDefaultUnixGid);
    //phase two
    //namespace String
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSessionImpl.class), any(Facility.class), eq(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace")).getValue()).thenReturn(namespace);
    //prefferedUnixGroupName attr
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSessionImpl.class), any(User.class), eq(AttributesManager.NS_USER_ATTR_DEF + ":preferredUnixGroupName-namespace:" + namespace))).thenReturn(prefferedUnixGroupName);
    //allowedResource list<resource>
    when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSessionImpl.class), any(Facility.class), any(User.class))).thenReturn(allowedResource);
    //R:D:unixGroupName-namespace:namespace string
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSessionImpl.class), any(Resource.class), eq(AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGroupName-namespace:" + namespace)).getValue()).thenReturn(resourceGroupName);
    //getMemberByUser list<members>
    when(session.getPerunBl().getMembersManagerBl().getMembersByUser(any(PerunSessionImpl.class), any(User.class))).thenReturn(memberByUser);
    //getAssignedGroupsToResource list<group>
    when(session.getPerunBl().getGroupsManagerBl().getAssignedGroupsToResource(any(PerunSessionImpl.class), any(Resource.class))).thenReturn(assignedGroupsToResource);
    //getGroupMembers list<members>
    when(session.getPerunBl().getGroupsManagerBl().getGroupMembers(any(PerunSessionImpl.class), any(Group.class))).thenReturn(groupMembers);
    //G:D:unixGroupName-namespace:namespace string
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSessionImpl.class), any(Group.class), eq(AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace:" + namespace)).getValue()).thenReturn(groupGroupName);
    //R:D:unixGID-namespace:namespace int
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSessionImpl.class), any(Resource.class), eq(AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGID-namespace:" + namespace)).getValue()).thenReturn(resourceUnixGID);
    //G:D:unixGID-namespace:namespace int
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSessionImpl.class), any(Group.class), eq(AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace:" + namespace)).getValue()).thenReturn(groupUnixGID);
    //phase three
    //UF:D:basicDefaultGID attr
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSessionImpl.class), any(Facility.class), any(User.class), eq(AttributesManager.NS_USER_FACILITY_ATTR_DEF + ":basicDefaultGID"))).thenReturn(basicDefaultGID);
    Attribute testAttr = classInstance.getAttributeValue(session, facility, user, attrDef);
    assertEquals(testAttr, dDefaultUnixGid);
}
Also used : Group(cz.metacentrum.perun.core.api.Group) 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) 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