From 60cd59d24d9626fffef740e514f3411f51e4f119 Mon Sep 17 00:00:00 2001 From: weijun Date: Mon, 28 Mar 2011 18:04:17 +0800 Subject: [PATCH] 7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports Reviewed-by: xuelei --- test/sun/security/jgss/GssNPE.java | 3 +- .../jgss/spnego/NoSpnegoAsDefMech.java | 3 +- test/sun/security/krb5/ConfPlusProp.java | 3 +- .../security/krb5/ConfigWithQuotations.java | 3 +- test/sun/security/krb5/DnsFallback.java | 3 +- test/sun/security/krb5/IPv6.java | 3 +- test/sun/security/krb5/ParseConfig.java | 3 +- test/sun/security/krb5/RFC396xTest.java | 3 +- test/sun/security/krb5/TimeInCCache.java | 3 +- .../krb5/auto/HttpNegotiateServer.java | 33 +++++++++---------- test/sun/security/krb5/etype/ETypeOrder.java | 3 +- test/sun/security/krb5/ktab/HighestKvno.java | 3 +- 12 files changed, 37 insertions(+), 29 deletions(-) diff --git a/test/sun/security/jgss/GssNPE.java b/test/sun/security/jgss/GssNPE.java index bacf60c5f..d2723ba62 100644 --- a/test/sun/security/jgss/GssNPE.java +++ b/test/sun/security/jgss/GssNPE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 6345338 + * @run main/othervm GssNPE * @summary GSS throws NPE when the JAAS config file does not exist */ diff --git a/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java b/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java index 13b9ee9d4..998f50d33 100644 --- a/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java +++ b/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 6770883 + * @run main/othervm NoSpnegoAsDefMech * @summary Infinite loop if SPNEGO specified as sun.security.jgss.mechanism */ diff --git a/test/sun/security/krb5/ConfPlusProp.java b/test/sun/security/krb5/ConfPlusProp.java index e29637b1b..9fe1adcf4 100644 --- a/test/sun/security/krb5/ConfPlusProp.java +++ b/test/sun/security/krb5/ConfPlusProp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @bug 6857795 * @bug 6858589 * @bug 6972005 + * @run main/othervm ConfPlusProp * @summary krb5.conf ignored if system properties on realm and kdc are provided */ diff --git a/test/sun/security/krb5/ConfigWithQuotations.java b/test/sun/security/krb5/ConfigWithQuotations.java index adf3919b9..c1286f8cb 100644 --- a/test/sun/security/krb5/ConfigWithQuotations.java +++ b/test/sun/security/krb5/ConfigWithQuotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test * @bug 6714845 + * @run main/othervm ConfigWithQuotations * @summary Quotes in Kerberos configuration file are included in the values */ diff --git a/test/sun/security/krb5/DnsFallback.java b/test/sun/security/krb5/DnsFallback.java index e305ac856..3a48b05d8 100644 --- a/test/sun/security/krb5/DnsFallback.java +++ b/test/sun/security/krb5/DnsFallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ * @test * @bug 6673164 * @bug 6552334 + * @run main/othervm DnsFallback * @summary fix dns_fallback parse error, and use dns by default */ diff --git a/test/sun/security/krb5/IPv6.java b/test/sun/security/krb5/IPv6.java index 4b4f2a887..d1a8bf260 100644 --- a/test/sun/security/krb5/IPv6.java +++ b/test/sun/security/krb5/IPv6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 6877357 6885166 + * @run main/othervm IPv6 * @summary IPv6 address does not work */ diff --git a/test/sun/security/krb5/ParseConfig.java b/test/sun/security/krb5/ParseConfig.java index d4aa590eb..43c5ce39f 100644 --- a/test/sun/security/krb5/ParseConfig.java +++ b/test/sun/security/krb5/ParseConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test * @bug 6319046 + * @run main/othervm ParseConfig * @summary Problem with parsing krb5.conf */ diff --git a/test/sun/security/krb5/RFC396xTest.java b/test/sun/security/krb5/RFC396xTest.java index 2bd3f235a..76016c388 100644 --- a/test/sun/security/krb5/RFC396xTest.java +++ b/test/sun/security/krb5/RFC396xTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test * @bug 6862679 + * @run main/othervm RFC396xTest * @summary ESC: AD Authentication with user with umlauts fails */ diff --git a/test/sun/security/krb5/TimeInCCache.java b/test/sun/security/krb5/TimeInCCache.java index e0e420f33..6c33d2eae 100644 --- a/test/sun/security/krb5/TimeInCCache.java +++ b/test/sun/security/krb5/TimeInCCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test * @bug 6590930 + * @run main/othervm TimeInCCache * @summary read/write does not match for ccache */ diff --git a/test/sun/security/krb5/auto/HttpNegotiateServer.java b/test/sun/security/krb5/auto/HttpNegotiateServer.java index 423ef0d85..aab6b9213 100644 --- a/test/sun/security/krb5/auto/HttpNegotiateServer.java +++ b/test/sun/security/krb5/auto/HttpNegotiateServer.java @@ -74,11 +74,10 @@ public class HttpNegotiateServer { final static char[] WEB_PASS = "webby".toCharArray(); final static String PROXY_USER = "pro"; final static char[] PROXY_PASS = "proxy".toCharArray(); - final static int WEB_PORT = 17840; + final static String WEB_HOST = "host.web.domain"; final static String PROXY_HOST = "host.proxy.domain"; - final static int PROXY_PORT = 17841; // web page content final static String CONTENT = "Hello, World!"; @@ -86,18 +85,11 @@ public class HttpNegotiateServer { // For 6829283, count how many times the Authenticator is called. static int count = 0; + static int webPort, proxyPort; + // URLs for web test, proxy test. The proxy server is not a real proxy // since it fakes the same content for any URL. :) - final static URL webUrl, proxyUrl; - static { - URL u1 = null, u2 = null; - try { - u1 = new URL("http://" + WEB_HOST +":" + WEB_PORT + "/a/b/c"); - u2 = new URL("http://nosuchplace/a/b/c"); - } catch (Exception e) { - } - webUrl = u1; proxyUrl = u2; - } + static URL webUrl, proxyUrl; /** * This Authenticator checks everything: @@ -127,7 +119,7 @@ public class HttpNegotiateServer { if (!this.getRequestingHost().equalsIgnoreCase(PROXY_HOST)) { throw new RuntimeException("Bad host"); } - if (this.getRequestingPort() != PROXY_PORT) { + if (this.getRequestingPort() != proxyPort) { throw new RuntimeException("Bad port"); } if (!this.getRequestingURL().equals(proxyUrl)) { @@ -188,10 +180,15 @@ public class HttpNegotiateServer { fos.close(); f.deleteOnExit(); - HttpServer h1 = httpd(WEB_PORT, "Negotiate", false, + HttpServer h1 = httpd("Negotiate", false, "HTTP/" + WEB_HOST + "@" + REALM_WEB, KRB5_TAB); - HttpServer h2 = httpd(PROXY_PORT, "Negotiate", true, + webPort = h1.getAddress().getPort(); + HttpServer h2 = httpd("Negotiate", true, "HTTP/" + PROXY_HOST + "@" + REALM_PROXY, KRB5_TAB); + proxyPort = h2.getAddress().getPort(); + + webUrl = new URL("http://" + WEB_HOST +":" + webPort + "/a/b/c"); + proxyUrl = new URL("http://nosuchplace/a/b/c"); try { Exception e1 = null, e2 = null; @@ -230,7 +227,7 @@ public class HttpNegotiateServer { reader = new BufferedReader(new InputStreamReader( proxyUrl.openConnection( new Proxy(Proxy.Type.HTTP, - new InetSocketAddress(PROXY_HOST, PROXY_PORT))) + new InetSocketAddress(PROXY_HOST, proxyPort))) .getInputStream())); if (!reader.readLine().equals(CONTENT)) { throw new RuntimeException("Bad content"); @@ -258,10 +255,10 @@ public class HttpNegotiateServer { * @param principal the krb5 service principal the server runs with * @return the server */ - public static HttpServer httpd(int port, String scheme, boolean proxy, + public static HttpServer httpd(String scheme, boolean proxy, String principal, String ktab) throws Exception { MyHttpHandler h = new MyHttpHandler(); - HttpServer server = HttpServer.create(new InetSocketAddress(port), 0); + HttpServer server = HttpServer.create(new InetSocketAddress(0), 0); HttpContext hc = server.createContext("/", h); hc.setAuthenticator(new MyServerAuthenticator( proxy, scheme, principal, ktab)); diff --git a/test/sun/security/krb5/etype/ETypeOrder.java b/test/sun/security/krb5/etype/ETypeOrder.java index cb854acf7..9437b16ed 100644 --- a/test/sun/security/krb5/etype/ETypeOrder.java +++ b/test/sun/security/krb5/etype/ETypeOrder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test * @bug 6844907 + * @run main/othervm ETypeOrder * @summary krb5 etype order should be from strong to weak */ diff --git a/test/sun/security/krb5/ktab/HighestKvno.java b/test/sun/security/krb5/ktab/HighestKvno.java index 9636bb1b5..92e3aebd6 100644 --- a/test/sun/security/krb5/ktab/HighestKvno.java +++ b/test/sun/security/krb5/ktab/HighestKvno.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ * @test * @bug 6867665 * @bug 6875033 + * @run main/othervm HighestKvno * @summary Problem with keytabs with multiple kvno's (key versions) */ -- GitLab