use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class VosManagerEntryIntegrationTest method removeBanCorrectly.
@Test
public void removeBanCorrectly() throws Exception {
System.out.println(CLASS_NAME + "removeBanCorrectly");
Vo createdVo = vosManagerEntry.createVo(sess, myVo);
Member member = createMemberFromExtSource(createdVo);
BanOnVo ban = new BanOnVo();
ban.setMemberId(member.getId());
vosManagerEntry.setBan(sess, ban);
vosManagerEntry.removeBan(sess, ban.getId());
assertThatExceptionOfType(BanNotExistsException.class).isThrownBy(() -> vosManagerEntry.getBanById(sess, ban.getId()));
}
use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class VosManagerImplIntegrationTest method removeBan.
@Test
public void removeBan() throws Exception {
System.out.println(CLASS_NAME + "removeBan");
BanOnVo originBan = new BanOnVo(-1, member.getId(), vo.getId(), new Date(), "noob");
vosManagerImpl.setBan(sess, originBan);
vosManagerImpl.removeBan(sess, originBan.getId());
assertThatExceptionOfType(BanNotExistsException.class).isThrownBy(() -> vosManagerImpl.getBanById(sess, originBan.getId()));
}
use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class VosManagerBlImpl method removeBanForMember.
@Override
public void removeBanForMember(PerunSession sess, int memberId) throws BanNotExistsException {
BanOnVo ban = vosManagerImpl.getBanForMember(sess, memberId);
removeBan(sess, ban.getId());
}
use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class VosManagerBlImpl method removeBan.
@Override
public void removeBan(PerunSession sess, int banId) throws BanNotExistsException {
BanOnVo ban = vosManagerImpl.getBanById(sess, banId);
vosManagerImpl.removeBan(sess, banId);
Member member;
try {
member = perunBl.getMembersManagerBl().getMemberById(sess, ban.getMemberId());
} catch (MemberNotExistsException e) {
// shouldn't happen
log.error("Failed to find member who was just banned.", e);
throw new ConsistencyErrorException("Failed to find member who was just banned.", e);
}
perunBl.getAuditer().log(sess, new MemberUnsuspended(member));
}
use of cz.metacentrum.perun.core.api.BanOnVo in project perun by CESNET.
the class MembersManagerEntryIntegrationTest method moveMembershipMovesBans.
@Test
public void moveMembershipMovesBans() throws Exception {
System.out.println(CLASS_NAME + "moveMembershipMovesBans");
User sourceUser = perun.getUsersManagerBl().getUserByMember(sess, createdMember);
Member member = setUpMember(createdVo);
User targetUser = perun.getUsersManagerBl().getUserByMember(sess, member);
// delete member - member was created just to create target user
perun.getMembersManager().deleteMember(sess, member);
// create resource and assign it to createdGroup
Facility facility = new Facility(0, "TESTING Facility", "TESTING Facility");
facility = perun.getFacilitiesManagerBl().createFacility(sess, facility);
Resource resource = new Resource(0, "TESTING Resource", "TESTING Resource", facility.getId(), createdVo.getId());
resource = perun.getResourcesManagerBl().createResource(sess, resource, createdVo, facility);
perun.getResourcesManagerBl().assignGroupToResource(sess, createdGroup, resource, false, false, false);
LocalDate today = LocalDate.now();
Date tommorow = Date.from(today.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
BanOnVo banOnVo = new BanOnVo(-1, createdMember.getId(), createdMember.getVoId(), tommorow, "ban");
perun.getVosManagerBl().setBan(sess, banOnVo);
BanOnResource banOnResource = new BanOnResource(-1, tommorow, "ban", createdMember.getId(), resource.getId());
perun.getResourcesManagerBl().setBan(sess, banOnResource);
perun.getMembersManager().moveMembership(sess, createdVo, sourceUser, targetUser);
Member targetMember = perun.getMembersManagerBl().getMemberByUser(sess, createdVo, targetUser);
assertTrue("Ban on VO should be moved from the source member to the target member.", perun.getVosManagerBl().getBanForMember(sess, targetMember.getId()).isPresent());
// Ban on resource should be moved from the source member to the target member
BanOnResource actualBanOnResource = perun.getResourcesManagerBl().getBan(sess, targetMember.getId(), resource.getId());
banOnResource.setId(actualBanOnResource.getId());
banOnResource.setMemberId(targetMember.getId());
assertEquals(banOnResource, actualBanOnResource);
assertThat(perun.getResourcesManagerBl().getBansForMember(sess, targetMember.getId())).containsExactlyInAnyOrder(banOnResource);
}
Aggregations