Search in sources :

Example 6 with UsersManagerBl

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

the class urn_perun_user_attribute_def_def_cnCeitecADTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_cnCeitecAD();
    session = mock(PerunSessionImpl.class);
    user = new User(0, "John", "Doe", "", "", "");
    secondUser = new User(1, "Jane", "Doe", "", "", "");
    attributeToCheck = new Attribute();
    attributeToCheck.setValue("něco");
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(session.getPerunBl().getUsersManagerBl()).thenReturn(usersManagerBl);
}
Also used : User(cz.metacentrum.perun.core.api.User) 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) Before(org.junit.Before)

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

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_ceitec();
    session = mock(PerunSessionImpl.class);
    user = new User();
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:ceitec");
    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, "ceitec")).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) 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 8 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 setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_einfra();
    session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:einfra");
    attributeToCheck.setValue("test");
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(session.getPerunBl().getUsersManagerBl()).thenReturn(usersManagerBl);
    PasswordManagerModule module = mock(EinfraPasswordManagerModule.class);
    when(session.getPerunBl().getUsersManagerBl().getPasswordManagerModule(session, "einfra")).thenReturn(module);
    ModulesUtilsBl modulesUtilsBlSpy = spy(mock(ModulesUtilsBl.class));
    when(session.getPerunBl().getModulesUtilsBl()).thenReturn(modulesUtilsBlSpy);
    Mockito.doThrow(InvalidLoginException.class).when(modulesUtilsBlSpy).checkLoginNamespaceRegex(eq("einfra"), // negated einfra check
    ArgumentMatchers.matches("(?!^[a-z][a-z0-9_-]{1,14}$)"), ArgumentMatchers.any(Pattern.class));
}
Also used : Pattern(java.util.regex.Pattern) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) EinfraPasswordManagerModule(cz.metacentrum.perun.core.impl.modules.pwdmgr.EinfraPasswordManagerModule) PasswordManagerModule(cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule) 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 9 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_vsupTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_vsup();
    session = mock(PerunSessionImpl.class);
    user = new User();
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:vsup");
    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, "vsup")).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 10 with UsersManagerBl

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

the class urn_perun_user_attribute_def_def_uid_namespaceTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_uid_namespace();
    session = mock(PerunSessionImpl.class);
    user = new User(0, "John", "Doe", "", "", "");
    attributeToCheck = new Attribute();
    attributeToCheck.setFriendlyName("name:param");
    minUid = new Attribute();
    maxUid = new Attribute();
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(session.getPerunBl().getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(session, "param", AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-minUID")).thenReturn(minUid);
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(session, "param", AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-maxUID")).thenReturn(maxUid);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(session.getPerunBl().getUsersManagerBl()).thenReturn(usersManagerBl);
}
Also used : User(cz.metacentrum.perun.core.api.User) 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)

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