Author: julien_viet
Date: 2010-01-08 05:38:18 -0500 (Fri, 08 Jan 2010)
New Revision: 1202
Added:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestGroupNavACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestPortalNavACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestUserNavACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/AbstractTestSharedPageACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestGroupPageACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestPortalPageACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestUserPageACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestCreatePortalACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestPortalACL.java
Removed:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestSharedPageACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestCreatePortalACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupNavACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupPageACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalConfigACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalNavACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalPageACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserNavACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserPageACL.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestUserACL.java
Log:
- reorg unit test for user acl
- clarified a few points in user page access in edit mode
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -239,23 +239,6 @@
return adminMSType;
}
- protected boolean findMembershipByUserAndGroupAndType(String groupId, String
membership) throws Exception
- {
- ConversationState conv = ConversationState.getCurrent();
- Identity id = null;
- if (conv != null)
- {
- id = conv.getIdentity();
- }
-
- if (id == null)
- {
- return false;
- }
-
- return id.isMemberOf(groupId, membership);
- }
-
public boolean hasPermission(PortalConfig pconfig)
{
return hasPermission(getIdentity(), pconfig);
@@ -322,10 +305,6 @@
return false;
}
- // --------------------------------------------------------------------------//
- // Utility Methods //
- // --------------------------------------------------------------------------//
-
private boolean hasPermission(Identity identity, PortalConfig pconfig)
{
if (hasPermission(identity, pconfig.getEditPermission()))
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestSharedPageACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestSharedPageACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestSharedPageACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,217 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-import org.exoplatform.portal.config.model.Page;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public abstract class AbstractTestSharedPageACL extends AbstractTestUserACL
-{
-
- protected abstract String getOwnerType();
-
- public void testPage()
- {
- Page page = new Page();
- page.setOwnerType("group");
- page.setOwnerId("foo");
- page.setAccessPermissions(new String[0]);
-
- //
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertFalse(manager.hasPermission(page));
- assertFalse(user.hasPermission(page));
- assertFalse(guest.hasPermission(page));
-
- //
- assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- assertFalse(manager.hasEditPermission(page));
- assertFalse(user.hasEditPermission(page));
- assertFalse(guest.hasEditPermission(page));
- }
-
- public void testPageAccessibleByEveryone()
- {
- Page page = new Page();
- page.setOwnerType("group");
- page.setOwnerId("foo");
- page.setAccessPermissions(new String[]{"Everyone"});
-
- //
- assertTrue(root.hasPermission(page));
- assertTrue(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertTrue(user.hasPermission(page));
- assertTrue(guest.hasPermission(page));
-
- //
- assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- assertFalse(manager.hasEditPermission(page));
- assertFalse(user.hasEditPermission(page));
- assertFalse(guest.hasEditPermission(page));
- }
-
- public void testPageEditableByEveryone()
- {
- Page page = new Page();
- page.setOwnerType("group");
- page.setOwnerId("foo");
- page.setAccessPermissions(new String[0]);
- page.setEditPermission("Everyone");
-
- //
- assertTrue(root.hasPermission(page));
- assertTrue(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertTrue(user.hasPermission(page));
- assertTrue(guest.hasPermission(page));
-
- //
- assertTrue(root.hasEditPermission(page));
- assertTrue(administrator.hasEditPermission(page));
- assertTrue(manager.hasEditPermission(page));
- assertTrue(user.hasEditPermission(page));
- assertTrue(guest.hasEditPermission(page));
- }
-
- public void testPageAccessibleByGuests()
- {
- Page page = new Page();
- page.setOwnerType("group");
- page.setOwnerId("foo");
- page.setAccessPermissions(new String[]{"whatever:/platform/guests"});
-
- //
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertFalse(manager.hasPermission(page));
- assertFalse(user.hasPermission(page));
- assertTrue(guest.hasPermission(page));
-
- //
- assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- assertFalse(manager.hasEditPermission(page));
- assertFalse(user.hasEditPermission(page));
- assertFalse(guest.hasEditPermission(page));
- }
-
- public void testPageEditableByGuests()
- {
- Page page = new Page();
- page.setOwnerType("group");
- page.setOwnerId("foo");
- page.setAccessPermissions(new String[0]);
- page.setEditPermission("whatever:/platform/guests");
-
- //
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertFalse(manager.hasPermission(page));
- assertFalse(user.hasPermission(page));
- assertTrue(guest.hasPermission(page));
-
- //
- assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- assertFalse(manager.hasEditPermission(page));
- assertFalse(user.hasEditPermission(page));
- assertTrue(guest.hasEditPermission(page));
- }
-
- public void testPageAccessibleByEveryOneAndGuests()
- {
- Page page = new Page();
- page.setOwnerType("group");
- page.setOwnerId("foo");
- page.setAccessPermissions(new String[]{"Everyone",
"whatever:/platform/guests"});
-
- //
- assertTrue(root.hasPermission(page));
- assertTrue(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertTrue(user.hasPermission(page));
- assertTrue(guest.hasPermission(page));
-
- //
- assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- assertFalse(manager.hasEditPermission(page));
- assertFalse(user.hasEditPermission(page));
- assertFalse(guest.hasEditPermission(page));
- }
-
- public void testPageWithAccessPermission()
- {
- Page page = new Page();
- page.setOwnerType("group");
- page.setOwnerId("foo");
- page.setAccessPermissions(new String[]{"manager:/manageable"});
-
- //
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertFalse(user.hasPermission(page));
- assertFalse(guest.hasPermission(page));
-
- //
- page.setAccessPermissions(new String[]{"*:/manageable"});
-
- //
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertFalse(user.hasPermission(page));
- assertFalse(guest.hasPermission(page));
- }
-
- public void testPageWithEditPermission()
- {
- Page page = new Page();
- page.setOwnerType("group");
- page.setOwnerId("foo");
- page.setAccessPermissions(new String[0]);
- page.setEditPermission("manager:/manageable");
-
- //
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertFalse(user.hasPermission(page));
- assertFalse(guest.hasPermission(page));
-
- //
- page.setEditPermission("*:/manageable");
-
- //
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertFalse(user.hasPermission(page));
- assertFalse(guest.hasPermission(page));
- }
-}
\ No newline at end of file
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestUserACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestUserACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestUserACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -42,9 +42,9 @@
public abstract class AbstractTestUserACL extends BasicTestCase
{
- UserACL ua;
+ protected UserACL ua;
- User root, administrator, manager, user, guest;
+ protected User root, administrator, manager, user, guest;
@Override
protected void setUp() throws Exception
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestCreatePortalACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestCreatePortalACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestCreatePortalACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,36 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class TestCreatePortalACL extends AbstractTestUserACL
-{
-
- public void testPermission()
- {
- assertTrue(root.hasCreatePortalPermission());
- assertTrue(administrator.hasCreatePortalPermission());
- assertFalse(manager.hasCreatePortalPermission());
- assertFalse(user.hasCreatePortalPermission());
- }
-}
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupNavACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupNavACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupNavACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,54 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-import org.exoplatform.portal.config.model.PageNavigation;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class TestGroupNavACL extends AbstractTestUserACL
-{
-
- public void testNavEditByManager()
- {
- PageNavigation nav = new PageNavigation();
- nav.setOwnerType("group");
- nav.setOwnerId("manageable");
-
- //
- assertTrue(root.hasEditPermission(nav));
- assertFalse(administrator.hasEditPermission(nav));
- assertTrue(manager.hasEditPermission(nav));
- assertFalse(user.hasEditPermission(nav));
- assertFalse(guest.hasEditPermission(nav));
-
- //
- nav.setOwnerId("foo");
-
- //
- assertTrue(root.hasEditPermission(nav));
- assertFalse(administrator.hasEditPermission(nav));
- assertFalse(manager.hasEditPermission(nav));
- assertFalse(user.hasEditPermission(nav));
- assertFalse(guest.hasEditPermission(nav));
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupPageACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupPageACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupPageACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,32 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class TestGroupPageACL extends AbstractTestSharedPageACL
-{
- protected String getOwnerType()
- {
- return "Group";
- }
-}
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalConfigACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalConfigACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalConfigACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,113 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-import org.exoplatform.portal.config.model.PortalConfig;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class TestPortalConfigACL extends AbstractTestUserACL
-{
-
- public void testFoo()
- {
- PortalConfig portal = new PortalConfig();
- portal.setAccessPermissions(new String[0]);
-
- //
- assertTrue(root.hasEditPermission(portal));
- assertFalse(administrator.hasEditPermission(portal));
- assertFalse(manager.hasEditPermission(portal));
- assertFalse(user.hasEditPermission(portal));
- assertFalse(guest.hasEditPermission(portal));
-
- //
- assertTrue(root.hasPermission(portal));
- assertFalse(administrator.hasPermission(portal));
- assertFalse(manager.hasPermission(portal));
- assertFalse(user.hasPermission(portal));
- assertFalse(guest.hasPermission(portal));
- }
-
- public void testPortalAccessible()
- {
- PortalConfig portal = new PortalConfig();
- portal.setAccessPermissions(new String[]{"manager:/manageable"});
-
- //
- assertTrue(root.hasEditPermission(portal));
- assertFalse(administrator.hasEditPermission(portal));
- assertFalse(manager.hasEditPermission(portal));
- assertFalse(user.hasEditPermission(portal));
- assertFalse(guest.hasEditPermission(portal));
-
- //
- assertTrue(root.hasPermission(portal));
- assertFalse(administrator.hasPermission(portal));
- assertTrue(manager.hasPermission(portal));
- assertFalse(user.hasPermission(portal));
- assertFalse(guest.hasPermission(portal));
- }
-
- public void testPortalEditable()
- {
- PortalConfig portal = new PortalConfig();
- portal.setAccessPermissions(new String[0]);
- portal.setEditPermission("manager:/manageable");
-
- //
- assertTrue(root.hasEditPermission(portal));
- assertFalse(administrator.hasEditPermission(portal));
- assertTrue(manager.hasEditPermission(portal));
- assertFalse(user.hasEditPermission(portal));
- assertFalse(guest.hasEditPermission(portal));
-
- //
- assertTrue(root.hasPermission(portal));
- assertFalse(administrator.hasPermission(portal));
- assertTrue(manager.hasPermission(portal));
- assertFalse(user.hasPermission(portal));
- assertFalse(guest.hasPermission(portal));
- }
-
- public void testPortalAccessibleAndEditable()
- {
- PortalConfig portal = new PortalConfig();
- portal.setAccessPermissions(new String[]{"manager:/manageable"});
- portal.setEditPermission("manager:/manageable");
-
- //
- assertTrue(root.hasEditPermission(portal));
- assertFalse(administrator.hasEditPermission(portal));
- assertTrue(manager.hasEditPermission(portal));
- assertFalse(user.hasEditPermission(portal));
- assertFalse(guest.hasEditPermission(portal));
-
- //
- assertTrue(root.hasPermission(portal));
- assertFalse(administrator.hasPermission(portal));
- assertTrue(manager.hasPermission(portal));
- assertFalse(user.hasPermission(portal));
- assertFalse(guest.hasPermission(portal));
- }
-
-}
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalNavACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalNavACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalNavACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,44 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-import org.exoplatform.portal.config.model.PageNavigation;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class TestPortalNavACL extends AbstractTestUserACL
-{
-
- public void testNavEditByRoot()
- {
- PageNavigation nav = new PageNavigation();
- nav.setOwnerType("portal");
- nav.setOwnerId("foo");
-
- //
- assertTrue(root.hasEditPermission(nav));
- assertFalse(administrator.hasEditPermission(nav));
- assertFalse(manager.hasEditPermission(nav));
- assertFalse(user.hasEditPermission(nav));
- assertFalse(guest.hasEditPermission(nav));
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalPageACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalPageACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalPageACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,32 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class TestPortalPageACL extends AbstractTestSharedPageACL
-{
- protected String getOwnerType()
- {
- return "Portal";
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserNavACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserNavACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserNavACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,44 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-import org.exoplatform.portal.config.model.PageNavigation;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class TestUserNavACL extends AbstractTestUserACL
-{
-
- public void testNav()
- {
-
- PageNavigation nav = new PageNavigation();
- nav.setOwnerType("user");
- nav.setOwnerId("user");
-
- assertTrue(root.hasEditPermission(nav));
- assertFalse(administrator.hasEditPermission(nav));
- assertFalse(manager.hasEditPermission(nav));
- assertTrue(user.hasEditPermission(nav));
- assertFalse(guest.hasEditPermission(nav));
- }
-}
Deleted:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserPageACL.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserPageACL.java 2010-01-08
06:45:41 UTC (rev 1201)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserPageACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -1,114 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.config.security;
-
-import org.exoplatform.portal.config.model.Page;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class TestUserPageACL extends AbstractTestUserACL
-{
- public void testUserPageIsAlwaysUsableOnlyByItsOwner()
- {
- Page page = new Page();
- page.setOwnerType("user");
- page.setOwnerId("user");
- page.setAccessPermissions(new String[0]);
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertFalse(manager.hasPermission(page));
- assertTrue(user.hasPermission(page));
- assertFalse(guest.hasPermission(page));
- //assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- assertFalse(manager.hasEditPermission(page));
- assertTrue(user.hasEditPermission(page));
- assertFalse(guest.hasEditPermission(page));
-
- //
- page = new Page();
- page.setOwnerType("user");
- page.setOwnerId("user");
- page.setAccessPermissions(new String[]{"manager:/manageable"});
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertTrue(user.hasPermission(page));
- assertFalse(guest.hasPermission(page));
- //assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- assertFalse(manager.hasEditPermission(page));
- assertTrue(user.hasEditPermission(page));
- assertFalse(guest.hasEditPermission(page));
-
- //
- page = new Page();
- page.setOwnerType("user");
- page.setOwnerId("user");
- page.setAccessPermissions(new String[0]);
- page.setEditPermission("manager:/manageable");
- assertTrue(root.hasPermission(page));
- assertFalse(administrator.hasPermission(page));
- //assertTrue(manager.hasPermission(page));
- assertFalse(manager.hasPermission(page));
- assertTrue(user.hasPermission(page));
- assertFalse(guest.hasPermission(page));
- //assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- //assertTrue(manager.hasEditPermission(page));
- assertTrue(user.hasEditPermission(page));
- assertFalse(guest.hasEditPermission(page));
-
- //
- page = new Page();
- page.setOwnerType("user");
- page.setOwnerId("user");
- page.setAccessPermissions(new String[]{"Everyone"});
- assertTrue(root.hasPermission(page));
- assertTrue(administrator.hasPermission(page));
- assertTrue(manager.hasPermission(page));
- assertTrue(user.hasPermission(page));
- assertTrue(guest.hasPermission(page));
- //assertTrue(root.hasEditPermission(page));
- assertFalse(administrator.hasEditPermission(page));
- assertFalse(manager.hasEditPermission(page));
- assertTrue(user.hasEditPermission(page));
- assertFalse(guest.hasEditPermission(page));
-
- //
- page = new Page();
- page.setOwnerType("user");
- page.setOwnerId("user");
- page.setAccessPermissions(new String[0]);
- page.setEditPermission("Everyone");
- assertTrue(root.hasPermission(page));
- //assertTrue(administrator.hasPermission(page));
- //assertTrue(manager.hasPermission(page));
- assertTrue(user.hasPermission(page));
- //assertTrue(guest.hasPermission(page));
- //assertTrue(root.hasEditPermission(page));
- //assertTrue(administrator.hasEditPermission(page));
- //assertTrue(manager.hasEditPermission(page));
- assertTrue(user.hasEditPermission(page));
- //assertTrue(guest.hasEditPermission(page));
- }
-}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestGroupNavACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupNavACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestGroupNavACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestGroupNavACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,55 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.nav;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.security.AbstractTestUserACL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestGroupNavACL extends AbstractTestUserACL
+{
+
+ public void testNavEditByManager()
+ {
+ PageNavigation nav = new PageNavigation();
+ nav.setOwnerType("group");
+ nav.setOwnerId("manageable");
+
+ //
+ assertTrue(root.hasEditPermission(nav));
+ assertFalse(administrator.hasEditPermission(nav));
+ assertTrue(manager.hasEditPermission(nav));
+ assertFalse(user.hasEditPermission(nav));
+ assertFalse(guest.hasEditPermission(nav));
+
+ //
+ nav.setOwnerId("foo");
+
+ //
+ assertTrue(root.hasEditPermission(nav));
+ assertFalse(administrator.hasEditPermission(nav));
+ assertFalse(manager.hasEditPermission(nav));
+ assertFalse(user.hasEditPermission(nav));
+ assertFalse(guest.hasEditPermission(nav));
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestPortalNavACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalNavACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestPortalNavACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestPortalNavACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,45 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.nav;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.security.AbstractTestUserACL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestPortalNavACL extends AbstractTestUserACL
+{
+
+ public void testNavEditByRoot()
+ {
+ PageNavigation nav = new PageNavigation();
+ nav.setOwnerType("portal");
+ nav.setOwnerId("foo");
+
+ //
+ assertTrue(root.hasEditPermission(nav));
+ assertFalse(administrator.hasEditPermission(nav));
+ assertFalse(manager.hasEditPermission(nav));
+ assertFalse(user.hasEditPermission(nav));
+ assertFalse(guest.hasEditPermission(nav));
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestUserNavACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserNavACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestUserNavACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/nav/TestUserNavACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,45 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.nav;
+
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.security.AbstractTestUserACL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestUserNavACL extends AbstractTestUserACL
+{
+
+ public void testNav()
+ {
+
+ PageNavigation nav = new PageNavigation();
+ nav.setOwnerType("user");
+ nav.setOwnerId("user");
+
+ assertTrue(root.hasEditPermission(nav));
+ assertFalse(administrator.hasEditPermission(nav));
+ assertFalse(manager.hasEditPermission(nav));
+ assertTrue(user.hasEditPermission(nav));
+ assertFalse(guest.hasEditPermission(nav));
+ }
+}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/AbstractTestSharedPageACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/AbstractTestSharedPageACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/AbstractTestSharedPageACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/AbstractTestSharedPageACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,218 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.page;
+
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.security.AbstractTestUserACL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public abstract class AbstractTestSharedPageACL extends AbstractTestUserACL
+{
+
+ protected abstract String getOwnerType();
+
+ public void testPage()
+ {
+ Page page = new Page();
+ page.setOwnerType(getOwnerType());
+ page.setOwnerId("foo");
+ page.setAccessPermissions(new String[0]);
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertFalse(manager.hasPermission(page));
+ assertFalse(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+
+ //
+ assertTrue(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertFalse(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+ }
+
+ public void testPageAccessibleByEveryone()
+ {
+ Page page = new Page();
+ page.setOwnerType(getOwnerType());
+ page.setOwnerId("foo");
+ page.setAccessPermissions(new String[]{"Everyone"});
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertTrue(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertTrue(user.hasPermission(page));
+ assertTrue(guest.hasPermission(page));
+
+ //
+ assertTrue(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertFalse(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+ }
+
+ public void testPageEditableByEveryone()
+ {
+ Page page = new Page();
+ page.setOwnerType(getOwnerType());
+ page.setOwnerId("foo");
+ page.setAccessPermissions(new String[0]);
+ page.setEditPermission("Everyone");
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertTrue(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertTrue(user.hasPermission(page));
+ assertTrue(guest.hasPermission(page));
+
+ //
+ assertTrue(root.hasEditPermission(page));
+ assertTrue(administrator.hasEditPermission(page));
+ assertTrue(manager.hasEditPermission(page));
+ assertTrue(user.hasEditPermission(page));
+ assertTrue(guest.hasEditPermission(page));
+ }
+
+ public void testPageAccessibleByGuests()
+ {
+ Page page = new Page();
+ page.setOwnerType(getOwnerType());
+ page.setOwnerId("foo");
+ page.setAccessPermissions(new String[]{"whatever:/platform/guests"});
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertFalse(manager.hasPermission(page));
+ assertFalse(user.hasPermission(page));
+ assertTrue(guest.hasPermission(page));
+
+ //
+ assertTrue(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertFalse(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+ }
+
+ public void testPageEditableByGuests()
+ {
+ Page page = new Page();
+ page.setOwnerType(getOwnerType());
+ page.setOwnerId("foo");
+ page.setAccessPermissions(new String[0]);
+ page.setEditPermission("whatever:/platform/guests");
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertFalse(manager.hasPermission(page));
+ assertFalse(user.hasPermission(page));
+ assertTrue(guest.hasPermission(page));
+
+ //
+ assertTrue(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertFalse(user.hasEditPermission(page));
+ assertTrue(guest.hasEditPermission(page));
+ }
+
+ public void testPageAccessibleByEveryOneAndGuests()
+ {
+ Page page = new Page();
+ page.setOwnerType(getOwnerType());
+ page.setOwnerId("foo");
+ page.setAccessPermissions(new String[]{"Everyone",
"whatever:/platform/guests"});
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertTrue(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertTrue(user.hasPermission(page));
+ assertTrue(guest.hasPermission(page));
+
+ //
+ assertTrue(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertFalse(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+ }
+
+ public void testPageWithAccessPermission()
+ {
+ Page page = new Page();
+ page.setOwnerType(getOwnerType());
+ page.setOwnerId("foo");
+ page.setAccessPermissions(new String[]{"manager:/manageable"});
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertFalse(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+
+ //
+ page.setAccessPermissions(new String[]{"*:/manageable"});
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertFalse(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+ }
+
+ public void testPageWithEditPermission()
+ {
+ Page page = new Page();
+ page.setOwnerType(getOwnerType());
+ page.setOwnerId("foo");
+ page.setAccessPermissions(new String[0]);
+ page.setEditPermission("manager:/manageable");
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertFalse(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+
+ //
+ page.setEditPermission("*:/manageable");
+
+ //
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertFalse(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestGroupPageACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestGroupPageACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestGroupPageACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestGroupPageACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,32 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.page;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestGroupPageACL extends AbstractTestSharedPageACL
+{
+ protected String getOwnerType()
+ {
+ return "Group";
+ }
+}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestPortalPageACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalPageACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestPortalPageACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestPortalPageACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,32 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.page;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestPortalPageACL extends AbstractTestSharedPageACL
+{
+ protected String getOwnerType()
+ {
+ return "Portal";
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestUserPageACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestUserPageACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestUserPageACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/page/TestUserPageACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,114 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.page;
+
+import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.security.AbstractTestUserACL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestUserPageACL extends AbstractTestUserACL
+{
+ public void testUserPageIsAlwaysUsableOnlyByItsOwner()
+ {
+ Page page = new Page();
+ page.setOwnerType("user");
+ page.setOwnerId("user");
+ page.setAccessPermissions(new String[0]);
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertFalse(manager.hasPermission(page));
+ assertTrue(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+ assertFalse(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertTrue(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+
+ //
+ page = new Page();
+ page.setOwnerType("user");
+ page.setOwnerId("user");
+ page.setAccessPermissions(new String[]{"manager:/manageable"});
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertTrue(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+ assertFalse(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertTrue(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+
+ //
+ page = new Page();
+ page.setOwnerType("user");
+ page.setOwnerId("user");
+ page.setEditPermission("manager:/manageable");
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertFalse(manager.hasPermission(page));
+ assertFalse(manager.hasPermission(page));
+ assertTrue(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+ assertFalse(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertTrue(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+
+ //
+ page = new Page();
+ page.setOwnerType("user");
+ page.setOwnerId("user");
+ page.setAccessPermissions(new String[]{"Everyone"});
+ assertTrue(root.hasPermission(page));
+ assertTrue(administrator.hasPermission(page));
+ assertTrue(manager.hasPermission(page));
+ assertTrue(user.hasPermission(page));
+ assertTrue(guest.hasPermission(page));
+ assertFalse(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertTrue(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+
+ //
+ page = new Page();
+ page.setOwnerType("user");
+ page.setOwnerId("user");
+ page.setAccessPermissions(new String[0]);
+ page.setEditPermission("Everyone");
+ assertTrue(root.hasPermission(page));
+ assertFalse(administrator.hasPermission(page));
+ assertFalse(manager.hasPermission(page));
+ assertTrue(user.hasPermission(page));
+ assertFalse(guest.hasPermission(page));
+ assertFalse(root.hasEditPermission(page));
+ assertFalse(administrator.hasEditPermission(page));
+ assertFalse(manager.hasEditPermission(page));
+ assertTrue(user.hasEditPermission(page));
+ assertFalse(guest.hasEditPermission(page));
+ }
+}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestCreatePortalACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestCreatePortalACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestCreatePortalACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestCreatePortalACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,38 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.portal;
+
+import org.exoplatform.portal.config.security.AbstractTestUserACL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestCreatePortalACL extends AbstractTestUserACL
+{
+
+ public void testPermission()
+ {
+ assertTrue(root.hasCreatePortalPermission());
+ assertTrue(administrator.hasCreatePortalPermission());
+ assertFalse(manager.hasCreatePortalPermission());
+ assertFalse(user.hasCreatePortalPermission());
+ }
+}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestPortalACL.java
(from rev 1192,
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/TestPortalConfigACL.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestPortalACL.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/security/portal/TestPortalACL.java 2010-01-08
10:38:18 UTC (rev 1202)
@@ -0,0 +1,114 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.security.portal;
+
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.config.security.AbstractTestUserACL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class TestPortalACL extends AbstractTestUserACL
+{
+
+ public void testFoo()
+ {
+ PortalConfig portal = new PortalConfig();
+ portal.setAccessPermissions(new String[0]);
+
+ //
+ assertTrue(root.hasEditPermission(portal));
+ assertFalse(administrator.hasEditPermission(portal));
+ assertFalse(manager.hasEditPermission(portal));
+ assertFalse(user.hasEditPermission(portal));
+ assertFalse(guest.hasEditPermission(portal));
+
+ //
+ assertTrue(root.hasPermission(portal));
+ assertFalse(administrator.hasPermission(portal));
+ assertFalse(manager.hasPermission(portal));
+ assertFalse(user.hasPermission(portal));
+ assertFalse(guest.hasPermission(portal));
+ }
+
+ public void testPortalAccessible()
+ {
+ PortalConfig portal = new PortalConfig();
+ portal.setAccessPermissions(new String[]{"manager:/manageable"});
+
+ //
+ assertTrue(root.hasEditPermission(portal));
+ assertFalse(administrator.hasEditPermission(portal));
+ assertFalse(manager.hasEditPermission(portal));
+ assertFalse(user.hasEditPermission(portal));
+ assertFalse(guest.hasEditPermission(portal));
+
+ //
+ assertTrue(root.hasPermission(portal));
+ assertFalse(administrator.hasPermission(portal));
+ assertTrue(manager.hasPermission(portal));
+ assertFalse(user.hasPermission(portal));
+ assertFalse(guest.hasPermission(portal));
+ }
+
+ public void testPortalEditable()
+ {
+ PortalConfig portal = new PortalConfig();
+ portal.setAccessPermissions(new String[0]);
+ portal.setEditPermission("manager:/manageable");
+
+ //
+ assertTrue(root.hasEditPermission(portal));
+ assertFalse(administrator.hasEditPermission(portal));
+ assertTrue(manager.hasEditPermission(portal));
+ assertFalse(user.hasEditPermission(portal));
+ assertFalse(guest.hasEditPermission(portal));
+
+ //
+ assertTrue(root.hasPermission(portal));
+ assertFalse(administrator.hasPermission(portal));
+ assertTrue(manager.hasPermission(portal));
+ assertFalse(user.hasPermission(portal));
+ assertFalse(guest.hasPermission(portal));
+ }
+
+ public void testPortalAccessibleAndEditable()
+ {
+ PortalConfig portal = new PortalConfig();
+ portal.setAccessPermissions(new String[]{"manager:/manageable"});
+ portal.setEditPermission("manager:/manageable");
+
+ //
+ assertTrue(root.hasEditPermission(portal));
+ assertFalse(administrator.hasEditPermission(portal));
+ assertTrue(manager.hasEditPermission(portal));
+ assertFalse(user.hasEditPermission(portal));
+ assertFalse(guest.hasEditPermission(portal));
+
+ //
+ assertTrue(root.hasPermission(portal));
+ assertFalse(administrator.hasPermission(portal));
+ assertTrue(manager.hasPermission(portal));
+ assertFalse(user.hasPermission(portal));
+ assertFalse(guest.hasPermission(portal));
+ }
+
+}