use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method setUserExtSourceAttribute.
@Test
public void setUserExtSourceAttribute() throws Exception {
System.out.println(CLASS_NAME + "setUserExtSourceAttribute");
UserExtSource ues = setUpUserExtSourceTest();
attributes = setUpUserExtSourceAttribute();
attributesManager.setAttribute(sess, ues, attributes.get(0));
Attribute retAttr = attributesManager.getAttribute(sess, ues, "urn:perun:ues:attribute-def:opt:userExtSource-test-attribute");
assertNotNull("unable to get userExtSource attribute by name", retAttr);
assertEquals("returned userExtSource attribute is not same as stored", retAttr, attributes.get(0));
}
use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method getAdmins.
@Test
public void getAdmins() throws Exception {
System.out.println(CLASS_NAME + "getAdmins");
vo = setUpVo();
setUpGroup(vo);
// set up first user
Member member = setUpMember(vo);
User user = perun.getUsersManagerBl().getUserByMember(sess, member);
groupsManager.addAdmin(sess, group, user);
// set up authorized group
Group authorizedGroup = new Group("authorizedGroup", "testovaciGroup");
Group returnedGroup = groupsManager.createGroup(sess, vo, authorizedGroup);
groupsManager.addAdmin(sess, group, 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(extSource, Long.toHexString(Double.doubleToLongBits(Math.random())));
candidate.setUserExtSource(userExtSource);
candidate.setAttributes(new HashMap<String, String>());
Member member2 = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
User user2 = perun.getUsersManagerBl().getUserByMember(sess, member2);
groupsManager.addMember(sess, returnedGroup, member2);
// test
List<User> admins = groupsManager.getAdmins(sess, group);
assertTrue("group 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));
}
use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method setUpCandidate.
private Candidate setUpCandidate(int i) {
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 + i);
candidate.setMiddleName("");
candidate.setLastName(userLastName);
candidate.setTitleBefore("");
candidate.setTitleAfter("");
final UserExtSource userExtSource = new UserExtSource(extSource, extLogin);
candidate.setUserExtSource(userExtSource);
candidate.setAttributes(new HashMap<String, String>());
return candidate;
}
use of cz.metacentrum.perun.core.api.UserExtSource 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));
}
use of cz.metacentrum.perun.core.api.UserExtSource 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)
}
Aggregations