geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r663474 - in /geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests: sec-ear/src/test/java/org/apache/geronimo/testsuite/security/ sec-ejb/ sec-ejb/src/main/java/org/apache/geronimo/itest/ sec-ejb/src/main/resources/META-INF/ sec-w...
Date Thu, 05 Jun 2008 06:47:44 GMT
Author: djencks
Date: Wed Jun  4 23:47:44 2008
New Revision: 663474

URL: http://svn.apache.org/viewvc?rev=663474&view=rev
Log:
add some role-ref tests to sec-tests

Modified:
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/pom.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/resources/META-INF/openejb-jar.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java?rev=663474&r1=663473&r2=663474&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java
Wed Jun  4 23:47:44 2008
@@ -59,8 +59,12 @@
         System.out.println("----------------------------------------------");
         System.out.println(selenium.getText("xpath=/html/body"));
         assertEquals("TestServlet principal: foo\n" +
-                "Test EJB principal: bar\n" +
-                "Correctly received security exception on noAccess method", selenium.getText("xpath=/html/body"));
+            "TestServlet isUserInRole foo: true\n" +
+            "TestServlet isUserInRole bar: false\n" +
+            "Test EJB principal: bar\n" +
+            "Correctly received security exception on noAccess method\n" +
+            "TestSession isCallerInRole foo: false\n" +
+            "TestSession isCallerInRole bar: true", selenium.getText("xpath=/html/body"));
     }
 
     @Test

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/pom.xml?rev=663474&r1=663473&r2=663474&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/pom.xml Wed Jun
 4 23:47:44 2008
@@ -52,6 +52,11 @@
             <artifactId>geronimo-ejb_3.0_spec</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-annotation_1.0_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.framework</groupId>

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java?rev=663474&r1=663473&r2=663474&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
Wed Jun  4 23:47:44 2008
@@ -24,5 +24,5 @@
 public interface TestSession  extends javax.ejb.EJBObject {
     String testAccess() throws RemoteException;
     String testNoAccess() throws RemoteException;
-
+    boolean isCallerInRole(String role);
 }

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java?rev=663474&r1=663473&r2=663474&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java
Wed Jun  4 23:47:44 2008
@@ -23,6 +23,7 @@
 /**
  * @version $Rev$ $Date$
  */
+@javax.annotation.security.DeclareRoles({"foo", "bar"})
 public class TestSessionBean implements SessionBean {
 
     SessionContext sessionContext;
@@ -35,6 +36,10 @@
         return sessionContext.getCallerPrincipal().getName();
     }
 
+    public boolean isCallerInRole(String role) {
+        return sessionContext.isCallerInRole(role);
+    }
+
     public void ejbCreate() {
         System.out.println("TestSessionBean");
     }

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/resources/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/resources/META-INF/openejb-jar.xml?rev=663474&r1=663473&r2=663474&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/resources/META-INF/openejb-jar.xml
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/resources/META-INF/openejb-jar.xml
Wed Jun  4 23:47:44 2008
@@ -32,34 +32,34 @@
             <ejb-name>TestSession</ejb-name>
         </session>
     </enterprise-beans>
-    <security xmlns="http://geronimo.apache.org/xml/ns/security-2.0">
-        <credential-store-ref>
-            <name xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">TestCredentialStore</name>
-        </credential-store-ref>
-        <role-mappings>
-            <role role-name="foo">
-                <run-as-subject>
-                    <realm>test-realm</realm>
-                    <id>foo-subject</id>
-                </run-as-subject>
-                <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"
name="foo"/>
-            </role>
-            <role role-name="bar">
-                <run-as-subject>
-                    <realm>test-realm</realm>
-                    <id>bar-subject</id>
-                </run-as-subject>
-                <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"
name="bar"/>
-            </role>
-        </role-mappings>
-    </security>
+    <s:security xmlns:s="http://geronimo.apache.org/xml/ns/security-2.0">
+        <s:credential-store-ref>
+            <d:name xmlns:d="http://geronimo.apache.org/xml/ns/deployment-1.2">TestCredentialStore</d:name>
+        </s:credential-store-ref>
+        <s:role-mappings>
+            <s:role role-name="foo">
+                <s:run-as-subject>
+                    <s:realm>test-realm</s:realm>
+                    <s:id>foo-subject</s:id>
+                </s:run-as-subject>
+                <s:principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"
name="foo"/>
+            </s:role>
+            <s:role role-name="bar">
+                <s:run-as-subject>
+                    <s:realm>test-realm</s:realm>
+                    <s:id>bar-subject</s:id>
+                </s:run-as-subject>
+                <s:principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"
name="bar"/>
+            </s:role>
+        </s:role-mappings>
+    </s:security>
     <gbean name="test-realm"
            class="org.apache.geronimo.security.realm.GenericSecurityRealm">
         <attribute name="realmName">test-realm</attribute>
         <xml-reference name="LoginModuleConfiguration">
             <lc:login-config xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-${geronimoSchemaVersion}">
                 <lc:login-module control-flag="REQUIRED" wrap-principals="false">
-                    <lc:login-domain-name>test-realm</lc:login-domain-name>
+                    <lc:login-domain-name>test-domain</lc:login-domain-name>
                     <lc:login-module-class>org.apache.geronimo.itest.TestLoginModule</lc:login-module-class>
                     <lc:option name="users">foo,bar</lc:option>
                 </lc:login-module>
@@ -98,6 +98,9 @@
                 </realm>
             </credential-store>
         </xml-attribute>
+        <dependency>
+            <n:name xmlns:n="http://geronimo.apache.org/xml/ns/naming-1.2">test-realm</n:name>
+        </dependency>
     </gbean>
 </openejb-jar>
 

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java?rev=663474&r1=663473&r2=663474&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java
Wed Jun  4 23:47:44 2008
@@ -48,6 +48,8 @@
     protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws ServletException, IOException {
         PrintWriter out = httpServletResponse.getWriter();
         out.println("TestServlet principal: " + httpServletRequest.getUserPrincipal().getName());
+        out.println("TestServlet isUserInRole foo: " + httpServletRequest.isUserInRole("foo"));
+        out.println("TestServlet isUserInRole bar: " + httpServletRequest.isUserInRole("bar"));
         try {
             String principalName = session.testAccess();
             out.println("Test EJB principal: " + principalName);
@@ -57,6 +59,8 @@
             } catch (AccessException e) {
                 out.println("Correctly received security exception on noAccess method");
             }
+            out.println("TestSession isCallerInRole foo: " + session.isCallerInRole("foo"));
+            out.println("TestSession isCallerInRole bar: " + session.isCallerInRole("bar"));
         } catch (RemoteException e) {
             e.printStackTrace();
         }

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java?rev=663474&r1=663473&r2=663474&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
Wed Jun  4 23:47:44 2008
@@ -43,6 +43,8 @@
     protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws ServletException, IOException {
         PrintWriter out = httpServletResponse.getWriter();
         out.println("TestServlet principal: " + httpServletRequest.getUserPrincipal().getName());
+        out.println("TestServlet isUserInRole foo: " + httpServletRequest.isUserInRole("foo"));
+        out.println("TestServlet isUserInRole bar: " + httpServletRequest.isUserInRole("bar"));
         try {
             InitialContext ctx = new InitialContext();
 
@@ -57,6 +59,8 @@
             } catch (AccessException e) {
                 out.println("Correctly received security exception on noAccess method");
             }
+            out.println("TestSession isCallerInRole foo: " + session.isCallerInRole("foo"));
+            out.println("TestSession isCallerInRole bar: " + session.isCallerInRole("bar"));
 
         } catch (NamingException e) {
             System.out.print("Exception:");

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml?rev=663474&r1=663473&r2=663474&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml
Wed Jun  4 23:47:44 2008
@@ -77,6 +77,7 @@
             <web-resource-name>secureServlet</web-resource-name>
             <url-pattern>/servlet</url-pattern>
             <url-pattern>/jsp</url-pattern>
+            <url-pattern>/injectionServlet</url-pattern>
             <http-method>GET</http-method>
             <http-method>POST</http-method>
         </web-resource-collection>



Mime
View raw message