From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8432 invoked by alias); 27 Jan 2006 11:58:45 -0000 Received: (qmail 8420 invoked by uid 22791); 27 Jan 2006 11:58:44 -0000 X-Spam-Check-By: sourceware.org Received: from gbenson.demon.co.uk (HELO gbenson.demon.co.uk) (80.177.220.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 27 Jan 2006 11:58:43 +0000 Received: from slippy.wire.rat ([192.168.1.1]) by gbenson.demon.co.uk with esmtp (Exim 3.36 #1) id 1F2SFV-0006aa-00 for mauve-patches@sources.redhat.com; Fri, 27 Jan 2006 11:58:41 +0000 Received: from slippy.wire.rat (localhost.localdomain [127.0.0.1]) by slippy.wire.rat (8.13.1/8.13.1) with ESMTP id k0RBwf52006351 for ; Fri, 27 Jan 2006 11:58:41 GMT Received: (from gary@localhost) by slippy.wire.rat (8.13.1/8.13.1/Submit) id k0RBweOF006350 for mauve-patches@sources.redhat.com; Fri, 27 Jan 2006 11:58:40 GMT Date: Fri, 27 Jan 2006 11:58:00 -0000 From: Gary Benson To: mauve-patches@sources.redhat.com Subject: FYI: Test security manager new feature Message-ID: <20060127115839.GD5116@redhat.com> Mail-Followup-To: mauve-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2006/txt/msg00051.txt.bz2 --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 273 Hi all, This commit adds a new way to run throwpoint checks to the test security manager. You can now make it throw an exception when the expected permission is checked, which allows you to test things you don't actually want to do, such as exiting the VM. Cheers, Gary --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-length: 2391 Index: ChangeLog =================================================================== RCS file: /cvs/mauve/mauve/ChangeLog,v retrieving revision 1.1377 diff -u -r1.1377 ChangeLog --- ChangeLog 26 Jan 2006 19:29:36 -0000 1.1377 +++ ChangeLog 27 Jan 2006 11:54:49 -0000 @@ -1,3 +1,9 @@ +2006-01-27 Gary Benson + + * gnu/testlet/TestSecurityManager2.java: Added the ability to + abort tests when the permission is checked, to allow us to test + things that we don't actually want doing. + 2006-01-27 Raif S. Naffah * gnu/testlet/javax/crypto/jce/TestOfPR25981.java: New test. Index: gnu/testlet/TestSecurityManager2.java =================================================================== RCS file: /cvs/mauve/mauve/gnu/testlet/TestSecurityManager2.java,v retrieving revision 1.4 diff -u -r1.4 TestSecurityManager2.java --- gnu/testlet/TestSecurityManager2.java 16 Jan 2006 11:17:41 -0000 1.4 +++ gnu/testlet/TestSecurityManager2.java 27 Jan 2006 11:54:49 -0000 @@ -35,6 +35,10 @@ new PropertyPermission("*", "read")}; private boolean[] checked = new boolean[0]; + private boolean throwOnSuccess = false; + + public static final String successMessage = "Test complete, aborting"; + private final TestHarness harness; public TestSecurityManager2(TestHarness harness) { @@ -56,6 +60,7 @@ public void uninstall() { + throwOnSuccess = false; mayCheck = new Permission[]{new RuntimePermission("setSecurityManager")}; System.setSecurityManager(oldManager); } @@ -75,9 +80,18 @@ } public void prepareChecks(Permission[] mustCheck, Permission[] mayCheck) { + prepareChecks(mustCheck, mayCheck, false); + } + + public void prepareChecks(Permission[] mustCheck, + Permission[] mayCheck, + boolean throwOnSuccess) { this.mayCheck = mayCheck; this.mustCheck = mustCheck; this.checked = new boolean[mustCheck.length]; + this.throwOnSuccess = throwOnSuccess; + if (throwOnSuccess && mustCheck.length != 1) + throw new IllegalArgumentException(); } public void checkAllChecked(TestHarness harness) { @@ -111,6 +125,9 @@ } } + if (matched && throwOnSuccess) + throw new SecurityException(successMessage); + expectedPerms.append(" May check:"); if (!matched) { for (int i = 0; i < mayCheck.length; i++) { --LZvS9be/3tNcYl/X--