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