Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 91982 invoked from network); 7 May 2009 08:31:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 May 2009 08:31:47 -0000 Received: (qmail 68971 invoked by uid 500); 7 May 2009 08:31:46 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 68934 invoked by uid 500); 7 May 2009 08:31:46 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 68925 invoked by uid 99); 7 May 2009 08:31:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2009 08:31:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2009 08:31:44 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4756623889D7; Thu, 7 May 2009 08:31:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r772547 - /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java Date: Thu, 07 May 2009 08:31:24 -0000 To: commits@jackrabbit.apache.org From: angela@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090507083124.4756623889D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: angela Date: Thu May 7 08:31:23 2009 New Revision: 772547 URL: http://svn.apache.org/viewvc?rev=772547&view=rev Log: JCR-1588: JSR 283: Access Control - test case for aggregate privileges covering Privilege. getAggregatePrivileges() and .getDeclaredAggregatePrivileges() Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java?rev=772547&r1=772546&r2=772547&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java Thu May 7 08:31:23 2009 @@ -104,8 +104,8 @@ public void testAllPrivilegeContainsAll() throws RepositoryException, NotExecutableException { Privilege[] supported = acMgr.getSupportedPrivileges(testRootNode.getPath()); - Set allSet = new HashSet(); Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL); + Set allSet = new HashSet(); allSet.addAll(Arrays.asList(all.getAggregatePrivileges())); String msg = "The all privilege must also contain "; @@ -120,6 +120,12 @@ } } + /** + * Test the jcr:all privilege. + * + * @throws RepositoryException + * @throws NotExecutableException + */ public void testAllPrivilege() throws RepositoryException, NotExecutableException { Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL); assertFalse("All privilege must be not be abstract.", all.isAbstract()); @@ -129,6 +135,7 @@ } /** + * Test the jcr:write privilege. * * @throws RepositoryException If an error occurs. * @throws NotExecutableException If the test cannot be executed. @@ -141,6 +148,35 @@ } /** + * Test some simple characteristics of the known aggregate privileges (jcr:write and jcr:all). + * + * @throws RepositoryException + */ + public void testAggregregatePrivileges() throws RepositoryException { + List l = new ArrayList(); + l.add(getJCRName(Privilege.JCR_WRITE, superuser)); + l.add(getJCRName(Privilege.JCR_ALL, superuser)); + + for (Iterator it = l.iterator(); it.hasNext();) { + String privName = it.next().toString(); + Privilege p = acMgr.privilegeFromName(privName); + + assertTrue("write and all must always be aggregate privileges.", p.isAggregate()); + Privilege[] aggregatedPrvs = p.getAggregatePrivileges(); + Privilege[] declaredPrvs = p.getDeclaredAggregatePrivileges(); + + assertNotNull("An aggregate privilege must return the aggregated privileges", aggregatedPrvs); + assertTrue("An aggregate privilege must return the aggregated privileges", aggregatedPrvs.length > 0); + + assertNotNull("An aggregate privilege must return the declared aggregated privileges", declaredPrvs); + assertTrue("An aggregate privilege must return the declared aggregated privileges", declaredPrvs.length > 0); + + assertTrue("The may be at least the same amount of declared aggregated privileges.", aggregatedPrvs.length >= declaredPrvs.length); + } + + } + + /** * Tests if the privilege name is treated as JCR Name and consequently * reflects changes made to the namespace prefix. *