User: starksm
Date: 01/06/15 01:48:25
Modified: src/main/org/jboss/test/security/test TestEJBSpec.java
Log:
Add tests of the EJB2.0 security-identity/run-as element
Revision Changes Path
1.5 +42 -4 jbosstest/src/main/org/jboss/test/security/test/TestEJBSpec.java
Index: TestEJBSpec.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/TestEJBSpec.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestEJBSpec.java 2001/06/12 07:58:41 1.4
+++ TestEJBSpec.java 2001/06/15 08:48:25 1.5
@@ -12,10 +12,10 @@
import org.jboss.test.security.interfaces.StatelessSessionHome;
/** Test of EJB spec conformace using the security-spec.jar
-deployment unit.
+deployment unit. These test the basic role based access model.
-@author [EMAIL PROTECTED]
-@version $Revision: 1.4 $
+@author [EMAIL PROTECTED]
+@version $Revision: 1.5 $
*/
public class TestEJBSpec extends junit.framework.TestCase
{
@@ -122,7 +122,7 @@
}
catch(RemoteException e)
{
- System.out.println("StatelessSession.noop not allowed");
+ System.out.println("StatelessSession.noop failed as expected");
}
bean.remove();
}
@@ -178,6 +178,44 @@
// This is what we expect
}
logout();
+ }
+
+ /** This method tests the following call chains:
+ 1. RunAsStatelessSession.echo() -> PrivateEntity.echo()
+ 2. RunAsStatelessSession.noop() -> RunAsStatelessSession.excluded()
+ 3. RunAsStatelessSession.forward() -> StatelessSession.echo()
+ 1. Should succeed because the run-as identity of RunAsStatelessSession
+ is valid for accessing PrivateEntity.
+ 2. Should succeed ecause the run-as identity of RunAsStatelessSession
+ is valid for accessing RunAsStatelessSession.excluded().
+ 3. Should fail because the run-as identity of RunAsStatelessSession
+ is not Echo.
+ */
+ public void testRunAs() throws Exception
+ {
+ login();
+ InitialContext jndiContext = new InitialContext();
+ Object obj = jndiContext.lookup("spec.RunAsStatelessSession");
+ obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
+ StatelessSessionHome home = (StatelessSessionHome) obj;
+ System.out.println("Found RunAsStatelessSession Home");
+ StatelessSession bean = home.create();
+ System.out.println("Created spec.RunAsStatelessSession");
+ System.out.println("Bean.echo('Hello') -> "+bean.echo("Hello"));
+ bean.noop();
+ System.out.println("Bean.noop(), ok");
+
+ try
+ {
+ // This should not be allowed
+ bean.forward("Hello");
+ fail("Was able to call RunAsStatelessSession.forward");
+ }
+ catch(RemoteException e)
+ {
+ System.out.println("StatelessSession.forward failed as expected");
+ }
+ bean.remove();
}
/** Login as user scott using the conf.name login config or
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development