changeset 3882:79cd9368b555

7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports Reviewed-by: xuelei
author weijun
date Mon, 28 Mar 2011 18:04:17 +0800
parents 86ace035d04d
children a42760dae179
files test/sun/security/jgss/GssNPE.java test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java test/sun/security/krb5/ConfPlusProp.java test/sun/security/krb5/ConfigWithQuotations.java test/sun/security/krb5/DnsFallback.java test/sun/security/krb5/IPv6.java test/sun/security/krb5/ParseConfig.java test/sun/security/krb5/RFC396xTest.java test/sun/security/krb5/TimeInCCache.java test/sun/security/krb5/auto/HttpNegotiateServer.java test/sun/security/krb5/etype/ETypeOrder.java test/sun/security/krb5/ktab/HighestKvno.java
diffstat 12 files changed, 37 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/security/jgss/GssNPE.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/jgss/GssNPE.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/ConfPlusProp.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/ConfPlusProp.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/ConfigWithQuotations.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/ConfigWithQuotations.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/DnsFallback.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/DnsFallback.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/IPv6.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/IPv6.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/ParseConfig.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/ParseConfig.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/RFC396xTest.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/RFC396xTest.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/TimeInCCache.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/TimeInCCache.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/auto/HttpNegotiateServer.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/auto/HttpNegotiateServer.java	Mon Mar 28 18:04:17 2011 +0800
@@ -74,11 +74,10 @@
     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 @@
     // 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 @@
                 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 @@
         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 @@
         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 @@
      * @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));
--- a/test/sun/security/krb5/etype/ETypeOrder.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/etype/ETypeOrder.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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
  */
 
--- a/test/sun/security/krb5/ktab/HighestKvno.java	Mon Mar 28 18:04:10 2011 +0800
+++ b/test/sun/security/krb5/ktab/HighestKvno.java	Mon Mar 28 18:04:17 2011 +0800
@@ -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)
  */