Search in sources :

Example 1 with UsersManagerBl

use of cz.metacentrum.perun.core.bl.UsersManagerBl in project perun by CESNET.

the class urn_perun_user_facility_attribute_def_def_defaultUnixGIDTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_facility_attribute_def_def_defaultUnixGID();
    attributeToCheck = new Attribute();
    attributeToCheck.setValue(5);
    namespace = new Attribute();
    namespace.setValue("namespace");
    unixGroupNamespace = new Attribute();
    unixGroupNamespace.setValue("unixGroupNamespace");
    resourceGidAttribute = new Attribute();
    resourceGidAttribute.setValue("resourceGidAttribute");
    groupGidAttribute = new Attribute();
    groupGidAttribute.setValue("groupGidAttribute");
    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().getAttribute(sess, facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace")).thenReturn(namespace);
    when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGroupName-namespace")).thenReturn(unixGroupNamespace);
    when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGID-namespace:" + namespace.valueAsString())).thenReturn(resourceGidAttribute);
    when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace:" + namespace.valueAsString())).thenReturn(groupGidAttribute);
    ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
    when(sess.getPerunBl().getResourcesManagerBl()).thenReturn(resourcesManagerBl);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(sess.getPerunBl().getUsersManagerBl()).thenReturn(usersManagerBl);
    GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
    when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
    when(sess.getPerunBl().getGroupsManagerBl().getGroupsByAttribute(sess, groupGidAttribute)).thenReturn(new ArrayList<>());
    FacilitiesManagerBl facilitiesManagerBl = mock(FacilitiesManagerBl.class);
    when(sess.getPerunBl().getFacilitiesManagerBl()).thenReturn(facilitiesManagerBl);
    when(sess.getPerunBl().getFacilitiesManagerBl().getAllowedGroups(sess, facility, null, null)).thenReturn(new ArrayList<>());
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) FacilitiesManagerBl(cz.metacentrum.perun.core.bl.FacilitiesManagerBl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 2 with UsersManagerBl

use of cz.metacentrum.perun.core.bl.UsersManagerBl in project perun by CESNET.

the class urn_perun_member_attribute_def_def_o365EmailAddresses_muTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_member_attribute_def_def_o365EmailAddresses_mu();
    // prepare mocks
    session = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    am = mock(AttributesManagerBl.class);
    UsersManagerBl um = mock(UsersManagerBl.class);
    Attribute ucoAttr = mock(Attribute.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    when(perunBl.getAttributesManagerBl()).thenReturn(am);
    when(perunBl.getUsersManagerBl()).thenReturn(um);
    when(um.getUserById(session, member.getUserId())).thenReturn(user);
    when(ucoAttr.getValue()).thenReturn(uco);
    when(ucoAttr.valueAsString()).thenReturn(uco);
    when(um.getUserById(session, member.getUserId())).thenReturn(user);
    when(am.getPerunBeanIdsForUniqueAttributeValue(eq(session), argThat(new BeanAttributeMatcher("member")))).thenReturn(Sets.newHashSet(new Pair<>(member.getId(), 0)));
    when(am.getPerunBeanIdsForUniqueAttributeValue(eq(session), argThat(new BeanAttributeMatcher("group")))).thenReturn(Sets.newHashSet());
    attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
    attributeToCheck.setId(101);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Pair(cz.metacentrum.perun.core.api.Pair) Before(org.junit.Before)

Example 3 with UsersManagerBl

use of cz.metacentrum.perun.core.bl.UsersManagerBl in project perun by CESNET.

the class urn_perun_user_attribute_def_def_login_namespace_eduteams_nicknameTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_eduteams_nickname();
    session = mock(PerunSessionImpl.class);
    user = new User();
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:eduteams-nickname");
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
    when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(perunBl.getUsersManagerBl()).thenReturn(usersManagerBl);
    PasswordManagerModule module = mock(GenericPasswordManagerModule.class);
    when(session.getPerunBl().getUsersManagerBl().getPasswordManagerModule(session, "eduteams-nickname")).thenReturn(module);
}
Also used : User(cz.metacentrum.perun.core.api.User) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PasswordManagerModule(cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule) GenericPasswordManagerModule(cz.metacentrum.perun.core.impl.modules.pwdmgr.GenericPasswordManagerModule) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) Before(org.junit.Before)

Example 4 with UsersManagerBl

use of cz.metacentrum.perun.core.bl.UsersManagerBl in project perun by CESNET.

the class urn_perun_user_attribute_def_def_login_namespace_fenix_nicknameTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_fenix_nickname();
    session = mock(PerunSessionImpl.class);
    user = new User();
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:fenix-nickname");
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
    when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(perunBl.getUsersManagerBl()).thenReturn(usersManagerBl);
    PasswordManagerModule module = mock(GenericPasswordManagerModule.class);
    when(session.getPerunBl().getUsersManagerBl().getPasswordManagerModule(session, "fenix-nickname")).thenReturn(module);
}
Also used : User(cz.metacentrum.perun.core.api.User) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PasswordManagerModule(cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule) GenericPasswordManagerModule(cz.metacentrum.perun.core.impl.modules.pwdmgr.GenericPasswordManagerModule) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) Before(org.junit.Before)

Example 5 with UsersManagerBl

use of cz.metacentrum.perun.core.bl.UsersManagerBl in project perun by CESNET.

the class urn_perun_user_attribute_def_def_login_namespace_mu_admTest method setUp.

@Before
public void setUp() throws Exception {
    // prepare core config for this test
    CoreConfig cfNew = new CoreConfig();
    cfNew.setInstanceId("test");
    BeansUtils.setConfig(cfNew);
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_mu_adm();
    session = mock(PerunSessionImpl.class);
    user = new User();
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:mu-adm");
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(session.getPerunBl().getUsersManagerBl()).thenReturn(usersManagerBl);
    PasswordManagerModule module = mock(GenericPasswordManagerModule.class);
    when(session.getPerunBl().getUsersManagerBl().getPasswordManagerModule(session, "mu-adm")).thenReturn(module);
    ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
    when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
}
Also used : User(cz.metacentrum.perun.core.api.User) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) CoreConfig(cz.metacentrum.perun.core.api.CoreConfig) Attribute(cz.metacentrum.perun.core.api.Attribute) PasswordManagerModule(cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule) GenericPasswordManagerModule(cz.metacentrum.perun.core.impl.modules.pwdmgr.GenericPasswordManagerModule) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) Before(org.junit.Before)

Aggregations

UsersManagerBl (cz.metacentrum.perun.core.bl.UsersManagerBl)16 PerunBl (cz.metacentrum.perun.core.bl.PerunBl)15 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)15 Before (org.junit.Before)15 Attribute (cz.metacentrum.perun.core.api.Attribute)12 User (cz.metacentrum.perun.core.api.User)9 ModulesUtilsBl (cz.metacentrum.perun.core.bl.ModulesUtilsBl)9 PasswordManagerModule (cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule)8 AttributesManagerBl (cz.metacentrum.perun.core.bl.AttributesManagerBl)7 GenericPasswordManagerModule (cz.metacentrum.perun.core.impl.modules.pwdmgr.GenericPasswordManagerModule)7 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)1 CoreConfig (cz.metacentrum.perun.core.api.CoreConfig)1 Pair (cz.metacentrum.perun.core.api.Pair)1 FacilitiesManagerBl (cz.metacentrum.perun.core.bl.FacilitiesManagerBl)1 GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)1 ResourcesManagerBl (cz.metacentrum.perun.core.bl.ResourcesManagerBl)1 EinfraPasswordManagerModule (cz.metacentrum.perun.core.impl.modules.pwdmgr.EinfraPasswordManagerModule)1 ArrayList (java.util.ArrayList)1 Pattern (java.util.regex.Pattern)1 Test (org.junit.Test)1