use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_virt_shellTest method setUp.
@Before
public void setUp() {
classInstance = new urn_perun_user_facility_attribute_def_virt_shell();
session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
preffered = new Attribute();
defDefShell = new Attribute();
facilityShell = new Attribute();
resourceShell = new ArrayList();
listOfMntPts = new ArrayList<String>();
for (int i = 0; i < 5; i++) listOfMntPts.add("/mnt/bash" + i);
preffered.setValue(new ArrayList(listOfMntPts));
listOfMntPts.clear();
listOfMntPts.add("/mnt/bash2");
facilityShell.setValue(listOfMntPts);
resourceShell.addAll(listOfMntPts);
user = new User();
facility = new Facility();
resource = new Resource();
resource.setName("myResource");
resource.setDescription("desc");
resource1 = new Resource();
resource1.setId(1);
resource1.setName("myResource");
resource1.setDescription("desc");
resourceList = new ArrayList<Resource>();
resourceList.add(resource1);
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_resource_attribute_def_def_shellsTest method testCheckAttributeValueWrongShellFormatShellIsDirectory.
@Test(expected = WrongAttributeValueException.class)
public void testCheckAttributeValueWrongShellFormatShellIsDirectory() throws Exception {
System.out.println("testCheckAttributeValueWrongShellFormatShellIsDirectory()");
Attribute attributeToCheck = new Attribute();
attributeToCheck.setValue(new ArrayList<String>() {
{
add("/bin/bash/");
}
});
when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Facility.class), anyString())).thenReturn(listOfShells);
classInstance.checkAttributeValue(session, new Resource(), attributeToCheck);
fail("Shell attribute with inappropriate format was approved.");
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_member_resource_attribute_def_virt_isBannedTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_member_resource_attribute_def_virt_isBanned();
session = mock(PerunSessionImpl.class, RETURNS_DEEP_STUBS);
facility = new Facility(1, "testFacility");
resource = new Resource(1, "testResource", "desc", 1, 1);
vo = new Vo(1, "testVo", "desc");
user = new User(1, "name", "surname", "middlename", "title", "title");
member = new Member(1, 1, 1, Status.VALID);
banOnResource = new BanOnResource(1, new Date(), "test", 1, 1);
banOnFacility = new BanOnFacility(1, new Date(), "test", 1, 1);
isBanned = new Attribute(classInstance.getAttributeDefinition());
isBanned.setValue(true);
message1 = "Ban " + banOnResource.serializeToString() + " was set for memberId 1 on resourceId 1";
message2 = "Ban " + banOnResource.serializeToString() + " was updated for memberId 1 on resourceId 1";
message3 = "Ban " + banOnResource.serializeToString() + " was removed for memberId 1 on resourceId 1";
message4 = "Ban " + banOnFacility.serializeToString() + " was set for userId 1 on facilityId 1";
message5 = "Ban " + banOnFacility.serializeToString() + " was updated for userId 1 on facilityId 1";
message6 = "Ban " + banOnFacility.serializeToString() + " was removed for userId 1 on facilityId 1";
wrongMessage = "Ban " + banOnFacility.serializeToString() + " was destroyed for userId 1 on facilityId 1";
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_resource_attribute_def_def_defaultShellTest method fillAttributeWhichNotExists.
@Test
public void fillAttributeWhichNotExists() throws Exception {
System.out.println("fillAttributeWhichNotExists()");
//testujeme scenar, kdy budeme hledat neexistujici atribut a proto ocekavame vyjimku AttrNotExists..
when(ps.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenThrow(new AttributeNotExistsException("neexistuje"));
try {
defShellAttr.fillAttribute(ps, new Resource(), new AttributeDefinition());
fail();
} catch (InternalErrorException ex) {
assertTrue("Mela byt vyhozena vyjimka AttributeNotExistsException", (ex.getCause() instanceof AttributeNotExistsException));
}
}
use of cz.metacentrum.perun.core.api.Resource in project perun by CESNET.
the class urn_perun_resource_attribute_def_def_defaultShellTest method checkAttributeValueWhichNotExists.
@Test
public void checkAttributeValueWhichNotExists() throws Exception {
System.out.println("checkAttributeValueWhichNotExists()");
// hledame neexistujici atribut, proto ocekavame vyjimku
when(ps.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenThrow(new AttributeNotExistsException("neexistuje"));
final Attribute attribute = new Attribute();
attribute.setValue("mujShell");
try {
defShellAttr.checkAttributeValue(ps, new Resource(), attribute);
fail();
} catch (InternalErrorException ex) {
assertTrue("Mela byt vyhozena vyjimka AttributeNotExistsException", (ex.getCause() instanceof AttributeNotExistsException));
}
}
Aggregations