assertEquals("pre con", res.getResult(0));
}
public void testSecurity()
{
m_context.initialize(new SimplePrincipal("jsmith"));
Server server = (Server)m_context.getComponentInstance("Server.Generic");
Request req = new Request();
req.addInvocation(new TransferObject("Contact", "read"),
new Object[]{null, null, null, new Integer(-1), new Integer(0), Boolean.FALSE});
try
{
server.invoke(req);
fail("Expected SecurityViolationException");
}
catch (SecurityViolationException e)
{
assertEquals("err.runtime.privilege", e.getErrorCode());
assertEquals("readContact", e.getErrorArgs()[0]);
}
req = new Request();
req.addInvocation(new TransferObject("StringEnum", "read"),
new Object[]{null, parse("(= value (SupportedLocaleEnum'en))"),
null, new Integer(-1), new Integer(0), Boolean.FALSE});
Response res = server.invoke(req);
assertEquals(1, res.getResultCount());
assertEquals(1, ((List)res.getResult(0)).size());
req.getInvocation(0).getArguments()[1] = parse("(= (user) (User'getUser \"jsmith\"))");
try
{
res = server.invoke(req);
fail("Expected SecurityViolationException");
}
catch (SecurityViolationException e)
{
assertEquals("err.rpc.eventVisibility", e.getErrorCode());
assertEquals("getUser", e.getErrorArgs()[0]);
assertEquals("User", e.getErrorArgs()[1]);
}
req = new Request();
req.addInvocation(new TransferObject("Address", "read"),
new Object[]{null, parse("(!= (@ contact (instance? (@) Patient) birthdate) ())"),
null, new Integer(-1), new Integer(0), Boolean.FALSE});
try
{
server.invoke(req);
fail("Expected SecurityViolationException");
}
catch (SecurityViolationException e)
{
assertEquals("err.rpc.attributeReadPrivilege", e.getErrorCode());
assertEquals("birthdate", e.getErrorArgs()[0]);
assertEquals("Patient", e.getErrorArgs()[1]);
assertEquals("readContact", e.getErrorArgs()[2]);
}
m_context.initialize(new SimplePrincipal("jtest"));
req = new Request();
req.addInvocation(new TransferObject("Address", "read"),
new Object[]{null, parse("(!= (@ contact (instance? (@) Patient) birthdate) ())"),
null, new Integer(-1), new Integer(0), Boolean.FALSE});