use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class urn_perun_group_attribute_def_def_unixGID_namespaceTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_group_attribute_def_def_unixGID_namespace();
attributeToCheck = new Attribute();
attributeToCheck.setFriendlyName("friendly name");
reqAttribute = new Attribute();
reqAttribute.setFriendlyName("friendly name");
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
when(sess.getPerunBl().getGroupsManagerBl().isGroupSynchronizedFromExternallSource(sess, group)).thenReturn(false);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace" + ":" + attributeToCheck.getNamespace())).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, "", AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":usedGids")).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGID-namespace:")).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGroupName-namespace:")).thenReturn(reqAttribute);
ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
when(sess.getPerunBl().getModulesUtilsBl()).thenReturn(modulesUtilsBl);
ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
when(sess.getPerunBl().getResourcesManagerBl()).thenReturn(resourcesManagerBl);
}
use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class urn_perun_group_attribute_def_virt_adGroupNameTest method setUp.
@Before
public void setUp() throws Exception {
attributeA.setValue("A");
attributeB.setValue("B");
attributeC.setValue("C");
// prepare mocks
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
AttributesManagerBl am = mock(AttributesManagerBl.class);
GroupsManagerBl gm = mock(GroupsManagerBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
when(perunBl.getAttributesManagerBl()).thenReturn(am);
when(perunBl.getGroupsManagerBl()).thenReturn(gm);
when(gm.getParentGroup(sess, groupB)).thenReturn(groupA);
when(gm.getParentGroup(sess, groupC)).thenReturn(groupB);
when(am.getAttribute(sess, groupA, defAdGroupNameAttributeName)).thenReturn(attributeA);
when(am.getAttribute(sess, groupB, defAdGroupNameAttributeName)).thenReturn(attributeB);
when(am.getAttribute(sess, groupC, defAdGroupNameAttributeName)).thenReturn(attributeC);
}
use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class urn_perun_resource_attribute_def_def_unixGID_namespaceTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_resource_attribute_def_def_unixGID_namespace();
attributeToCheck = new Attribute();
attributeToCheck.setFriendlyName("friendly name");
reqAttribute = new Attribute();
reqAttribute.setFriendlyName("friendly name");
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, resource, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace" + ":" + attributeToCheck.getNamespace())).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, attributeToCheck.getFriendlyNameParameter(), AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":usedGids")).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace:")).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace:")).thenReturn(reqAttribute);
ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
when(sess.getPerunBl().getModulesUtilsBl()).thenReturn(modulesUtilsBl);
ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
when(sess.getPerunBl().getResourcesManagerBl()).thenReturn(resourcesManagerBl);
}
use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class urn_perun_group_attribute_def_def_unixGroupName_namespaceTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_group_attribute_def_def_unixGroupName_namespace();
attributeToCheck = new Attribute();
attributeToCheck.setFriendlyName("unixGID-namespace");
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGroupName-namespace:")).thenReturn(attributeToCheck);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
when(sess.getPerunBl().getGroupsManagerBl().isGroupSynchronizedFromExternallSource(sess, group)).thenReturn(false);
ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
when(sess.getPerunBl().getModulesUtilsBl()).thenReturn(modulesUtilsBl);
ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
when(sess.getPerunBl().getResourcesManagerBl()).thenReturn(resourcesManagerBl);
}
use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_sponsoredMembershipInOrganizations method getSponsorOrganizationIdentifiersFromGroups.
/**
* Collect sponsor organization's identifiers from perun Groups
* @param sess Perun session
* @param user User for whom the values should be collected
* @return List of collected identifiers
* @throws InternalErrorException When some error occurs, see exception cause for details.
*/
private List<String> getSponsorOrganizationIdentifiersFromGroups(PerunSessionImpl sess, User user) {
GroupsManagerBl groupsManagerBl = sess.getPerunBl().getGroupsManagerBl();
MembersManagerBl membersManagerBl = sess.getPerunBl().getMembersManagerBl();
return membersManagerBl.getMembersByUserWithStatus(sess, user, Status.VALID).stream().flatMap(validMember -> groupsManagerBl.getGroupsWhereMemberIsActive(sess, validMember).stream()).map(groupWhereMemberIsActive -> getOrganizationIdentifierAttribute(sess, groupWhereMemberIsActive, user)).filter(Objects::nonNull).map(Attribute::valueAsString).filter(Objects::nonNull).distinct().collect(Collectors.toList());
}
Aggregations