use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_shellTest method testCheckAttributeValue.
/**
* Test of checkAttributeValue method, of class urn_perun_user_facility_attribute_def_def_shell.
* with all parameters properly set.
*/
@Test
public void testCheckAttributeValue() throws Exception {
System.out.println("testCheckAttributeValue()");
Attribute attributeToCheck = new Attribute();
attributeToCheck.setValue("/bin/bash");
when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSession.class), any(Facility.class), any(User.class))).thenReturn(new ArrayList<Resource>() {
{
add(resource);
}
});
when(session.getPerunBl().getFacilitiesManagerBl().getAssignedResources(any(PerunSession.class), any(Facility.class))).thenReturn(new ArrayList<Resource>() {
{
add(resource);
}
});
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), eq(AttributesManager.NS_RESOURCE_ATTR_DEF + ":shells"))).thenReturn(listOfShells);
classInstance.checkAttributeValue(session, facility, user, attributeToCheck);
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_shellTest method testCheckAttributeValueWithEmptyAttribute.
/**
* Test of checkAttributeValue method, of class urn_perun_user_facility_attribute_def_def_shell.
* with empty attribute.
*/
public void testCheckAttributeValueWithEmptyAttribute() throws Exception {
System.out.println("testCheckAttributeValueWithEmptyAttribute()");
when(session.getPerunBl().getUsersManagerBl().getAllowedResources(any(PerunSession.class), any(Facility.class), any(User.class))).thenReturn(new ArrayList<Resource>() {
{
add(resource);
}
});
when(session.getPerunBl().getFacilitiesManagerBl().getAssignedResources(any(PerunSession.class), any(Facility.class))).thenReturn(new ArrayList<Resource>() {
{
add(resource);
}
});
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenReturn(listOfShells);
classInstance.checkAttributeValue(session, facility, user, new Attribute());
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class OwnersManagerBlImpl method deleteOwner.
public void deleteOwner(PerunSession sess, Owner owner, boolean forceDelete) throws InternalErrorException, RelationExistsException, OwnerAlreadyRemovedException {
// Check if the owner is assigned to some facility
List<Facility> facilities = getPerunBl().getFacilitiesManagerBl().getOwnerFacilities(sess, owner);
if (facilities != null && facilities.size() > 0) {
if (!forceDelete) {
throw new RelationExistsException("Owner own " + facilities.size() + " facilities");
} else {
for (Facility facility : facilities) {
try {
getPerunBl().getFacilitiesManagerBl().removeOwner(sess, facility, owner);
} catch (OwnerAlreadyRemovedException e) {
throw new InternalErrorException(e);
}
}
}
}
//Remove all information about owner on facilities (facilities contacts)
List<ContactGroup> ownerContactGroups = getPerunBl().getFacilitiesManagerBl().getFacilityContactGroups(sess, owner);
if (!ownerContactGroups.isEmpty()) {
if (forceDelete) {
getPerunBl().getFacilitiesManagerBl().removeAllOwnerContacts(sess, owner);
} else {
throw new RelationExistsException("Owner has still some facilities contacts : " + ownerContactGroups);
}
}
getOwnersManagerImpl().deleteOwner(sess, owner);
getPerunBl().getAuditer().log(sess, "{} deleted.", owner);
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class SecurityTeamsManagerBlImpl method deleteSecurityTeam.
@Override
public void deleteSecurityTeam(PerunSession sess, SecurityTeam securityTeam, boolean forceDelete) throws SecurityTeamNotExistsException, InternalErrorException, RelationExistsException {
// remove all users from blacklist, which were blacklisted by this security team.
List<User> blacklist = getSecurityTeamsManagerImpl().getBlacklist(sess, Arrays.asList(securityTeam));
if (blacklist != null && !blacklist.isEmpty() && !forceDelete) {
throw new RelationExistsException("SecurityTeam has blacklisted users.");
}
for (User blacklistedUser : blacklist) {
// calling BL will make auditer message about user to appear.
getPerunBl().getSecurityTeamsManagerBl().removeUserFromBlacklist(sess, securityTeam, blacklistedUser);
}
// remove security team from all facilities
List<Facility> facilities = getPerunBl().getFacilitiesManagerBl().getAssignedFacilities(sess, securityTeam);
if (facilities != null && !facilities.isEmpty() && !forceDelete) {
throw new RelationExistsException("SecurityTeam is assigned to some facilities.");
}
for (Facility facility : facilities) {
// calling BL will make auditer message about facility to appear.
getPerunBl().getFacilitiesManagerBl().removeSecurityTeam(sess, facility, securityTeam);
}
getSecurityTeamsManagerImpl().deleteSecurityTeam(sess, securityTeam);
getPerunBl().getAuditer().log(sess, "{} was deleted.", securityTeam);
}
use of cz.metacentrum.perun.core.api.Facility in project perun by CESNET.
the class FacilitiesManagerBlImpl method getRichFacilities.
public List<RichFacility> getRichFacilities(PerunSession perunSession, List<Facility> facilities) throws InternalErrorException {
List<RichFacility> richFacilities = new ArrayList<RichFacility>();
if (facilities == null || facilities.isEmpty())
return richFacilities;
else {
for (Facility f : facilities) {
List<Owner> fOwners = this.getOwners(perunSession, f);
RichFacility rf = new RichFacility(f, fOwners);
richFacilities.add(rf);
}
}
return richFacilities;
}
Aggregations