Search in sources :

Example 6 with GroupsManagerBl

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);
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 7 with GroupsManagerBl

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);
}
Also used : GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 8 with GroupsManagerBl

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);
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 9 with GroupsManagerBl

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);
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 10 with GroupsManagerBl

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());
}
Also used : UserVirtualAttributesModuleImplApi(cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleImplApi) Attribute(cz.metacentrum.perun.core.api.Attribute) Member(cz.metacentrum.perun.core.api.Member) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) SkipValueCheckDuringDependencyCheck(cz.metacentrum.perun.core.implApi.modules.attributes.SkipValueCheckDuringDependencyCheck) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) LoggerFactory(org.slf4j.LoggerFactory) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) AttributesManager(cz.metacentrum.perun.core.api.AttributesManager) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) Collectors(java.util.stream.Collectors) Group(cz.metacentrum.perun.core.api.Group) UserVirtualAttributesModuleAbstract(cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleAbstract) User(cz.metacentrum.perun.core.api.User) ArrayList(java.util.ArrayList) Objects(java.util.Objects) MembersManagerBl(cz.metacentrum.perun.core.bl.MembersManagerBl) List(java.util.List) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) Status(cz.metacentrum.perun.core.api.Status) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) MembersManagerBl(cz.metacentrum.perun.core.bl.MembersManagerBl) Objects(java.util.Objects)

Aggregations

GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)18 Attribute (cz.metacentrum.perun.core.api.Attribute)14 PerunBl (cz.metacentrum.perun.core.bl.PerunBl)14 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)13 AttributesManagerBl (cz.metacentrum.perun.core.bl.AttributesManagerBl)12 Before (org.junit.Before)12 Group (cz.metacentrum.perun.core.api.Group)6 ResourcesManagerBl (cz.metacentrum.perun.core.bl.ResourcesManagerBl)6 Member (cz.metacentrum.perun.core.api.Member)5 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)5 ModulesUtilsBl (cz.metacentrum.perun.core.bl.ModulesUtilsBl)4 User (cz.metacentrum.perun.core.api.User)3 Vo (cz.metacentrum.perun.core.api.Vo)3 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)3 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)3 ArrayList (java.util.ArrayList)3 AttributesManager (cz.metacentrum.perun.core.api.AttributesManager)2 Facility (cz.metacentrum.perun.core.api.Facility)2 Resource (cz.metacentrum.perun.core.api.Resource)2 Status (cz.metacentrum.perun.core.api.Status)2