Return-Path: Delivered-To: apmail-jakarta-jetspeed-dev-archive@www.apache.org Received: (qmail 3359 invoked from network); 3 May 2004 22:23:51 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 3 May 2004 22:23:51 -0000 Received: (qmail 53862 invoked by uid 500); 3 May 2004 22:23:34 -0000 Delivered-To: apmail-jakarta-jetspeed-dev-archive@jakarta.apache.org Received: (qmail 53851 invoked by uid 500); 3 May 2004 22:23:34 -0000 Mailing-List: contact jetspeed-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jetspeed Developers List" Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@jakarta.apache.org Received: (qmail 53838 invoked by uid 500); 3 May 2004 22:23:34 -0000 Received: (qmail 53835 invoked from network); 3 May 2004 22:23:34 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 3 May 2004 22:23:34 -0000 Received: (qmail 3318 invoked by uid 1265); 3 May 2004 22:23:47 -0000 Date: 3 May 2004 22:23:47 -0000 Message-ID: <20040503222347.3317.qmail@minotaur.apache.org> From: taylor@apache.org To: jakarta-jetspeed-cvs@apache.org Subject: cvs commit: jakarta-jetspeed/src/test/org/apache/jetspeed/services/security/registry TestSecurityCaching.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N taylor 2004/05/03 15:23:47 Added: src/test/org/apache/jetspeed/services/security/registry TestSecurityCaching.java Log: New unit test for testing AccessController Security Cache Used in finding bugs for http://nagoya.apache.org/jira/browse/JS1-466 PR: Obtained from: Submitted by: Reviewed by: CVS: ---------------------------------------------------------------------- CVS: PR: CVS: If this change addresses a PR in the problem report tracking CVS: database, then enter the PR number(s) here. CVS: Obtained from: CVS: If this change has been taken from another system, such as NCSA, CVS: then name the system in this line, otherwise delete it. CVS: Submitted by: CVS: If this code has been contributed to Apache by someone else; i.e., CVS: they sent us a patch or a new module, then include their name/email CVS: address here. If this is your work then delete this line. CVS: Reviewed by: CVS: If we are doing pre-commit code reviews and someone else has CVS: reviewed your changes, include their name(s) here. CVS: If you have not had it reviewed then delete this line. Revision Changes Path 1.1 jakarta-jetspeed/src/test/org/apache/jetspeed/services/security/registry/TestSecurityCaching.java Index: TestSecurityCaching.java =================================================================== /* * Copyright 2000-2001,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.services.security.registry; import java.util.Vector; import junit.framework.Test; import junit.framework.TestSuite; import junit.awtui.TestRunner; import org.apache.jetspeed.om.registry.SecurityAccess; import org.apache.jetspeed.om.registry.SecurityAllow; import org.apache.jetspeed.om.registry.SecurityEntry; import org.apache.jetspeed.om.registry.base.BaseSecurityAccess; import org.apache.jetspeed.om.registry.base.BaseSecurityAllow; import org.apache.jetspeed.om.registry.base.BaseSecurityEntry; import org.apache.jetspeed.test.JetspeedTestCase; /** * TestSecurityCaching * * @author David Sean Taylor * @version $Id: TestSecurityCaching.java,v 1.1 2004/05/03 22:23:47 taylor Exp $ */ public class TestSecurityCaching extends JetspeedTestCase { public TestSecurityCaching( String name ) { super( name ); } public static void main(String args[]) { TestRunner.main( new String[] { TestSecurityCaching.class.getName() } ); } public void setUp() { System.out.println("Setup: "); } public void tearDown() { System.out.println("Teardown"); } /** * Creates the test suite. * * @return a test suite (TestSuite) that includes all methods * starting with "test" */ public static Test suite() { // All methods starting with "test" will be executed in the test suite. return new TestSuite( TestSecurityCaching.class ); } public void testGroupCache() throws Exception { System.out.println("Testing Group Security Registry Cache..."); SecurityEntry entry = createSecurityEntry("test-group-security"); entry.grantGroupAccess("view", "users"); entry.grantGroupAccess("view", "hackers"); entry.grantGroupAccess("edit", "managers"); entry.grantGroupAccess("view", "managers"); assertTrue("group-assert: view/users", entry.allowsGroup("users", "view")); assertTrue("group-assert: view/hackers", entry.allowsGroup("hackers", "view")); assertTrue("group-assert: view/managers", entry.allowsGroup("managers", "view")); assertTrue("group-assert: edit/managers", entry.allowsGroup("managers", "edit")); assertTrue("false group-assert: edit/hackers", !entry.allowsGroup("hackers", "edit")); entry.revokeGroupAccess("view", "hackers"); assertTrue("false group-revoked-assert: view/hackers", !entry.allowsGroup("hackers", "view")); assertTrue("group-assert: view/users", entry.allowsGroup("users", "view")); assertTrue("group-specific: view/managers", entry.allowsSpecificGroup("view", "managers")); System.out.println("Security Group Registry Cache Test done."); } private SecurityEntry createSecurityEntry(String name) { BaseSecurityEntry securityEntry = new BaseSecurityEntry(); securityEntry.setName(name); return securityEntry; } public void testRoleCache() throws Exception { System.out.println("Testing Role Security Registry Cache..."); SecurityEntry entry = createSecurityEntry("test-role-security"); entry.grantRoleAccess("view", "users"); entry.grantRoleAccess("view", "hackers"); entry.grantRoleAccess("edit", "managers"); entry.grantRoleAccess("view", "managers"); assertTrue("Role-assert: view/users", entry.allowsRole("users", "view")); assertTrue("Role-assert: view/hackers", entry.allowsRole("hackers", "view")); assertTrue("Role-assert: view/managers", entry.allowsRole("managers", "view")); assertTrue("Role-assert: edit/managers", entry.allowsRole("managers", "edit")); assertTrue("false Role-assert: edit/hackers", !entry.allowsRole("hackers", "edit")); entry.revokeRoleAccess("view", "hackers"); assertTrue("false Role-revoked-assert: view/hackers", !entry.allowsRole("hackers", "view")); assertTrue("Role-assert: view/users", entry.allowsRole("users", "view")); assertTrue("Role-specific: view/managers", entry.allowsSpecificRole("view", "managers")); System.out.println("Security Role Registry Cache Test done."); } public void testUserCache() throws Exception { System.out.println("Testing User Security Registry Cache..."); SecurityEntry entry = createSecurityEntry("test-user-security"); entry.grantUserAccess("view", "joey"); entry.grantUserAccess("view", "deedee"); entry.grantUserAccess("edit", "johnny"); entry.grantUserAccess("view", "johnny"); assertTrue("User-assert: view/joey", entry.allowsUser("joey", "view")); assertTrue("User-assert: view/deedee", entry.allowsUser("deedee", "view")); assertTrue("User-assert: view/johnny", entry.allowsUser("johnny", "view")); assertTrue("User-assert: edit/johnny", entry.allowsUser("johnny", "edit")); assertTrue("false User-assert: edit/deedee", !entry.allowsUser("deedee", "edit")); entry.revokeUserAccess("view", "deedee"); assertTrue("false User-revoked-assert: view/deedee", !entry.allowsUser("deedee", "view")); assertTrue("User-assert: view/joey", entry.allowsUser("joey", "view")); assertTrue("User-specific: view/johnny", entry.allowsSpecificUser("view", "johnny")); System.out.println("Security User Registry Cache Test done."); } } --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org