* FYI: Improved SocketPermission implies tests
@ 2006-08-25 15:24 Gary Benson
0 siblings, 0 replies; only message in thread
From: Gary Benson @ 2006-08-25 15:24 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 256 bytes --]
Hi again,
I was poking around in the java.net.SocketPermission.implies() test
and I realised that while it tested ports and actions extensively
there was little checking of hosts. No longer!
Cheers,
Gary
PS we fail all but the most trivial of these :(
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 5929 bytes --]
Index: ChangeLog
===================================================================
RCS file: /cvs/mauve/mauve/ChangeLog,v
retrieving revision 1.1889
diff -u -r1.1889 ChangeLog
--- ChangeLog 25 Aug 2006 13:54:55 -0000 1.1889
+++ ChangeLog 25 Aug 2006 15:20:50 -0000
@@ -1,3 +1,8 @@
+2006-08-25 Gary Benson <gbenson@redhat.com>
+
+ gnu/testlet/java/net/SocketPermission/implies.java:
+ Add many more host checks, and catch exceptions within checks.
+
2006-08-25 Gary Benson <gbenson@redhat.com>
* gnu/testlet/java/net/SocketPermission/argument.java: Also test
Index: gnu/testlet/java/net/SocketPermission/implies.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/SocketPermission/implies.java,v
retrieving revision 1.3
diff -u -r1.3 implies.java
--- gnu/testlet/java/net/SocketPermission/implies.java 19 Jan 2006 13:59:49 -0000 1.3
+++ gnu/testlet/java/net/SocketPermission/implies.java 25 Aug 2006 15:20:50 -0000
@@ -20,16 +20,87 @@
package gnu.testlet.java.net.SocketPermission;
+import java.net.InetAddress;
import java.net.SocketPermission;
+import java.net.UnknownHostException;
import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
public class implies implements Testlet
{
+ static String redhat_com_addr = null;
+ static {
+ try {
+ redhat_com_addr =
+ InetAddress.getByName("www.redhat.com").getHostAddress();
+ }
+ catch (UnknownHostException e) {
+ }
+ }
+
private Test[] hosts = new Test[] {
new Test("", "", true),
- new Test("localhost", "localhost", true), // XXX need more!
+ new Test("localhost", "localhost", true),
+ new Test("127.0.0.1", "localhost", true),
+ new Test("localhost", "127.0.0.1", true),
+ new Test("www.redhat.com", "www.redhat.com", true),
+ new Test("*.redhat.com", "www.redhat.com", true),
+ new Test("www.redhat.com", "*.redhat.com", false),
+ new Test(redhat_com_addr, redhat_com_addr, true),
+ new Test("www.redhat.com", redhat_com_addr, true),
+ new Test(redhat_com_addr, "www.redhat.com", true),
+ new Test("*.redhat.com", redhat_com_addr, true),
+ new Test(redhat_com_addr, "*.redhat.com", false),
+ new Test("209.132.177.50", "209.132.177.51", false),
+ new Test("209.132.177.50", "209.132.178.50", false),
+ new Test("209.132.177.50", "209.131.177.50", false),
+ new Test("209.132.177.50", "208.132.177.50", false),
+ // full uncompressed IPv6 addresses
+ new Test("[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",
+ "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", true),
+ new Test("[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",
+ "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210", true),
+ new Test("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210",
+ "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", true),
+ new Test("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210",
+ "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210", true),
+ new Test("[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",
+ "[fedc:ba98:7654:3210:fedc:ba98:7654:3210]", true),
+ new Test("[FEDC:Bb98:7654:3210:FEDC:BA98:7654:3210]",
+ "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", false),
+ // compressed IPv6 addresses
+ new Test("[1080:0:0:0:8:800:200C:417A]",
+ "[1080:0000:0:0:8:800:200C:417A]", true),
+ new Test("[1080::8:800:200C:417A]", "[1080::8:800:200C:417A]", true),
+ new Test("[1080::8:800:200C:417A]", "[1080::8:800:200C:417a]", true),
+ new Test("[1080::8:800:200C:417A]", "[1080:0:0:0:8:800:200C:417A]", true),
+ new Test("[1080:0:0:0:8:800:200C:417A]", "[1080::8:800:200C:417A]", true),
+ new Test("[1080::8:800:200C:417B]", "[1080:0:0:0:8:800:200C:417A]", false),
+ new Test("[1080:0:0:0:8:800:200C:417A]", "[1080::8:800:200C:417B]", false),
+ new Test("[FF01::101]", "[FF01:0:0:0:0:0:0:101]", true),
+ new Test("[FF01:0:0:0:0:0:0:101]", "[FF01::101]", true),
+ new Test("[::1]", "[0:0:0:0:0:0:0:1]", true),
+ new Test("[0:0:0:0:0:0:0:1]", "[::1]", true),
+ new Test("[::]", "[0:0:0:0:0:0:0:0]", true),
+ new Test("[0:0:0:0:0:0:0:0]", "[::]", true),
+ // alternative IPv6 addresses
+ new Test("[0:0:0:0:0:0:13.1.68.3]", "[0:0:0:0:0:0:13.1.68.3]", true),
+ new Test("[::13.1.68.3]", "[0:0:0:0:0:0:13.1.68.3]", true),
+ new Test("[0:0:0:0:0:0:13.1.68.3]", "[::13.1.68.3]", true),
+ new Test("[::13.1.68.3]", "[::13.1.68.3]", true),
+ new Test("[::13.1.68.3]", "[::D01:4403]", true),
+ new Test("[::D01:4403]", "[::13.1.68.3]", true),
+ new Test("[::D01:4403]", "[::D01:4403]", true),
+ new Test("[::D01:4403]", "[0:0:0:0:0:0:13.1.68.3]", true),
+ new Test("[0:0:0:0:0:0:13.1.68.3]", "[::D01:4403]", true),
+ new Test("[0:0:0:0:0:FFFF:129.144.52.38]",
+ "[0:0:0:0:0:FFFF:129.144.52.38]", true),
+ new Test("[::FFFF:129.144.52.38]", "[0:0:0:0:0:FFFF:129.144.52.38]", true),
+ new Test("[0:0:0:0:0:FFFF:129.144.52.38]", "[::FFFF:129.144.52.38]", true),
+ new Test("[::FFFF:129.144.52.38]", "[::FFFF:129.144.52.38]", true),
+ new Test("[::13.1.68.3]", "[::FFFF:13.1.68.3]", false),
+ new Test("[::FFFF:13.1.68.3]", "[::13.1.68.3]", false),
};
private Test[] ports = new Test[] {
@@ -109,6 +180,7 @@
public void test(TestHarness harness)
{
harness.checkPoint("hostport checking");
+ harness.check(redhat_com_addr != null);
for (int i = 0; i < hosts.length; i++) {
for (int j = 0; j < ports.length; j++) {
@@ -117,7 +189,14 @@
SocketPermission px = new SocketPermission(test.x, "connect");
SocketPermission py = new SocketPermission(test.y, "connect");
- harness.check(px.implies(py) == test.expect);
+ try {
+ harness.check(px.implies(py) == test.expect, test.x + " should"
+ + (test.expect ? "" : " not") + " imply " + test.y);
+ }
+ catch (Exception e) {
+ harness.check(false, test.x + " implies " + test.y + " failed");
+ harness.debug(e);
+ }
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-08-25 15:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-25 15:24 FYI: Improved SocketPermission implies tests Gary Benson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).