Search in sources :

Example 6 with ExtSource

use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.

the class UsersManagerEntryIntegrationTest method getActiveUserExtSources.

@Test
public void getActiveUserExtSources() throws Exception {
    System.out.println(CLASS_NAME + "getActiveUserExtSources");
    ExtSource externalSource = perun.getExtSourcesManager().getExtSourceByName(sess, extSourceName);
    UserExtSource userExtSource = usersManager.getUserExtSourceByExtLogin(sess, externalSource, extLogin);
    List<UserExtSource> ues = perun.getUsersManagerBl().getActiveUserExtSources(sess, user);
    assertTrue(ues.contains(userExtSource));
}
Also used : UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 7 with ExtSource

use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.

the class UsersManagerEntryIntegrationTest method getUserExtSourceByExtLoginWhenExtLoginNotExists.

//TODO: for this test is needed to add creating login in registrar database
/*
		 @Test (expected=AlreadyReservedLoginException.class)
		 public void isAlreadyReservedLogin() throws Exception {
		 System.out.println(CLASS_NAME + "isAlreadyReservedLogin");

		 String namespace = "einfra";
		 String login = "martin_svehla";
		 perun.getUsersManagerBl().checkReservedLogins(sess, namespace, login);
		 }
		 */
@Test(expected = UserExtSourceNotExistsException.class)
public void getUserExtSourceByExtLoginWhenExtLoginNotExists() throws Exception {
    System.out.println(CLASS_NAME + "getUserExtSourceByExtLoginWhenExtLoginNotExists");
    ExtSource externalSource = perun.getExtSourcesManager().getExtSourceByName(sess, extSourceName);
    usersManager.getUserExtSourceByExtLogin(sess, externalSource, "");
// shouldn't find UserExtSource (based on valid ext source and invalid login)
}
Also used : ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 8 with ExtSource

use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.

the class UsersManagerEntryIntegrationTest method getUserExtSourceByExtLogin.

@Test
public void getUserExtSourceByExtLogin() throws Exception {
    System.out.println(CLASS_NAME + "getUserExtSourceByExtLogin");
    ExtSource externalSource = perun.getExtSourcesManager().getExtSourceByName(sess, extSourceName);
    UserExtSource returnedUserExtSource = usersManager.getUserExtSourceByExtLogin(sess, externalSource, extLogin);
    assertEquals("both ext source should be the same", userExtSource, returnedUserExtSource);
// check if both user ext sources are the same.
}
Also used : UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 9 with ExtSource

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

Example 10 with ExtSource

use of cz.metacentrum.perun.core.api.ExtSource in project perun by CESNET.

the class UsersManagerEntryIntegrationTest method addUserExtSource.

@Test
public void addUserExtSource() throws Exception {
    System.out.println(CLASS_NAME + "addUserExtSource");
    ExtSource externalSource = perun.getExtSourcesManager().getExtSourceByName(sess, extSourceName);
    UserExtSource userExtSource2 = new UserExtSource();
    userExtSource2.setLogin(extLogin2);
    userExtSource2.setExtSource(externalSource);
    UserExtSource returnedUserExtSource = usersManager.addUserExtSource(sess, user, userExtSource2);
    assertNotNull(returnedUserExtSource);
    assertTrue(returnedUserExtSource.getId() > 0);
    assertEquals("Both User Ext Sources should be the same", userExtSource2, returnedUserExtSource);
}
Also used : UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

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