Search in sources :

Example 21 with ExtSource

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));
}
Also used : Group(cz.metacentrum.perun.core.api.Group) Vo(cz.metacentrum.perun.core.api.Vo) ExtSource(cz.metacentrum.perun.core.api.ExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 22 with 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();
}
Also used : ExtSource(cz.metacentrum.perun.core.api.ExtSource) Before(org.junit.Before)

Example 23 with ExtSource

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()));
}
Also used : ExtSource(cz.metacentrum.perun.core.api.ExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 24 with ExtSource

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;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) Member(cz.metacentrum.perun.core.api.Member)

Example 25 with ExtSource

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);
}
Also used : UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) UserNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserNotExistsException) UserExtSourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserExtSourceNotExistsException) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.ExtSourceNotExistsException) UserExtSourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserExtSourceNotExistsException) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl)

Aggregations

ExtSource (cz.metacentrum.perun.core.api.ExtSource)58 UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)36 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)24 Test (org.junit.Test)24 Vo (cz.metacentrum.perun.core.api.Vo)16 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)13 Candidate (cz.metacentrum.perun.core.api.Candidate)12 Group (cz.metacentrum.perun.core.api.Group)11 ExtSourceNotExistsException (cz.metacentrum.perun.core.api.exceptions.ExtSourceNotExistsException)10 Member (cz.metacentrum.perun.core.api.Member)8 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)8 ArrayList (java.util.ArrayList)5 Attribute (cz.metacentrum.perun.core.api.Attribute)4 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)4 CandidateNotExistsException (cz.metacentrum.perun.core.api.exceptions.CandidateNotExistsException)4 ExtSourceExistsException (cz.metacentrum.perun.core.api.exceptions.ExtSourceExistsException)4 MemberNotExistsException (cz.metacentrum.perun.core.api.exceptions.MemberNotExistsException)4 HashMap (java.util.HashMap)4 User (cz.metacentrum.perun.core.api.User)3 ExtSourceUnsupportedOperationException (cz.metacentrum.perun.core.api.exceptions.ExtSourceUnsupportedOperationException)3