Search in sources :

Example 41 with UserExtSource

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

the class AttributesManagerEntryIntegrationTest method removeUserExtSourceAttributesWhenUserExtSourceNotExists.

@Test(expected = UserExtSourceNotExistsException.class)
public void removeUserExtSourceAttributesWhenUserExtSourceNotExists() throws Exception {
    System.out.println(CLASS_NAME + "removeUserExtSourceAttributesWhenUserExtSourceNotExists");
    attributes = setUpUserExtSourceAttribute();
    UserExtSource ues = setUpUserExtSource();
    attributesManager.removeAttributes(sess, ues, attributes);
// shouldn't find user external source
}
Also used : UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 42 with UserExtSource

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

the class VosManagerEntryIntegrationTest method getAdmins.

@Test
public void getAdmins() throws Exception {
    System.out.println(CLASS_NAME + "getAdmins");
    final Vo createdVo = vosManagerEntry.createVo(sess, myVo);
    // set up first user
    final Member member = createMemberFromExtSource(createdVo);
    User user = perun.getUsersManagerBl().getUserByMember(sess, member);
    vosManagerEntry.addAdmin(sess, createdVo, user);
    // set up authorized group
    Group authorizedGroup = new Group("authorizedGroup", "testovaciGroup");
    Group returnedGroup = perun.getGroupsManager().createGroup(sess, createdVo, authorizedGroup);
    vosManagerEntry.addAdmin(sess, createdVo, returnedGroup);
    // set up second user
    //Mockito.mock(Candidate.class);
    Candidate candidate = new Candidate();
    candidate.setFirstName("Josef");
    candidate.setId(4);
    candidate.setMiddleName("");
    candidate.setLastName("Novak");
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    UserExtSource userExtSource = new UserExtSource(new ExtSource(0, "testExtSource", "cz.metacentrum.perun.core.impl.ExtSourceInternal"), Long.toHexString(Double.doubleToLongBits(Math.random())));
    candidate.setUserExtSource(userExtSource);
    candidate.setAttributes(new HashMap<String, String>());
    Member member2 = perun.getMembersManagerBl().createMemberSync(sess, createdVo, candidate);
    User user2 = perun.getUsersManagerBl().getUserByMember(sess, member2);
    perun.getGroupsManager().addMember(sess, returnedGroup, member2);
    // test
    List<User> admins = vosManagerEntry.getAdmins(sess, createdVo);
    assertTrue("should have 2 admins", admins.size() == 2);
    assertTrue("our member as direct user should be admin", admins.contains(user));
    assertTrue("our member as member of admin group should be admin", admins.contains(user2));
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) Group(cz.metacentrum.perun.core.api.Group) User(cz.metacentrum.perun.core.api.User) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) Vo(cz.metacentrum.perun.core.api.Vo) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) Member(cz.metacentrum.perun.core.api.Member) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 43 with UserExtSource

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

the class UsersManagerEntryIntegrationTest method setUpCandidateForSpecificUser1.

private Candidate setUpCandidateForSpecificUser1() {
    //Mockito.mock(Candidate.class);
    Candidate candidate = new Candidate();
    candidate.setFirstName("(Service)");
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName("testingServiceUser01");
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    candidate.setServiceUser(true);
    final UserExtSource userExtSource = new UserExtSource(extSource, Long.toHexString(Double.doubleToLongBits(Math.random())));
    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)

Example 44 with UserExtSource

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

the class UsersManagerEntryIntegrationTest method setUpCandidateForSpecificUser2.

private Candidate setUpCandidateForSpecificUser2() {
    //Mockito.mock(Candidate.class);
    Candidate candidate = new Candidate();
    candidate.setFirstName("(Service)");
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName("testingServiceUser02");
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    candidate.setServiceUser(true);
    final UserExtSource userExtSource = new UserExtSource(extSource, Long.toHexString(Double.doubleToLongBits(Math.random())));
    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)

Example 45 with UserExtSource

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

the class UsersManagerEntryIntegrationTest method addIDPExtSourcesWithSameLogin.

@Test(expected = InternalErrorException.class)
public void addIDPExtSourcesWithSameLogin() throws Exception {
    System.out.println(CLASS_NAME + "addIDPExtSourcesWithSameLogin");
    ExtSource ext1 = new ExtSource("test1", ExtSourcesManagerEntry.EXTSOURCE_IDP);
    ExtSource ext2 = new ExtSource("test2", ExtSourcesManagerEntry.EXTSOURCE_IDP);
    ext1 = perun.getExtSourcesManagerBl().createExtSource(sess, ext1, null);
    ext2 = perun.getExtSourcesManagerBl().createExtSource(sess, ext2, null);
    UserExtSource ues1 = new UserExtSource(ext1, 1, "testExtLogin@test");
    UserExtSource ues2 = new UserExtSource(ext2, 1, "testExtLogin@test");
    ues1 = usersManager.addUserExtSource(sess, user, ues1);
    ues2 = usersManager.addUserExtSource(sess, user, ues2);
}
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

UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)79 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)34 Test (org.junit.Test)34 ExtSource (cz.metacentrum.perun.core.api.ExtSource)28 Attribute (cz.metacentrum.perun.core.api.Attribute)19 Candidate (cz.metacentrum.perun.core.api.Candidate)18 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)14 User (cz.metacentrum.perun.core.api.User)12 Member (cz.metacentrum.perun.core.api.Member)11 ArrayList (java.util.ArrayList)11 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)8 Group (cz.metacentrum.perun.core.api.Group)7 ExtSourceNotExistsException (cz.metacentrum.perun.core.api.exceptions.ExtSourceNotExistsException)6 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)5 HashMap (java.util.HashMap)5 RichUser (cz.metacentrum.perun.core.api.RichUser)4 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)4 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)4 Matcher (java.util.regex.Matcher)4 RichMember (cz.metacentrum.perun.core.api.RichMember)3