use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.
the class ExtSourcesManagerEntryIntegrationTest method testGetGroupExtSources.
@Test
public void testGetGroupExtSources() throws Exception {
System.out.println(CLASS_NAME + "getGroupExtSources");
final VosManagerEntry vosManagerEntry = new VosManagerEntry(perun);
final Vo createdVo = vosManagerEntry.createVo(sess, new Vo(0, "sjk", "kljlk"));
final GroupsManagerEntry groupsManagerEntry = new GroupsManagerEntry(perun);
final Group createdGroup = groupsManagerEntry.createGroup(sess, createdVo, new Group("sjk", "kljlk"));
final ExtSource extSource = newInstanceExtSource();
extSourcesManagerEntry.createExtSource(sess, extSource, null);
extSourcesManagerEntry.addExtSource(sess, createdVo, extSource);
extSourcesManagerEntry.addExtSource(sess, createdGroup, extSource);
final List<ExtSource> extSources = extSourcesManagerEntry.getGroupExtSources(sess, createdGroup);
assertNotNull(extSources);
assertTrue(extSources.contains(extSource));
}
use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.
the class ExtSourcesManagerEntryIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
ExtSource newExtSource = new ExtSource(EXT_SOURCE_NAME, ExtSourcesManager.EXTSOURCE_INTERNAL);
extSource = perun.getExtSourcesManager().createExtSource(sess, newExtSource, null);
this.extSourcesManagerEntry = perun.getExtSourcesManager();
}
use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.
the class ExtSourcesManagerEntryIntegrationTest method testGetExtSourceById.
/**
* Test method for {@link cz.metacentrum.perun.core.blImpl.ExtSourcesManagerBlImpl#getExtSourceById(cz.metacentrum.perun.core.api.PerunSession, int)}.
*/
@Test
public void testGetExtSourceById() throws Exception {
System.out.println(CLASS_NAME + "getExtSourceById");
final ExtSource es = newInstanceExtSource();
final ExtSource createdExtSource = extSourcesManagerEntry.createExtSource(sess, es, null);
assertTrue(createdExtSource.getId() > 0);
assertEquals(createdExtSource, extSourcesManagerEntry.getExtSourceById(sess, createdExtSource.getId()));
}
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<String, String>());
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 PerunBlImpl method getPerunSession.
public PerunSession getPerunSession(PerunPrincipal principal, PerunClient client) throws InternalErrorException {
if (principal.getUser() == null && this.getUsersManagerBl() != null && !dontLookupUsersForLogins.contains(principal.getActor())) {
// Get the user if we are completely initialized
try {
principal.setUser(this.getUsersManagerBl().getUserByExtSourceNameAndExtLogin(getPerunSession(), principal.getExtSourceName(), principal.getActor()));
// Try to update LoA for userExtSource
ExtSource es = this.getExtSourcesManagerBl().getExtSourceByName(getPerunSession(), principal.getExtSourceName());
UserExtSource ues = this.getUsersManagerBl().getUserExtSourceByExtLogin(getPerunSession(), es, principal.getActor());
if (ues.getLoa() != principal.getExtSourceLoa()) {
ues.setLoa(principal.getExtSourceLoa());
this.getUsersManagerBl().updateUserExtSource(getPerunSession(), ues);
}
// Update last access for userExtSource
this.getUsersManagerBl().updateUserExtSourceLastAccess(getPerunSession(), ues);
} catch (ExtSourceNotExistsException | UserExtSourceNotExistsException | UserNotExistsException e) {
// OK - We don't know user yet
}
}
return new PerunSessionImpl(this, principal, client);
}
Aggregations