portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r332661 [2/2] - in /portals/jetspeed-2/trunk/components: cm/src/java/org/apache/jetspeed/components/test/ page-manager/ page-manager/src/java/JETSPEED-INF/ojb/ page-manager/src/java/org/apache/jetspeed/om/folder/impl/ page-manager/src/java/...
Date Fri, 11 Nov 2005 22:40:23 GMT
Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java?rev=332661&r1=332660&r2=332661&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java
Fri Nov 11 14:40:15 2005
@@ -32,6 +32,8 @@
 import org.apache.jetspeed.page.document.DocumentNotFoundException;
 import org.apache.jetspeed.page.document.FailedToUpdateDocumentException;
 
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -47,6 +49,8 @@
     private String deepFolderPath = "/__subsite-rootx/_user/userx/_role/rolex/_group/groupx/_mediatype/xhtml/_language/en/_country/us/_custom/customx";
     private String deepPagePath = deepFolderPath + "/default-page.psml";
 
+    private static ClassPathXmlApplicationContext context;
+
     private PageManager pageManager;
     
     public static void main(String args[])
@@ -57,8 +61,21 @@
     
     protected void setUp() throws Exception
     {
-        super.setUp();        
-        pageManager = (PageManager)ctx.getBean("pageManager");
+        // reuse context between test cases below
+        // that is normally configured if null in
+        // super class setUp() implementation
+        if (context == null)
+        {
+            super.setUp();
+            context = ctx;
+        }
+        else
+        {
+            ctx = context;
+            super.setUp();
+        }
+        // lookup page manager in context
+        pageManager = (PageManager)context.getBean("pageManager");
     }
 
     protected void tearDown() throws Exception
@@ -159,10 +176,23 @@
         portlet.setLayoutRow(88);
         portlet.setLayoutColumn(99);
         root.getFragments().add(portlet);
+        portlet = pageManager.newPortletFragment();
+        portlet.setName("some-app::SomePortlet");
+        portlet.setShortTitle("Some Portlet");
+        portlet.setTitle("Some Portlet Fragment");
+        portlet.setState("Normal");
+        portlet.setLayoutRow(22);
+        portlet.setLayoutColumn(11);
+        SecurityConstraints fragmentConstraints = pageManager.newSecurityConstraints();
+        fragmentConstraints.setOwner("user");
+        portlet.setSecurityConstraints(fragmentConstraints);
+        root.getFragments().add(portlet);
 
         pageManager.updatePage(page);
 
         assertNotNull(page.getParent());
+        assertNotNull(folder.getPages());
+        assertEquals(1, folder.getPages().size());
         assertEquals(page.getParent().getId(), folder.getId());
 
         PageSecurity pageSecurity = pageManager.newPageSecurity();
@@ -197,6 +227,7 @@
         pageManager.updatePageSecurity(pageSecurity);
 
         assertNotNull(pageSecurity.getParent());
+        assertNotNull(folder.getPageSecurity());
         assertEquals(pageSecurity.getParent().getId(), folder.getId());
 
         // test duplicate creates
@@ -235,6 +266,8 @@
             folder = pageManager.newFolder(deepFolderPath.substring(0, pathIndex));
             pageManager.updateFolder(folder);
             assertNotNull(folder.getParent());
+            assertNotNull(((Folder)folder.getParent()).getFolders());
+            assertEquals(1, ((Folder)folder.getParent()).getFolders().size());
 
             if (pathIndex < deepFolderPath.length())
             {
@@ -280,6 +313,7 @@
             assertEquals(2, check.getGlobalSecurityConstraintsRefs().size());
             assertEquals("admin-all", (String)check.getGlobalSecurityConstraintsRefs().get(0));
             assertEquals("public-view", (String)check.getGlobalSecurityConstraintsRefs().get(1));
+            assertNotNull(check.getParent());
         }
         catch (DocumentNotFoundException e)
         {
@@ -299,6 +333,14 @@
             assertNotNull(check.getMetadata());
             assertEquals("[fr] Default Page", check.getTitle(Locale.FRENCH));
             assertEquals("[ja] Default Page", check.getTitle(Locale.JAPANESE));
+            assertNotNull(check.getSecurityConstraints());
+            assertEquals("user", check.getSecurityConstraints().getOwner());
+            assertNotNull(check.getSecurityConstraints().getSecurityConstraintsRefs());
+            assertEquals(1, check.getSecurityConstraints().getSecurityConstraintsRefs().size());
+            assertEquals("manager-edit", (String)check.getSecurityConstraints().getSecurityConstraintsRefs().get(0));
+            assertNotNull(check.getSecurityConstraints().getSecurityConstraints());
+            assertEquals(1, check.getSecurityConstraints().getSecurityConstraints().size());
+            assertEquals("jetspeed", ((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(0)).getUsers());
             assertNotNull(check.getRootFragment());
             assertEquals("blue-gradient", check.getRootFragment().getDecorator());
             assertEquals("jetspeed-layouts::VelocityTwoColumns", check.getRootFragment().getName());
@@ -309,7 +351,7 @@
             assertNotNull(check.getRootFragment().getProperties());
             assertEquals("custom-prop-value1", check.getRootFragment().getProperty("custom-prop1"));
             assertNotNull(check.getRootFragment().getFragments());
-            assertEquals(1, check.getRootFragment().getFragments().size());
+            assertEquals(2, check.getRootFragment().getFragments().size());
             assertEquals("security::LoginPortlet", ((Fragment)check.getRootFragment().getFragments().get(0)).getName());
             assertEquals("Portlet", ((Fragment)check.getRootFragment().getFragments().get(0)).getShortTitle());
             assertEquals("Portlet Fragment", ((Fragment)check.getRootFragment().getFragments().get(0)).getTitle());
@@ -317,13 +359,15 @@
             assertEquals(88, ((Fragment)check.getRootFragment().getFragments().get(0)).getLayoutRow());
             assertEquals(88, ((Fragment)check.getRootFragment().getFragments().get(0)).getIntProperty(Fragment.ROW_PROPERTY_NAME));
             assertEquals(99, ((Fragment)check.getRootFragment().getFragments().get(0)).getLayoutColumn());
-            assertNotNull(check.getSecurityConstraints());
-            assertNotNull(check.getSecurityConstraints().getSecurityConstraintsRefs());
-            assertEquals(1, check.getSecurityConstraints().getSecurityConstraintsRefs().size());
-            assertEquals("manager-edit", (String)check.getSecurityConstraints().getSecurityConstraintsRefs().get(0));
-            assertNotNull(check.getSecurityConstraints().getSecurityConstraints());
-            assertEquals(1, check.getSecurityConstraints().getSecurityConstraints().size());
-            assertEquals("jetspeed", ((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(0)).getUsers());
+            assertEquals("some-app::SomePortlet", ((Fragment)check.getRootFragment().getFragments().get(1)).getName());
+            assertEquals("Some Portlet", ((Fragment)check.getRootFragment().getFragments().get(1)).getShortTitle());
+            assertEquals("Some Portlet Fragment", ((Fragment)check.getRootFragment().getFragments().get(1)).getTitle());
+            assertEquals("Normal", ((Fragment)check.getRootFragment().getFragments().get(1)).getState());
+            assertEquals(22, ((Fragment)check.getRootFragment().getFragments().get(1)).getLayoutRow());
+            assertEquals(11, ((Fragment)check.getRootFragment().getFragments().get(1)).getLayoutColumn());
+            assertNotNull(((Fragment)check.getRootFragment().getFragments().get(1)).getSecurityConstraints());
+            assertEquals("user", ((Fragment)check.getRootFragment().getFragments().get(1)).getSecurityConstraints().getOwner());
+            assertNotNull(check.getParent());
         }
         catch (PageNotFoundException e)
         {
@@ -340,6 +384,7 @@
             assertNotNull(check.getMetadata());
             assertEquals("[fr] Root Folder", check.getTitle(Locale.FRENCH));
             assertNotNull(check.getSecurityConstraints());
+            assertEquals("admin", check.getSecurityConstraints().getOwner());
             assertNotNull(check.getSecurityConstraints().getSecurityConstraintsRefs());
             assertEquals(2, check.getSecurityConstraints().getSecurityConstraintsRefs().size());
             assertEquals("public-edit", (String)check.getSecurityConstraints().getSecurityConstraintsRefs().get(1));
@@ -347,6 +392,12 @@
             assertEquals(2, check.getSecurityConstraints().getSecurityConstraints().size());
             assertEquals("user,admin", ((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(0)).getUsers());
             assertEquals("edit", ((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(1)).getPermissions());
+            assertNull(check.getParent());
+            assertNotNull(check.getPageSecurity());
+            assertNotNull(check.getPages());
+            assertEquals(1, check.getPages().size());
+            assertNotNull(check.getFolders());
+            assertEquals(1, check.getFolders().size());
         }
         catch (FolderNotFoundException e)
         {
@@ -357,6 +408,7 @@
         {
             Page check = pageManager.getPage(deepPagePath);
             assertEquals(deepPagePath, check.getPath());
+            assertNotNull(check.getParent());
         }
         catch (PageNotFoundException e)
         {
@@ -366,6 +418,7 @@
         {
             Folder check = pageManager.getFolder(deepFolderPath);
             assertEquals(deepFolderPath, check.getPath());
+            assertNotNull(check.getParent());
         }
         catch (FolderNotFoundException e)
         {

Added: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java?rev=332661&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
(added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
Fri Nov 11 14:40:15 2005
@@ -0,0 +1,455 @@
+/*
+ * Copyright 2000-2004 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.
+ */
+package org.apache.jetspeed.page;
+
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+                                                                                        
            
+import javax.security.auth.Subject;
+
+import org.apache.jetspeed.components.test.AbstractSpringTestCase;
+import org.apache.jetspeed.om.common.SecurityConstraint;
+import org.apache.jetspeed.om.common.SecurityConstraints;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.FolderNotFoundException;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.PageSecurity;
+import org.apache.jetspeed.om.page.SecurityConstraintsDef;
+import org.apache.jetspeed.security.UserPrincipal;
+import org.apache.jetspeed.security.impl.PrincipalsSet;
+import org.apache.jetspeed.security.impl.RolePrincipalImpl;
+import org.apache.jetspeed.security.impl.UserPrincipalImpl;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * TestPageXmlPersistence
+ * 
+ * @author <a href="taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ *          
+ */
+public class TestSecureDatabasePageManager extends AbstractSpringTestCase
+{
+    private PageManager pageManager;
+    
+    public static void main(String args[])
+    {
+        junit.awtui.TestRunner.main(new String[]
+        { TestDatabasePageManager.class.getName() });
+    }
+    
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        pageManager = (PageManager)ctx.getBean("securePageManager");
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestSecureDatabasePageManager.class);
+    }
+    
+    protected String[] getConfigurations()
+    {
+        return new String[]
+        { "secure-database-page-manager.xml", "transaction.xml" };
+    }
+
+    protected String[] getBootConfigurations()
+    {
+        return new String[]
+        { "test-repository-datasource-spring.xml" };
+    }
+
+    public void testSecurePageManager() throws Exception
+    {
+        // reset page manager cache
+        pageManager.reset();
+
+        // setup test subjects
+        Principal userPrincipal = new UserPrincipalImpl("admin");
+        Principal rolePrincipal = new RolePrincipalImpl("admin");
+        Set principals = new PrincipalsSet();
+        principals.add(userPrincipal);
+        principals.add(rolePrincipal);
+        Subject adminSubject = new Subject(true, principals, new HashSet(), new HashSet());
+
+        userPrincipal = new UserPrincipalImpl("user");
+        principals = new PrincipalsSet();
+        principals.add(userPrincipal);
+        Subject userSubject = new Subject(true, principals, new HashSet(), new HashSet());
+
+        userPrincipal = new UserPrincipalImpl("manager");
+        rolePrincipal = new RolePrincipalImpl("manager");
+        principals = new PrincipalsSet();
+        principals.add(userPrincipal);
+        principals.add(rolePrincipal);
+        Subject managerSubject = new Subject(true, principals, new HashSet(), new HashSet());
+
+        userPrincipal = new UserPrincipalImpl("guest");
+        principals = new PrincipalsSet();
+        principals.add(userPrincipal);
+        Subject guestSubject = new Subject(true, principals, new HashSet(), new HashSet());
+
+        // setup test as admin user
+        Exception setup = (Exception)Subject.doAs(adminSubject, new PrivilegedAction()
+            {
+                public Object run()
+                {
+                    try
+                    {
+                        // create test documents and folders
+                        Folder folder = pageManager.newFolder("/");
+                        SecurityConstraints constraints = pageManager.newSecurityConstraints();
+                        constraints.setOwner("admin");
+                        List constraintsRefs = new ArrayList(1);
+                        constraintsRefs.add("public-view");
+                        constraints.setSecurityConstraintsRefs(constraintsRefs);
+                        folder.setSecurityConstraints(constraints);
+                        pageManager.updateFolder(folder);
+                        
+                        PageSecurity pageSecurity = pageManager.newPageSecurity();
+                        List constraintsDefs = new ArrayList(2);
+                        SecurityConstraintsDef constraintsDef = pageManager.newSecurityConstraintsDef();
+                        constraintsDef.setName("public-view");
+                        List defConstraints = new ArrayList(1);
+                        SecurityConstraint defConstraint = pageManager.newSecurityConstraint();
+                        defConstraint.setUsers("*");
+                        defConstraint.setPermissions("view");
+                        defConstraints.add(defConstraint);
+                        constraintsDef.setSecurityConstraints(defConstraints);
+                        constraintsDefs.add(constraintsDef);
+                        constraintsDef = pageManager.newSecurityConstraintsDef();
+                        constraintsDef.setName("admin-all");
+                        defConstraints = new ArrayList(1);
+                        defConstraint = pageManager.newSecurityConstraint();
+                        defConstraint.setRoles("admin");
+                        defConstraint.setPermissions("view,edit");
+                        defConstraints.add(defConstraint);
+                        constraintsDef.setSecurityConstraints(defConstraints);
+                        constraintsDefs.add(constraintsDef);
+                        pageSecurity.setSecurityConstraintsDefs(constraintsDefs);
+                        List globalConstraintsRefs = new ArrayList(1);
+                        globalConstraintsRefs.add("admin-all");
+                        pageSecurity.setGlobalSecurityConstraintsRefs(globalConstraintsRefs);
+                        pageManager.updatePageSecurity(pageSecurity);
+                        
+                        Page page = pageManager.newPage("/default-page.psml");
+                        constraints = pageManager.newSecurityConstraints();
+                        constraints.setOwner("admin");
+                        List inlineConstraints = new ArrayList(1);
+                        SecurityConstraint constraint = pageManager.newSecurityConstraint();
+                        constraint.setRoles("manager");
+                        constraint.setPermissions("edit");
+                        inlineConstraints.add(constraint);
+                        constraints.setSecurityConstraints(inlineConstraints);
+                        constraintsRefs = new ArrayList(1);
+                        constraintsRefs.add("public-view");
+                        constraints.setSecurityConstraintsRefs(constraintsRefs);
+                        page.setSecurityConstraints(constraints);                       

+                        Fragment root = page.getRootFragment();
+                        root.setName("jetspeed-layouts::VelocityTwoColumns");
+                        Fragment portlet = pageManager.newPortletFragment();
+                        portlet.setName("security::LoginPortlet");
+                        root.getFragments().add(portlet);
+                        portlet = pageManager.newPortletFragment();
+                        portlet.setName("some-app::SomePortlet");
+                        SecurityConstraints fragmentConstraints = pageManager.newSecurityConstraints();
+                        fragmentConstraints.setOwner("user");
+                        portlet.setSecurityConstraints(fragmentConstraints);
+                        root.getFragments().add(portlet);
+                        pageManager.updatePage(page);
+
+                        page = pageManager.newPage("/user-page.psml");
+                        constraints = pageManager.newSecurityConstraints();
+                        inlineConstraints = new ArrayList(1);
+                        constraint = pageManager.newSecurityConstraint();
+                        constraint.setUsers("user");
+                        constraint.setPermissions("view,edit");
+                        inlineConstraints.add(constraint);
+                        constraints.setSecurityConstraints(inlineConstraints);
+                        page.setSecurityConstraints(constraints);
+                        pageManager.updatePage(page);
+                        
+                        return null;
+                    }
+                    catch (Exception e)
+                    {
+                        return e;
+                    }
+                }
+            });
+        if (setup != null)
+        {
+            throw setup;
+        }
+
+        // access test as admin user
+        Exception adminAccess = (Exception)Subject.doAs(adminSubject, new PrivilegedAction()
+            {
+                public Object run()
+                {
+                    try
+                    {
+                        // test view access
+                        Folder folder = pageManager.getFolder("/");
+                        assertNotNull(folder.getPageSecurity());
+                        assertNotNull(folder.getPages());
+                        assertEquals(2, folder.getPages().size());
+                        PageSecurity pageSecurity = pageManager.getPageSecurity();
+                        Page page0 = pageManager.getPage("/default-page.psml");
+                        assertNotNull(page0.getRootFragment());
+                        assertNotNull(page0.getRootFragment().getFragments());
+                        assertEquals(2, page0.getRootFragment().getFragments().size());
+                        Page page1 = pageManager.getPage("/user-page.psml");
+                        // test edit access
+                        pageManager.updateFolder(folder);
+                        pageManager.updatePageSecurity(pageSecurity);
+                        pageManager.updatePage(page0);
+                        pageManager.updatePage(page1);
+                        return null;
+                    }
+                    catch (Exception e)
+                    {
+                        return e;
+                    }
+                }
+            });
+        if (adminAccess != null)
+        {
+            throw adminAccess;
+        }
+
+        // access test as user user
+        Exception userAccess = (Exception)Subject.doAs(userSubject, new PrivilegedAction()
+            {
+                public Object run()
+                {
+                    try
+                    {
+                        // test view access
+                        Folder folder = pageManager.getFolder("/");
+                        assertNotNull(folder.getPageSecurity());
+                        assertNotNull(folder.getPages());
+                        assertEquals(2, folder.getPages().size());
+                        PageSecurity pageSecurity = pageManager.getPageSecurity();
+                        Page page0 = pageManager.getPage("/default-page.psml");
+                        assertNotNull(page0.getRootFragment());
+                        assertNotNull(page0.getRootFragment().getFragments());
+                        assertEquals(2, page0.getRootFragment().getFragments().size());
+                        Page page1 = pageManager.getPage("/user-page.psml");
+                        // test edit access
+                        try
+                        {
+                            pageManager.updateFolder(folder);
+                            assertTrue("Folder / not editable for user", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        try
+                        {
+                            pageManager.updatePageSecurity(pageSecurity);
+                            assertTrue("PageSecurity not editable for user", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        try
+                        {
+                            pageManager.updatePage(page0);
+                            assertTrue("Page /default-page.psml not editable for user", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        pageManager.updatePage(page1);
+                        return null;
+                    }
+                    catch (Exception e)
+                    {
+                        return e;
+                    }
+                }
+            });
+        if (userAccess != null)
+        {
+            throw userAccess;
+        }
+
+        // access test as manager user
+        Exception managerAccess = (Exception)Subject.doAs(managerSubject, new PrivilegedAction()
+            {
+                public Object run()
+                {
+                    try
+                    {
+                        // test view access
+                        Folder folder = pageManager.getFolder("/");
+                        assertNotNull(folder.getPageSecurity());
+                        assertNotNull(folder.getPages());
+                        assertEquals(1, folder.getPages().size());
+                        PageSecurity pageSecurity = pageManager.getPageSecurity();
+                        Page page0 = pageManager.getPage("/default-page.psml");
+                        assertNotNull(page0.getRootFragment());
+                        assertNotNull(page0.getRootFragment().getFragments());
+                        // Fragment access bug: assertEquals(1, page0.getRootFragment().getFragments().size());
+                        assertEquals(2, page0.getRootFragment().getFragments().size());
+                        try
+                        {
+                            Page page1 = pageManager.getPage("/user-page.psml");
+                            assertTrue("Page /user-page.psml not viewable for manager", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }                        
+                        // test edit access
+                        try
+                        {
+                            pageManager.updateFolder(folder);
+                            assertTrue("Folder / not editable for manager", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        try
+                        {
+                            pageManager.updatePageSecurity(pageSecurity);
+                            assertTrue("PageSecurity not editable for manager", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        pageManager.updatePage(page0);
+                        return null;
+                    }
+                    catch (Exception e)
+                    {
+                        return e;
+                    }
+                }
+            });
+        if (managerAccess != null)
+        {
+            throw managerAccess;
+        }
+
+        // access test as guest user
+        Exception guestAccess = (Exception)Subject.doAs(guestSubject, new PrivilegedAction()
+            {
+                public Object run()
+                {
+                    try
+                    {
+                        // test view access
+                        Folder folder = pageManager.getFolder("/");
+                        assertNotNull(folder.getPageSecurity());
+                        assertNotNull(folder.getPages());
+                        assertEquals(1, folder.getPages().size());
+                        PageSecurity pageSecurity = pageManager.getPageSecurity();
+                        Page page0 = pageManager.getPage("/default-page.psml");
+                        assertNotNull(page0.getRootFragment());
+                        assertNotNull(page0.getRootFragment().getFragments());
+                        // Fragment access bug: assertEquals(1, page0.getRootFragment().getFragments().size());
+                        assertEquals(2, page0.getRootFragment().getFragments().size());
+                        try
+                        {
+                            Page page1 = pageManager.getPage("/user-page.psml");
+                            assertTrue("Page /user-page.psml not viewable for guest", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }                        
+                        // test edit access
+                        try
+                        {
+                            pageManager.updateFolder(folder);
+                            assertTrue("Folder / not editable for guest", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        try
+                        {
+                            pageManager.updatePageSecurity(pageSecurity);
+                            assertTrue("PageSecurity not editable for guest", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        try
+                        {
+                            pageManager.updatePage(page0);
+                            assertTrue("Page /default-page.psml not editable for guest",
false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        return null;
+                    }
+                    catch (Exception e)
+                    {
+                        return e;
+                    }
+                }
+            });
+        if (guestAccess != null)
+        {
+            throw guestAccess;
+        }
+
+        // cleanup test as admin user
+        Exception cleanup = (Exception)Subject.doAs(adminSubject, new PrivilegedAction()
+            {
+                public Object run()
+                {
+                    try
+                    {
+                        // cleanup by removing root folder
+                        try
+                        {
+                            Folder remove = pageManager.getFolder("/");
+                            assertEquals("/", remove.getPath());
+                            pageManager.removeFolder(remove);
+                        }
+                        catch (FolderNotFoundException e)
+                        {
+                            assertTrue("Folder / NOT FOUND", false);
+                        }
+
+                        return null;
+                    }
+                    catch (Exception e)
+                    {
+                        return e;
+                    }
+                }
+            });
+        if (cleanup != null)
+        {
+            throw cleanup;
+        }
+    }
+}

Propchange: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/page-manager/src/test/secure-database-page-manager.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/secure-database-page-manager.xml?rev=332661&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/secure-database-page-manager.xml
(added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/secure-database-page-manager.xml
Fri Nov 11 14:40:15 2005
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<!--
+Copyright 2004 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.
+-->
+<beans>
+
+    <!-- Page Manager -->
+    <bean id="org.apache.jetspeed.page.PageManagerImpl" 
+          name="securePageManagerImpl"
+          init-method="init"
+          class="org.apache.jetspeed.page.impl.DatabasePageManager">
+        <!-- OJB configuration file resource path -->
+        <constructor-arg index="0"><value>JETSPEED-INF/ojb/page-manager-repository.xml</value></constructor-arg>
      
+        <!-- folder/page/link cache size -->
+        <constructor-arg index="1"><value>128</value></constructor-arg>
+        <!-- permissions security enabled flag -->
+        <constructor-arg index="2"><value>false</value></constructor-arg>
+        <!-- constraints security enabled flag -->
+        <constructor-arg index="3"><value>true</value></constructor-arg>
+    </bean>
+
+    <!-- Transaction Proxying -->
+    <bean id="org.apache.jetspeed.page.PageManager" name="securePageManager" parent="baseTransactionProxy">
+        <property name="proxyInterfaces">
+            <value>org.apache.jetspeed.page.PageManager</value>
+        </property>
+        <property name="target">
+            <ref bean="securePageManagerImpl" />
+        </property>
+        <property name="transactionAttributes">
+            <props>
+                <prop key="*">PROPAGATION_SUPPORTS</prop>
+                <prop key="get*">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+                <prop key="update*">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+                <prop key="remove*">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+            </props>
+        </property>
+    </bean>
+
+
+</beans>

Propchange: portals/jetspeed-2/trunk/components/page-manager/src/test/secure-database-page-manager.xml
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message