continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r421010 - /maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsServiceTest.java
Date Tue, 11 Jul 2006 22:07:03 GMT
Author: carlos
Date: Tue Jul 11 15:07:02 2006
New Revision: 421010

URL: http://svn.apache.org/viewvc?rev=421010&view=rev
Log:
Fixed test

Modified:
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsServiceTest.java

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsServiceTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsServiceTest.java?rev=421010&r1=421009&r2=421010&view=diff
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsServiceTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsServiceTest.java
Tue Jul 11 15:07:02 2006
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import org.acegisecurity.GrantedAuthority;
 import org.acegisecurity.providers.encoding.ShaPasswordEncoder;
 import org.acegisecurity.userdetails.UserDetails;
 import org.apache.maven.continuum.model.system.ContinuumUser;
@@ -40,45 +41,51 @@
         throws Exception
     {
         super.setUp();
+        userDetailsService = new ContinuumUserDetailsService();
     }
 
     public void testGetUserDetails()
     {
+        Permission p0 = new Permission();
+        p0.setName( "p0" );
         Permission p1 = new Permission();
         p1.setName( "p1" );
         Permission p2 = new Permission();
         p2.setName( "p2" );
-        Permission p3 = new Permission();
-        p3.setName( "p3" );
-        
+
         UserGroup group = new UserGroup();
+        group.addPermission( p0 );
         group.addPermission( p1 );
         group.addPermission( p2 );
-        group.addPermission( p3 );
-        
+
         ContinuumUser continuumUser = new ContinuumUser();
         continuumUser.setUsername( "username" );
         continuumUser.setPassword( "password" );
         continuumUser.setGroup( group );
-        
+
         ShaPasswordEncoder passwordEncoder = new ShaPasswordEncoder();
         String shaPassword = passwordEncoder.encodePassword( "password", null );
-        
+
         UserDetails userDetails = userDetailsService.getUserDetails( continuumUser );
-        
+
         assertEquals( userDetails.getUsername(), continuumUser.getUsername() );
         assertEquals( userDetails.getPassword(), shaPassword );
-        assertEquals( userDetails.getAuthorities(), continuumUser.getUsername() );
+
+        GrantedAuthority[] authorities = userDetails.getAuthorities();
+        for ( int i = 0; i < authorities.length; i++ )
+        {
+            assertEquals( "ROLE_p" + i, authorities[i].getAuthority() );
+        }
     }
 
     public void testPasswordEncoding()
     {
         ContinuumUser continuumUser = new ContinuumUser();
         continuumUser.setPassword( "admin" );
-        
+
         ShaPasswordEncoder passwordEncoder = new ShaPasswordEncoder();
         String shaPassword = passwordEncoder.encodePassword( "admin", null );
-        
+
         assertEquals( continuumUser.getHashedPassword(), shaPassword );
     }
 }



Mime
View raw message