use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method getGroupsWithAssignedExtSourceInVo.
@Test
public void getGroupsWithAssignedExtSourceInVo() throws Exception {
System.out.println(CLASS_NAME + "getGroupsWithAssignedExtSourceInVo");
vo = setUpVo();
groupsManagerBl.createGroup(sess, vo, group);
groupsManagerBl.createGroup(sess, vo, group2);
ExtSource newExtSource = new ExtSource("ExtSourcesManagerEntryIntegrationTest1", ExtSourcesManager.EXTSOURCE_INTERNAL);
newExtSource = perun.getExtSourcesManager().createExtSource(sess, newExtSource, null);
perun.getExtSourcesManagerBl().addExtSource(sess, vo, newExtSource);
perun.getExtSourcesManagerBl().addExtSource(sess, group, newExtSource);
perun.getExtSourcesManagerBl().addExtSource(sess, group2, newExtSource);
final List<Group> groups = groupsManagerBl.getGroupsWithAssignedExtSourceInVo(sess, newExtSource, vo);
assertTrue(groups.contains(group));
assertTrue(groups.contains(group2));
}
use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method getGroupToSynchronize.
@Test
public void getGroupToSynchronize() throws Exception {
System.out.println(CLASS_NAME + "getGroupToSynchronize");
vo = setUpVo();
setUpGroup(vo);
ExtSource es = perun.getExtSourcesManagerBl().createExtSource(sess, extSource, null);
perun.getExtSourcesManagerBl().addExtSource(sess, vo, es);
perun.getGroupsManager().createGroup(sess, vo, group2);
Attribute synchroAttr1 = new Attribute(perun.getAttributesManager().getAttributeDefinition(sess, GroupsManager.GROUPSYNCHROINTERVAL_ATTRNAME));
synchroAttr1.setValue("5");
perun.getAttributesManager().setAttribute(sess, group, synchroAttr1);
perun.getAttributesManager().setAttribute(sess, group2, synchroAttr1);
Attribute synchroAttr2 = new Attribute(perun.getAttributesManager().getAttributeDefinition(sess, GroupsManager.GROUPEXTSOURCE_ATTRNAME));
synchroAttr2.setValue(es.getName());
perun.getAttributesManager().setAttribute(sess, group, synchroAttr2);
perun.getAttributesManager().setAttribute(sess, group2, synchroAttr2);
Attribute synchroAttr3 = new Attribute(perun.getAttributesManager().getAttributeDefinition(sess, GroupsManager.GROUPMEMBERSQUERY_ATTRNAME));
synchroAttr3.setValue("testVal");
perun.getAttributesManager().setAttribute(sess, group, synchroAttr3);
perun.getAttributesManager().setAttribute(sess, group2, synchroAttr3);
Attribute synchroAttr4 = new Attribute(perun.getAttributesManager().getAttributeDefinition(sess, GroupsManager.GROUPSYNCHROENABLED_ATTRNAME));
synchroAttr4.setValue("true");
perun.getAttributesManager().setAttribute(sess, group, synchroAttr4);
perun.getAttributesManager().setAttribute(sess, group2, synchroAttr4);
List<Group> groups = groupsManagerBl.getGroupsToSynchronize(sess);
assertTrue("List of groups to synchronize contain group.", groups.contains(group));
assertTrue("List of groups to synchronize contain group2.", groups.contains(group2));
}
use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.
the class ModulesUtilsEntryIntegrationTest method setUpMember.
private Member setUpMember() throws Exception {
String userFirstName = Long.toHexString(Double.doubleToLongBits(Math.random()));
String userLastName = Long.toHexString(Double.doubleToLongBits(Math.random()));
// his login in external source
String extLogin = Long.toHexString(Double.doubleToLongBits(Math.random()));
// Mockito.mock(Candidate.class);
Candidate candidate = new Candidate();
candidate.setFirstName(userFirstName);
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName(userLastName);
candidate.setTitleBefore("");
candidate.setTitleAfter("");
UserExtSource userExtSource = new UserExtSource(new ExtSource(0, "testExtSource", "cz.metacentrum.perun.core.impl.ExtSourceInternal"), extLogin);
candidate.setUserExtSource(userExtSource);
candidate.setAttributes(new HashMap<>());
Member member = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
assertNotNull("No member created", member);
usersForDeletion.add(perun.getUsersManager().getUserByMember(sess, member));
// save user for deletion after test
return member;
}
use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_studentIdentifiers method processRemoveUserExtSource.
/**
* Remove userExtSource with attributes for member's user if exists.
*
* @param sess Perun session
* @param group from which appropriate attributes will be obtained
* @param member for which the xtSource with attributes will be processed
*/
private void processRemoveUserExtSource(PerunSessionImpl sess, Group group, Member member) {
User user = sess.getPerunBl().getUsersManagerBl().getUserByMember(sess, member);
Attribute organizationScope = tryGetAttribute(sess, group, A_G_D_organizationScopeFriendlyName);
if (organizationScope == null || organizationScope.getValue() == null) {
return;
}
Attribute organizationNamespace = this.tryGetAttribute(sess, group, A_G_D_organizationNamespaceFriendlyName);
if (organizationNamespace == null || organizationNamespace.getValue() == null) {
return;
}
Attribute userLoginID = tryGetAttribute(sess, user, A_U_D_loginNamespaceFriendlyNamePrefix + organizationNamespace.valueAsString());
if (userLoginID == null || userLoginID.getValue() == null) {
return;
}
ExtSource extSource = tryGetExtSource(sess, organizationScope.valueAsString());
// Remove userExtSource if exists
try {
UserExtSource ues = sess.getPerunBl().getUsersManagerBl().getUserExtSourceByExtLogin(sess, extSource, userLoginID.valueAsString());
sess.getPerunBl().getUsersManagerBl().removeUserExtSource(sess, user, ues);
} catch (UserExtSourceNotExistsException e) {
// Means that the ues was already removed, which is ok
} catch (UserExtSourceAlreadyRemovedException e) {
// Should not happened
throw new InternalErrorException(e);
}
}
use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.
the class VosManagerEntryIntegrationTest method prepareCandidate.
private Candidate prepareCandidate() {
String userFirstName = Long.toHexString(Double.doubleToLongBits(Math.random()));
String userLastName = Long.toHexString(Double.doubleToLongBits(Math.random()));
// his login in external source
String extLogin = Long.toHexString(Double.doubleToLongBits(Math.random()));
// Mockito.mock(Candidate.class);
final Candidate candidate = new Candidate();
candidate.setFirstName(userFirstName);
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName(userLastName);
candidate.setTitleBefore("");
candidate.setTitleAfter("");
final ExtSource extSource = new ExtSource(0, "testExtSource", "cz.metacentrum.perun.core.impl.ExtSourceInternal");
final UserExtSource userExtSource = new UserExtSource(extSource, extLogin);
candidate.setUserExtSource(userExtSource);
candidate.setAttributes(new HashMap<>());
return candidate;
}
Aggregations