use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method setUpSponsoredUserForVo.
private void setUpSponsoredUserForVo(Vo vo) throws Exception {
Candidate candidate = setUpCandidateForSponsoredUser();
AuthzResolverBlImpl.setRole(sess, user, vo, Role.SPONSOR);
Member sponsoredMember = perun.getMembersManagerBl().createMember(sess, vo, candidate);
perun.getMembersManagerBl().setSponsorshipForMember(sess, sponsoredMember, user);
perun.getMembersManagerBl().validateMember(sess, sponsoredMember);
// set first candidate as member of test VO
assertNotNull("No member created", sponsoredMember);
sponsoredUser = usersManager.getUserByMember(sess, sponsoredMember);
usersForDeletion.add(sponsoredUser);
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method testCreateServiceUserSetsAttributes.
@Test
public void testCreateServiceUserSetsAttributes() throws Exception {
System.out.println(CLASS_NAME + "testCreateServiceUserSetsAttributes");
Candidate candidate = setUpCandidateForSpecificUser1();
Map<String, String> attrs = new HashMap<>();
String value = "asdf@sdf.df";
attrs.put(URN_ATTR_USER_PREFERRED_MAIL, value);
candidate.setAttributes(attrs);
User createdUser = usersManager.createServiceUser(sess, candidate, Collections.emptyList());
Attribute attr = perun.getAttributesManagerBl().getAttribute(sess, createdUser, URN_ATTR_USER_PREFERRED_MAIL);
assertThat(attr.getValue()).isEqualTo(value);
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method testCreateServiceUser.
@Test
public void testCreateServiceUser() throws Exception {
System.out.println(CLASS_NAME + "testCreateServiceUser");
Candidate candidate = setUpCandidateForSpecificUser1();
User createdUser = usersManager.createServiceUser(sess, candidate, Collections.emptyList());
createdUser = usersManager.getUserById(sess, createdUser.getId());
assertThat(createdUser).isEqualToComparingOnlyGivenFields(candidate, "firstName", "lastName");
assertThat(createdUser.isServiceUser());
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class UsersManagerEntryIntegrationTest method setUpCandidate.
private Candidate setUpCandidate() {
// Mockito.mock(Candidate.class);
Candidate candidate = new Candidate();
candidate.setFirstName(userFirstName);
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName(userLastName);
candidate.setTitleBefore("");
candidate.setTitleAfter("");
final UserExtSource userExtSource = new UserExtSource(extSource, extLogin);
candidate.setUserExtSource(userExtSource);
candidate.setAttributes(new HashMap<>());
return candidate;
}
use of cz.metacentrum.perun.core.api.Candidate in project perun by CESNET.
the class FacilitiesManagerBlImplTest method setUp.
@Before
public void setUp() throws Exception {
candidate = new Candidate();
candidate.setFirstName("some");
candidate.setId(0);
candidate.setMiddleName("");
candidate.setLastName("testingUser");
candidate.setTitleBefore("");
candidate.setTitleAfter("");
ues = new UserExtSource(extSource, "extLogin");
candidate.setUserExtSource(ues);
candidate.setAttributes(new HashMap<>());
sess = perun.getPerunSession(new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient());
vo = new Vo(0, "FacilitiesManagerBlImplTestVo", "FacMgrBlImplTestVo");
vo = perun.getVosManagerBl().createVo(sess, vo);
member = perun.getMembersManagerBl().createMemberSync(sess, vo, candidate);
group = new Group("testGroup", "testGroup");
group = perun.getGroupsManagerBl().createGroup(sess, vo, group);
perun.getGroupsManagerBl().addMember(sess, group, member);
facility = new Facility(0, "testFac");
facility = perun.getFacilitiesManagerBl().createFacility(sess, facility);
resource = new Resource(0, "testRes", null, facility.getId(), vo.getId());
resource = perun.getResourcesManagerBl().createResource(sess, resource, vo, facility);
perun.getResourcesManagerBl().assignGroupToResource(sess, group, resource, false, false, false);
// second branch
vo2 = new Vo(0, "FacilitiesManagerBlImplTestVo2", "FacMgrBlImplTestVo2");
vo2 = perun.getVosManagerBl().createVo(sess, vo2);
member2 = perun.getMembersManagerBl().createMemberSync(sess, vo2, candidate);
group2 = new Group("testGroup", "testGroup");
group2 = perun.getGroupsManagerBl().createGroup(sess, vo2, group2);
perun.getGroupsManagerBl().addMember(sess, group2, member2);
resource2 = new Resource(0, "testRes2", null, facility.getId(), vo2.getId());
resource2 = perun.getResourcesManagerBl().createResource(sess, resource2, vo2, facility);
// third branch
facility2 = new Facility(0, "testFac2");
facility2 = perun.getFacilitiesManagerBl().createFacility(sess, facility2);
resource3 = new Resource(0, "testRes3", null, facility2.getId(), vo2.getId());
resource3 = perun.getResourcesManagerBl().createResource(sess, resource3, vo2, facility2);
perun.getResourcesManagerBl().assignGroupToResources(sess, group2, Arrays.asList(resource2, resource3), false, false, false);
user = perun.getUsersManagerBl().getUserByMember(sess, member);
}
Aggregations