You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2007/10/03 20:46:21 UTC

svn commit: r581682 - in /geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src: main/resources/META-INF/geronimo-application.xml test/java/org/apache/geronimo/testsuite/jcacms/CmsTest.java

Author: gawor
Date: Wed Oct  3 11:46:20 2007
New Revision: 581682

URL: http://svn.apache.org/viewvc?rev=581682&view=rev
Log:
fixed the jca-cms-tests. added another login module that actaully validates the credentials

Modified:
    geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/main/resources/META-INF/geronimo-application.xml
    geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/test/java/org/apache/geronimo/testsuite/jcacms/CmsTest.java

Modified: geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/main/resources/META-INF/geronimo-application.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/main/resources/META-INF/geronimo-application.xml?rev=581682&r1=581681&r2=581682&view=diff
==============================================================================
--- geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/main/resources/META-INF/geronimo-application.xml (original)
+++ geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/main/resources/META-INF/geronimo-application.xml Wed Oct  3 11:46:20 2007
@@ -83,17 +83,22 @@
                     </connection-definition>
                 </outbound-resourceadapter>
             </resourceadapter>
-            <gbean name="test-cms-realm"
-                   class="org.apache.geronimo.security.realm.GenericSecurityRealm">
+            <gbean name="test-cms-realm" class="org.apache.geronimo.security.realm.GenericSecurityRealm">
                 <attribute name="realmName">test-cms-realm</attribute>
-                <xml-reference name="LoginModuleConfiguration">
-                    <lc:login-config xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-1.1">
+                <xml-reference name="LoginModuleConfiguration" xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-1.1">
+                    <lc:login-config>
                         <lc:login-module-ref control-flag="REQUIRED">
                             <lc:pattern>
                                 <name xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">test-cms-credentials
                                 </name>
                             </lc:pattern>
                         </lc:login-module-ref>
+                        <lc:login-module control-flag="REQUIRED" wrap-principals="false">
+                            <lc:login-domain-name>test-app-credentials</lc:login-domain-name>
+                            <lc:login-module-class>org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule</lc:login-module-class>
+                            <lc:option name="usersURI">var/security/demo_users.properties</lc:option>
+                            <lc:option name="groupsURI">var/security/demo_groups.properties</lc:option>
+                        </lc:login-module>
                     </lc:login-config>
                 </xml-reference>
                 <reference name="ServerInfo">
@@ -118,7 +123,7 @@
             <security-realm-name>test-cms-realm</security-realm-name>
             <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">test-credential-store</name>
+                    <name xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">test-credential-store</name>
                 </credential-store-ref>
                 <default-subject>
                     <realm>test-cms-realm</realm>
@@ -126,7 +131,7 @@
                 </default-subject>
                 <role-mappings>
                     <role role-name="test">
-                        <principal class="org.apache.geronimo.connector.outbound.security.ResourcePrincipal" name="system"/>
+                        <principal class="org.apache.geronimo.connector.outbound.security.ResourcePrincipal" name="george"/>
                     </role>
                     <role role-name="fail">
                         <run-as-subject>
@@ -146,22 +151,22 @@
                                 <id>test</id>
                                 <credential>
                                     <type>org.apache.geronimo.security.credentialstore.NameCallbackHandler</type>
-                                    <value>system</value>
+                                    <value>george</value>
                                 </credential>
                                 <credential>
                                     <type>org.apache.geronimo.security.credentialstore.PasswordCallbackHandler</type>
-                                    <value>manager</value>
+                                    <value>bone</value>
                                 </credential>
                             </subject>
                             <subject>
                                 <id>fail</id>
                                 <credential>
                                     <type>org.apache.geronimo.security.credentialstore.NameCallbackHandler</type>
-                                    <value>unauthorized</value>
+                                    <value>gracie</value>
                                 </credential>
                                 <credential>
                                     <type>org.apache.geronimo.security.credentialstore.PasswordCallbackHandler</type>
-                                    <value>nope</value>
+                                    <value>biscuit</value>
                                 </credential>
                             </subject>
                         </realm>

Modified: geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/test/java/org/apache/geronimo/testsuite/jcacms/CmsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/test/java/org/apache/geronimo/testsuite/jcacms/CmsTest.java?rev=581682&r1=581681&r2=581682&view=diff
==============================================================================
--- geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/test/java/org/apache/geronimo/testsuite/jcacms/CmsTest.java (original)
+++ geronimo/server/branches/2.0/testsuite/deployment-testsuite/jca-cms-tests/jca-cms-ear/src/test/java/org/apache/geronimo/testsuite/jcacms/CmsTest.java Wed Oct  3 11:46:20 2007
@@ -32,12 +32,53 @@
     extends SeleniumTestSupport
 {
     @Test
-    public void testPageContent() throws Exception {
-        selenium.open("http://system:manager@localhost:8080/jca-cms/servlet");
+    public void testPageContent1() throws Exception {
+        selenium.open("http://localhost:8080/jca-cms/default-subject-servlet");
         selenium.waitForPageToLoad("30000");
 
-        //TODO the line separators might well be wrong???
-        assertEquals("Successfully got configured connection\n\nSuccessfully got container managed connection\n", selenium.getText("xpath=/html/body"));
+        String body = selenium.getText("xpath=/html/body");
+
+        assertTrue(body.endsWith(
+//                "Current subject: Subject:\n" +
+//                "\tPrincipal: org.apache.geronimo.connector.outbound.security.ResourcePrincipal@cb1c722f\n" +
+//                "\tPrincipal: org.apache.geronimo.security.IdentificationPrincipal[[1186174499145:0x607c7eb7837eabcd6b759e6f9d29e7eee72622d6]]\n" +
+//                "\tPrincipal: org.apache.geronimo.security.IdentificationPrincipal[[1186174499146:0x7622e0831ed59a4cd6c277a53491de74f1489311]]\n" +
+//                "\tPrivate Credential: javax.resource.spi.security.PasswordCredential@23f33e5c\n" +
+//                "\n" +
+//                "Next subject:    Subject:\n" +
+//                "\tPrincipal: org.apache.geronimo.connector.outbound.security.ResourcePrincipal@cb1c722f\n" +
+//                "\tPrincipal: org.apache.geronimo.security.IdentificationPrincipal[[1186174499145:0x607c7eb7837eabcd6b759e6f9d29e7eee72622d6]]\n" +
+//                "\tPrincipal: org.apache.geronimo.security.IdentificationPrincipal[[1186174499146:0x7622e0831ed59a4cd6c277a53491de74f1489311]]\n" +
+//                "\tPrivate Credential: javax.resource.spi.security.PasswordCredential@23f33e5c\n" +
+//                "\n" +
+                "Successfully got configured connection\n" +
+                "\n" +
+                "Successfully got container managed connection"));
+
+        String expectedPrincipal = "Principal: george";
+        int pos1 = body.indexOf(expectedPrincipal);
+        assertTrue("Expected current subject principal", pos1 > 0);
+        int pos2 = body.indexOf(expectedPrincipal, pos1 + expectedPrincipal.length());
+        assertTrue("Expected next subject principal", pos2 > 0);
+    }
+
+    @Test
+    public void testPageContent2() throws Exception {
+        selenium.open("http://localhost:8080/jca-cms/run-as-servlet");
+        selenium.waitForPageToLoad("30000");
+
+        String body = selenium.getText("xpath=/html/body");
+
+        assertTrue(body.endsWith(
+                "Successfully got configured connection\n" +
+                "\n" +
+                "Successfully got container managed connection"));
+
+        String expectedPrincipal = "Principal: george";
+        int pos1 = body.indexOf(expectedPrincipal);
+        assertTrue("Expected current subject principal", pos1 > 0);
+        int pos2 = body.indexOf("Principal: gracie", pos1 + expectedPrincipal.length());
+        assertTrue("Expected next subject principal", pos2 > 0);
     }
 }