[jboss-cvs] JBossAS SVN: r65635 - trunk/testsuite/src/main/org/jboss/test/security/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Sep 26 16:36:17 EDT 2007


Author: anil.saldhana at jboss.com
Date: 2007-09-26 16:36:17 -0400 (Wed, 26 Sep 2007)
New Revision: 65635

Modified:
   trunk/testsuite/src/main/org/jboss/test/security/test/LoginModulesUnitTestCase.java
Log:
JBAS-4404:Do not assume that the first group will be ROLES

Modified: trunk/testsuite/src/main/org/jboss/test/security/test/LoginModulesUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/security/test/LoginModulesUnitTestCase.java	2007-09-26 20:29:34 UTC (rev 65634)
+++ trunk/testsuite/src/main/org/jboss/test/security/test/LoginModulesUnitTestCase.java	2007-09-26 20:36:17 UTC (rev 65635)
@@ -888,7 +888,7 @@
          Set groups = subject.getPrincipals(Group.class);
          assertTrue("Principals contains stark", subject.getPrincipals().contains(new SimplePrincipal("stark")));
          assertTrue("Principals contains Roles", groups.contains(new SimplePrincipal("Roles")));
-         Group roles = (Group) groups.iterator().next();
+         Group roles = findRolesGroup(groups);
          assertTrue("Java is a role", roles.isMember(new SimplePrincipal("Java")));
          assertTrue("Coder is a role", roles.isMember(new SimplePrincipal("Coder")));
 
@@ -927,7 +927,7 @@
          Set groups = subject.getPrincipals(Group.class);
          assertTrue("Principals contains jduke", subject.getPrincipals().contains(new SimplePrincipal("jduke")));
          assertTrue("Principals contains Roles", groups.contains(new SimplePrincipal("Roles")));
-         Group roles = (Group) groups.iterator().next();
+         Group roles = findRolesGroup(groups);
          // Only the roles from the DatabaseServerLoginModule should exist
          assertTrue("Role1 is a role", roles.isMember(new SimplePrincipal("Role1")));
          assertTrue("Role2 is a role", roles.isMember(new SimplePrincipal("Role2")));
@@ -1027,6 +1027,20 @@
 
    }
 
+   // Method to find the group named "Roles" in the given Set of groups.
+   private Group findRolesGroup(Set groups)
+   {
+       // Find the "Roles" group:
+       Iterator groupsIter = groups.iterator();
+       Group roles = null;
+       while (groupsIter.hasNext()) {
+      	 roles = (Group)groupsIter.next();
+      	 if (roles.getName().equals("Roles"))
+      		 break;
+       }
+       return roles;
+   }
+
    private Connection setupLoginTables() throws Exception
    {
       Class.forName("org.hsqldb.jdbcDriver");




More information about the jboss-cvs-commits mailing list