Search in sources :

Example 11 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_acc_nicknameTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_eduteams_acc_nickname();
    session = mock(PerunSessionImpl.class);
    user = new User();
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:eduteams-acc-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-acc-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 12 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_einfraTest method testAlreadyReservedLogin.

@Test(expected = WrongReferenceAttributeValueException.class)
public void testAlreadyReservedLogin() throws Exception {
    System.out.println("testAlreadyReservedLogin()");
    UsersManagerBl usersManager = mock(UsersManagerBl.class);
    when(session.getPerunBl().getUsersManagerBl()).thenReturn(usersManager);
    List<User> tmp = new ArrayList<>();
    tmp.add(user);
    when(usersManager.getUsersByAttribute(session, attributeToCheck, true)).thenReturn(tmp);
    attributeToCheck.setValue(attributeToCheck.getValue().toString().toUpperCase());
    doThrow(new AlreadyReservedLoginException("")).when(usersManager).checkReservedLogins(session, "einfra", attributeToCheck.valueAsString(), true);
    classInstance.checkAttributeSemantics(session, user, attributeToCheck);
}
Also used : ArrayList(java.util.ArrayList) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) Test(org.junit.Test)

Example 13 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_eduroam_vsupTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_eduroam_vsup();
    session = mock(PerunSessionImpl.class);
    user = new User();
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:eduroam-vsup");
    attribute = new Attribute();
    attribute.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attribute.setFriendlyName("login-namespace:eduroam-vsup");
    attribute.setValue("same_value");
    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, "eduroam-vsup")).thenReturn(module);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(attributesManagerBl.getAttribute(session, user, AttributesManager.NS_USER_ATTR_DEF + ":login-namespace:vsup")).thenReturn(attribute);
}
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) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 14 with UsersManagerBl

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

the class urn_perun_user_attribute_def_virt_associatedUsersMailsTest method setUp.

@Before
public void setUp() throws Exception {
    sess = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(perunBl.getUsersManagerBl()).thenReturn(usersManagerBl);
    when(sess.getPerunBl().getUsersManagerBl().getUsersBySpecificUser(sess, specificUser)).thenReturn(Arrays.asList(user1, user2));
    when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, user1, A_U_D_preferredMail)).thenReturn(user1MailAttribute);
    when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, user2, A_U_D_preferredMail)).thenReturn(user2MailAttribute);
}
Also used : 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 15 with UsersManagerBl

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

the class urn_perun_user_attribute_def_virt_tcsMails_muTest method setUp.

@Before
public void setUp() throws Exception {
    tcsMailsAttrDef.setId(100);
    // prepare mocks
    sess = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    AttributesManagerBl am = mock(AttributesManagerBl.class);
    UsersManagerBl um = mock(UsersManagerBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    when(perunBl.getAttributesManagerBl()).thenReturn(am);
    when(perunBl.getUsersManagerBl()).thenReturn(um);
    when(sess.getPerunBl().getAttributesManagerBl().getAttributes(sess, user, Arrays.asList(preferredMailAttr.getName(), isMailAttr.getName(), o365MailsAttr.getName(), publicMailsAttr.getName(), privateMailsAttr.getName()))).thenReturn(Arrays.asList(preferredMailAttr, isMailAttr, o365MailsAttr, publicMailsAttr, privateMailsAttr));
    when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, tcsMailsAttrDef.getName())).thenReturn(tcsMailsAttrDef);
}
Also used : 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)

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