continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r431765 - in /maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test: java/org/apache/maven/continuum/security/acegi/aspectj/ resources/org/apache/maven/continuum/security/acegi/aspectj/
Date Wed, 16 Aug 2006 01:53:01 GMT
Author: carlos
Date: Tue Aug 15 18:53:00 2006
New Revision: 431765

URL: http://svn.apache.org/viewvc?rev=431765&view=rev
Log:
Added ProjectSecurityPlexusTest

Added:
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractContinuumSecurityAspectTest.java
  (with props)
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractProjectSecurityTest.java
  (with props)
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/BasicAclDaoMock.java
  (with props)
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.java
  (with props)
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.xml
  (with props)
Modified:
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityTest.java

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractContinuumSecurityAspectTest.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/aspectj/AbstractContinuumSecurityAspectTest.java?rev=431765&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractContinuumSecurityAspectTest.java
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractContinuumSecurityAspectTest.java
Tue Aug 15 18:53:00 2006
@@ -0,0 +1,78 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.acegisecurity.AccessDecisionManager;
+import org.acegisecurity.AccessDeniedException;
+import org.acegisecurity.Authentication;
+import org.acegisecurity.AuthenticationException;
+import org.acegisecurity.GrantedAuthority;
+import org.acegisecurity.GrantedAuthorityImpl;
+import org.acegisecurity.context.SecurityContextHolder;
+import org.acegisecurity.providers.TestingAuthenticationToken;
+import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.model.project.Project;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Test for {@link ContinuumSecurityAspect}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public abstract class AbstractContinuumSecurityAspectTest
+    extends PlexusTestCase
+{
+    public static final String USERNAME = "marissa";
+
+    private ContinuumStub continuum;
+
+    public void setContinuum( ContinuumStub continuum )
+    {
+        this.continuum = continuum;
+    }
+
+    public ContinuumStub getContinuum()
+    {
+        return continuum;
+    }
+
+    public ContinuumSecurityAspect getAspect()
+    {
+        return ContinuumSecurityAspect.aspectOf();
+    }
+
+    /**
+     * Get an {@link Authentication} with provided role object that can
+     * be used with the chosen {@link AccessDecisionManager} 
+     * 
+     * @param role eg. <code>ADMIN</code>, <code>USER</code>, ...
+     * @return
+     */
+    protected Authentication getAuthentication( String role )
+    {
+        return new TestingAuthenticationToken( USERNAME, "koala",
+                                               new GrantedAuthority[] { new GrantedAuthorityImpl(
"MOCK_" + role ) } );
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+        SecurityContextHolder.getContext().setAuthentication( null );
+        super.tearDown();
+    }
+}

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractContinuumSecurityAspectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractContinuumSecurityAspectTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.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/aspectj/AbstractMethodSecurityTest.java?rev=431765&r1=431764&r2=431765&view=diff
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
Tue Aug 15 18:53:00 2006
@@ -29,43 +29,14 @@
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
- * Test for {@link ContinuumSecurityAspect}
+ * Test for {@link ContinuumSecurityAspect}, method level security
  * 
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id$
  */
 public abstract class AbstractMethodSecurityTest
-    extends PlexusTestCase
+    extends AbstractContinuumSecurityAspectTest
 {
-    private Continuum continuum;
-
-    public void setContinuum( Continuum continuum )
-    {
-        this.continuum = continuum;
-    }
-
-    public Continuum getContinuum()
-    {
-        return continuum;
-    }
-
-    public ContinuumSecurityAspect getAspect()
-    {
-        return ContinuumSecurityAspect.aspectOf();
-    }
-
-    /**
-     * Get an {@link Authentication} with provided role object that can
-     * be used with the chosen {@link AccessDecisionManager} 
-     * 
-     * @param role eg. <code>ADMIN</code>, <code>USER</code>, ...
-     * @return
-     */
-    protected Authentication getAuthentication( String role )
-    {
-        return new TestingAuthenticationToken( "marissa", "koala",
-                                               new GrantedAuthority[] { new GrantedAuthorityImpl(
"MOCK_" + role ) } );
-    }
 
     /**
      * Check that method call proceeds when user has the required role.
@@ -122,12 +93,5 @@
         getAspect().setSecurityInterceptor( null );
 
         getContinuum().addProject( new Project(), "" );
-    }
-
-    protected void tearDown()
-        throws Exception
-    {
-        SecurityContextHolder.getContext().setAuthentication( null );
-        super.tearDown();
     }
 }

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractProjectSecurityTest.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/aspectj/AbstractProjectSecurityTest.java?rev=431765&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractProjectSecurityTest.java
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractProjectSecurityTest.java
Tue Aug 15 18:53:00 2006
@@ -0,0 +1,71 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.acegisecurity.Authentication;
+import org.acegisecurity.GrantedAuthority;
+import org.acegisecurity.GrantedAuthorityImpl;
+import org.acegisecurity.context.SecurityContextHolder;
+import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
+import org.apache.maven.continuum.model.project.Project;
+
+/**
+ * Test for {@link ContinuumSecurityAspect}, project instance level security
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public abstract class AbstractProjectSecurityTest
+    extends AbstractContinuumSecurityAspectTest
+{
+
+    protected Authentication getAuthentication( String role )
+    {
+        return new UsernamePasswordAuthenticationToken( USERNAME, "koala",
+                                                        new GrantedAuthority[] { new GrantedAuthorityImpl(
"ROLE_"
+                                                            + role ) } );
+    }
+
+    public void testGetAllProjects()
+        throws Exception
+    {
+        Project project1 = new Project();
+        project1.setId( 1 );
+    
+        Project project2 = new Project();
+        project2.setId( 2 );
+    
+        List mockProjects = new ArrayList();
+        mockProjects.add( project1 );
+        mockProjects.add( project2 );
+    
+        getContinuum().setMockProjects( mockProjects );
+    
+        SecurityContextHolder.getContext().setAuthentication( getAuthentication( "USER" )
);
+    
+        Collection allProjects = getContinuum().getAllProjects( 1, 1000 );
+    
+        assertEquals( "Number of projects returned does not match", 1, allProjects.size()
);
+        assertEquals( "The returned project is not the right one", 1, ( (Project) allProjects.iterator().next()
)
+            .getId() );
+    }
+
+}

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractProjectSecurityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractProjectSecurityTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/BasicAclDaoMock.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/aspectj/BasicAclDaoMock.java?rev=431765&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/BasicAclDaoMock.java
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/BasicAclDaoMock.java
Tue Aug 15 18:53:00 2006
@@ -0,0 +1,62 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.acegisecurity.acl.basic.AclObjectIdentity;
+import org.acegisecurity.acl.basic.BasicAclDao;
+import org.acegisecurity.acl.basic.BasicAclEntry;
+import org.acegisecurity.acl.basic.NamedEntityObjectIdentity;
+import org.acegisecurity.acl.basic.SimpleAclEntry;
+import org.apache.maven.continuum.model.project.Project;
+
+/**
+ * {@link BasicAclDao} that will allow READ for {@link Project} with id 1.
+ * 
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class BasicAclDaoMock
+    implements BasicAclDao
+{
+    private SimpleAclEntry aclEntry1, aclEntryDefault;
+
+    public BasicAclDaoMock( )
+    {
+        aclEntryDefault = new SimpleAclEntry();
+        aclEntryDefault.addPermission( SimpleAclEntry.NOTHING );
+        aclEntryDefault.setRecipient( AbstractContinuumSecurityAspectTest.USERNAME );
+
+        aclEntry1 = new SimpleAclEntry();
+        aclEntry1.addPermission( SimpleAclEntry.READ );
+        aclEntry1.setRecipient( AbstractContinuumSecurityAspectTest.USERNAME );
+    }
+
+    public BasicAclEntry[] getAcls( AclObjectIdentity aclObjectIdentity )
+    {
+        NamedEntityObjectIdentity objectIdentity = ( (NamedEntityObjectIdentity) aclObjectIdentity
);
+        
+        if ( objectIdentity.getId().equals( "1" ) )
+        {
+            return new BasicAclEntry[] { aclEntry1 };
+        }
+        else
+        {
+            return new BasicAclEntry[] { aclEntryDefault };
+        }
+    }
+}

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/BasicAclDaoMock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/BasicAclDaoMock.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.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/aspectj/MethodSecurityPlexusTest.java?rev=431765&r1=431764&r2=431765&view=diff
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
Tue Aug 15 18:53:00 2006
@@ -30,12 +30,12 @@
         throws Exception
     {
         super.setUp();
-        setContinuum( (Continuum) lookup( Continuum.ROLE ) );
+        setContinuum( (ContinuumStub) lookup( Continuum.ROLE ) );
     }
 
     protected Authentication getAuthentication( String role )
     {
-        return new UsernamePasswordAuthenticationToken( "marissa", "koala",
+        return new UsernamePasswordAuthenticationToken( USERNAME, "koala",
                                                         new GrantedAuthority[] { new GrantedAuthorityImpl(
"ROLE_"
                                                             + role ) } );
     }

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.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/aspectj/ProjectSecurityPlexusTest.java?rev=431765&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.java
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.java
Tue Aug 15 18:53:00 2006
@@ -0,0 +1,32 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.continuum.Continuum;
+
+public class ProjectSecurityPlexusTest
+    extends AbstractProjectSecurityTest
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setContinuum( (ContinuumStub) lookup( Continuum.ROLE ) );
+    }
+
+}

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityTest.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/aspectj/ProjectSecurityTest.java?rev=431765&r1=431764&r2=431765&view=diff
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityTest.java
Tue Aug 15 18:53:00 2006
@@ -18,32 +18,21 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 
-import junit.framework.TestCase;
-
-import org.acegisecurity.GrantedAuthority;
-import org.acegisecurity.GrantedAuthorityImpl;
 import org.acegisecurity.MockAuthenticationManager;
 import org.acegisecurity.MockRunAsManager;
 import org.acegisecurity.acl.AclProvider;
 import org.acegisecurity.acl.AclProviderManager;
-import org.acegisecurity.acl.basic.AclObjectIdentity;
-import org.acegisecurity.acl.basic.BasicAclDao;
-import org.acegisecurity.acl.basic.BasicAclEntry;
 import org.acegisecurity.acl.basic.BasicAclProvider;
-import org.acegisecurity.acl.basic.NamedEntityObjectIdentity;
 import org.acegisecurity.acl.basic.SimpleAclEntry;
 import org.acegisecurity.afterinvocation.AfterInvocationProvider;
 import org.acegisecurity.afterinvocation.AfterInvocationProviderManager;
 import org.acegisecurity.afterinvocation.BasicAclEntryAfterInvocationCollectionFilteringProvider;
 import org.acegisecurity.afterinvocation.BasicAclEntryAfterInvocationProvider;
-import org.acegisecurity.context.SecurityContextHolder;
 import org.acegisecurity.intercept.method.MethodDefinitionMap;
 import org.acegisecurity.intercept.method.MethodDefinitionSourceMapping;
 import org.acegisecurity.intercept.method.aspectj.AspectJSecurityInterceptor;
-import org.acegisecurity.providers.TestingAuthenticationToken;
 import org.acegisecurity.vote.AccessDecisionVoter;
 import org.acegisecurity.vote.AffirmativeBased;
 import org.acegisecurity.vote.BasicAclEntryVoter;
@@ -59,13 +48,9 @@
  * @version $Id$
  */
 public class ProjectSecurityTest
-    extends TestCase
+    extends AbstractProjectSecurityTest
 {
 
-    private static final String USERNAME = "marissa";
-
-    private ContinuumStub continuum;
-
     protected void setUp()
         throws Exception
     {
@@ -81,7 +66,7 @@
         //        aclDao.setDataSource( dataSource );
 
         BasicAclProvider basicAclProvider = new BasicAclProvider();
-        basicAclProvider.setBasicAclDao( new MockDao() );
+        basicAclProvider.setBasicAclDao( new BasicAclDaoMock() );
 
         AclProviderManager aclManager = new AclProviderManager();
         aclManager.setProviders( Arrays.asList( new AclProvider[] { basicAclProvider } )
);
@@ -131,76 +116,10 @@
         si.setRunAsManager( new MockRunAsManager() );
         si.setAfterInvocationManager( afterInvocationProviderManager );
 
-        continuum = new ContinuumStub();
+        setContinuum( new ContinuumStub() );
         AspectJSecurityInterceptorHelper helper = new AspectJSecurityInterceptorHelper();
         helper.setAspectName( "org.apache.maven.continuum.security.acegi.aspectj.ContinuumSecurityAspect"
);
         helper.setSecurityInterceptor( si );
         helper.initialize();
-    }
-
-    public void testGetAllProjects()
-        throws Exception
-    {
-        Project project1 = new Project();
-        project1.setId( 1 );
-
-        Project project2 = new Project();
-        project2.setId( 2 );
-
-        List mockProjects = new ArrayList();
-        mockProjects.add( project1 );
-        mockProjects.add( project2 );
-
-        continuum.setMockProjects( mockProjects );
-
-        TestingAuthenticationToken authentication = new TestingAuthenticationToken(
-                                                                                    USERNAME,
-                                                                                    "koala",
-                                                                                    new GrantedAuthority[]
{ new GrantedAuthorityImpl(
-                                                                                        
                                              "ROLE_USER" ) } );
-        SecurityContextHolder.getContext().setAuthentication( authentication );
-
-        Collection allProjects = continuum.getAllProjects( 1, 1000 );
-
-        assertEquals( "Number of projects returned does not match", 1, allProjects.size()
);
-        assertEquals( "The returned project is not the right one", 1, ( (Project) allProjects.iterator().next()
)
-            .getId() );
-    }
-
-    /**
-     * {@link BasicAclDao} that will allow READ for {@link Project} with id 1.
-     * 
-     * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
-     * @version $Id$
-     */
-    private class MockDao
-        implements BasicAclDao
-    {
-        private SimpleAclEntry aclEntry1, aclEntryDefault;
-
-        public MockDao()
-        {
-            aclEntryDefault = new SimpleAclEntry();
-            aclEntryDefault.addPermission( SimpleAclEntry.NOTHING );
-            aclEntryDefault.setRecipient( USERNAME );
-
-            aclEntry1 = new SimpleAclEntry();
-            aclEntry1.addPermission( SimpleAclEntry.READ );
-            aclEntry1.setRecipient( USERNAME );
-        }
-
-        public BasicAclEntry[] getAcls( AclObjectIdentity aclObjectIdentity )
-        {
-            NamedEntityObjectIdentity objectIdentity = ( (NamedEntityObjectIdentity) aclObjectIdentity
);
-
-            if ( objectIdentity.getId().equals( "1" ) )
-            {
-                return new BasicAclEntry[] { aclEntry1 };
-            }
-            else
-            {
-                return new BasicAclEntry[] { aclEntryDefault };
-            }
-        }
     }
 }

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.xml?rev=431765&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.xml
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.xml
Tue Aug 15 18:53:00 2006
@@ -0,0 +1,246 @@
+<plexus>
+
+  <!-- load on start to inject values into the aspect -->
+  <load-on-start>
+    <component>
+      <role>org.codehaus.plexus.acegi.intercept.method.aspectj.AspectJSecurityInterceptorHelper</role>
+    </component>
+  </load-on-start>
+
+  <components>
+
+    <component>
+      <role>org.apache.maven.continuum.Continuum</role>
+      <implementation>org.apache.maven.continuum.security.acegi.aspectj.ContinuumStub</implementation>
+    </component>
+
+    <!--
+     | ACEGI Configuration
+     -->
+     
+    <!-- Authentication -->
+
+    <component>
+      <role>org.acegisecurity.providers.ProviderManager</role>
+      <implementation>org.acegisecurity.providers.ProviderManager</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.providers.dao.DaoAuthenticationProvider</role>
+          <field-name>providers</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <!-- In memory database used only for testing -->
+    <component>
+      <role>org.acegisecurity.userdetails.UserDetailsService</role>
+      <implementation>org.acegisecurity.userdetails.memory.InMemoryDaoImpl</implementation>
+      <configuration>
+        <userProperties>
+          <property>
+            <name>marissa</name>
+            <value>koala,ROLE_USER,ROLE_SUPERVISOR</value>
+          </property>
+          <property>
+            <name>dianne</name>
+            <value>emu,ROLE_USER</value>
+          </property>
+          <property>
+            <name>scott</name>
+            <value>wombat,ROLE_USER</value>
+          </property>
+        </userProperties>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.providers.dao.DaoAuthenticationProvider</role>
+      <implementation>org.acegisecurity.providers.dao.DaoAuthenticationProvider</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.userdetails.UserDetailsService</role>
+          <field-name>userDetailsService</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <!-- authorization -->
+
+    <component>
+      <role>org.codehaus.plexus.acegi.intercept.method.aspectj.AspectJSecurityInterceptorHelper</role>
+      <implementation>org.codehaus.plexus.acegi.intercept.method.aspectj.AspectJSecurityInterceptorHelper</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.intercept.method.aspectj.AspectJSecurityInterceptor</role>
+          <field-name>securityInterceptor</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <aspectName>org.apache.maven.continuum.security.acegi.aspectj.ContinuumSecurityAspect</aspectName>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.intercept.method.aspectj.AspectJSecurityInterceptor</role>
+      <implementation>org.acegisecurity.intercept.method.aspectj.AspectJSecurityInterceptor</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.providers.ProviderManager</role>
+          <field-name>authenticationManager</field-name>
+        </requirement>
+        <requirement>
+          <role>org.acegisecurity.AccessDecisionManager</role>
+          <field-name>accessDecisionManager</field-name>
+        </requirement>
+        <requirement>
+          <role>org.acegisecurity.afterinvocation.AfterInvocationProviderManager</role>
+          <field-name>afterInvocationManager</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <objectDefinitionSource implementation="org.acegisecurity.intercept.method.MethodDefinitionMap">
+          <mappings>
+            <methodDefinitionSourceMapping>
+              <methodName>org.apache.maven.continuum.Continuum.addProject</methodName>
+              <configAttributes>
+                <configAttribute>ROLE_ADMIN</configAttribute>
+              </configAttributes>
+            </methodDefinitionSourceMapping>
+            <methodDefinitionSourceMapping>
+              <methodName>org.apache.maven.continuum.Continuum.getAllProjects</methodName>
+              <configAttributes>
+                <configAttribute>ROLE_USER</configAttribute>
+                <configAttribute>AFTER_ACL_COLLECTION_READ</configAttribute>
+              </configAttributes>
+            </methodDefinitionSourceMapping>
+          </mappings>
+        </objectDefinitionSource>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.acl.basic.BasicAclDao</role>
+      <implementation>org.apache.maven.continuum.security.acegi.aspectj.BasicAclDaoMock</implementation>
+      <requirements>
+<!--
+        <requirement>
+          <role></role>
+          <field-name>dataSource</field-name>
+        </requirement>
+-->
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.acl.AclProvider</role>
+      <implementation>org.acegisecurity.acl.basic.BasicAclProvider</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.acl.basic.BasicAclDao</role>
+          <field-name>basicAclDao</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.acl.AclManager</role>
+      <implementation>org.acegisecurity.acl.AclProviderManager</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.acl.AclProvider</role>
+          <field-name>providers</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.vote.AccessDecisionVoter</role>
+      <role-hint>roleVoter</role-hint>
+      <implementation>org.acegisecurity.vote.RoleVoter</implementation>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.vote.AccessDecisionVoter</role>
+      <role-hint>aclProjectRead</role-hint>
+      <implementation>org.acegisecurity.vote.BasicAclEntryVoter</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.acl.AclManager</role>
+          <field-name>aclManager</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <processConfigAttribute>ACL_PROJECT_READ</processConfigAttribute>
+        <processDomainObjectClass>org.apache.maven.continuum.model.project.Project</processDomainObjectClass>
+        <requirePermissionFromString>
+          <permission>ADMINISTRATION</permission>
+          <permission>READ</permission>
+        </requirePermissionFromString>
+      </configuration>
+    </component>
+
+    <!-- An access decision manager used by the business objects -->
+    <component>
+      <role>org.acegisecurity.AccessDecisionManager</role>
+      <implementation>org.acegisecurity.vote.AffirmativeBased</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.vote.AccessDecisionVoter</role>
+          <field-name>decisionVoters</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <allowIfAllAbstainDecisions>false</allowIfAllAbstainDecisions>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.afterinvocation.AfterInvocationProvider</role>
+      <role-hint>afterAclCollectionRead</role-hint>
+      <implementation>org.acegisecurity.afterinvocation.BasicAclEntryAfterInvocationCollectionFilteringProvider</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.acl.AclManager</role>
+          <field-name>aclManager</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <requirePermissionFromString>
+          <permission>ADMINISTRATION</permission>
+          <permission>READ</permission>
+        </requirePermissionFromString>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.afterinvocation.AfterInvocationProvider</role>
+      <role-hint>afterAclRead</role-hint>
+      <implementation>org.acegisecurity.afterinvocation.BasicAclEntryAfterInvocationCollectionFilteringProvider</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.acl.AclManager</role>
+          <field-name>aclManager</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <requirePermissionFromString>
+          <permission>ADMINISTRATION</permission>
+          <permission>READ</permission>
+        </requirePermissionFromString>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.afterinvocation.AfterInvocationProviderManager</role>
+      <implementation>org.acegisecurity.afterinvocation.AfterInvocationProviderManager</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.afterinvocation.AfterInvocationProvider</role>
+          <field-name>providers</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+  </components>
+
+</plexus>

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/ProjectSecurityPlexusTest.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message