test/jdk/javax/net/ssl/TLS/TLSClientPropertyTest.java
changeset 59316 753ab8dcdbba
parent 47241 be3d868a805a
equal deleted inserted replaced
59315:e0d919d7c1a6 59316:753ab8dcdbba
     1 /*
     1 /*
     2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 8049432 8069038
    26  * @bug 8049432 8069038 8234723
    27  * @summary New tests for TLS property jdk.tls.client.protocols
    27  * @summary New tests for TLS property jdk.tls.client.protocols
    28  * @summary javax/net/ssl/TLS/TLSClientPropertyTest.java needs to be
    28  * @summary javax/net/ssl/TLS/TLSClientPropertyTest.java needs to be
    29  *     updated for JDK-8061210
    29  *     updated for JDK-8061210
    30  * @modules java.security.jgss
    30  * @modules java.security.jgss
    31  *          java.security.jgss/sun.security.jgss.krb5
    31  *          java.security.jgss/sun.security.jgss.krb5
    38  * @run main/othervm TLSClientPropertyTest NoProperty
    38  * @run main/othervm TLSClientPropertyTest NoProperty
    39  * @run main/othervm TLSClientPropertyTest SSLv3
    39  * @run main/othervm TLSClientPropertyTest SSLv3
    40  * @run main/othervm TLSClientPropertyTest TLSv1
    40  * @run main/othervm TLSClientPropertyTest TLSv1
    41  * @run main/othervm TLSClientPropertyTest TLSv11
    41  * @run main/othervm TLSClientPropertyTest TLSv11
    42  * @run main/othervm TLSClientPropertyTest TLSv12
    42  * @run main/othervm TLSClientPropertyTest TLSv12
       
    43  * @run main/othervm TLSClientPropertyTest TLSv13
       
    44  * @run main/othervm TLSClientPropertyTest TLS
    43  * @run main/othervm TLSClientPropertyTest WrongProperty
    45  * @run main/othervm TLSClientPropertyTest WrongProperty
    44  */
    46  */
    45 
    47 
    46 import java.security.KeyManagementException;
    48 import java.security.KeyManagementException;
    47 import java.security.NoSuchAlgorithmException;
    49 import java.security.NoSuchAlgorithmException;
    55  * property (if any),then validates the default, supported and current
    57  * property (if any),then validates the default, supported and current
    56  * protocols in the SSLContext.
    58  * protocols in the SSLContext.
    57  */
    59  */
    58 public class TLSClientPropertyTest {
    60 public class TLSClientPropertyTest {
    59     private final String[] expectedSupportedProtos = new String[] {
    61     private final String[] expectedSupportedProtos = new String[] {
    60             "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"
    62             "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"
    61     };
    63     };
    62 
    64 
    63     public static void main(String[] args) throws Exception {
    65     public static void main(String[] args) throws Exception {
    64 
    66 
    65         if (args.length < 1) {
    67         if (args.length < 1) {
    75             if (System.getProperty("jdk.tls.client.protocols") != null) {
    77             if (System.getProperty("jdk.tls.client.protocols") != null) {
    76                 System.getProperties().remove("jdk.tls.client.protocols");
    78                 System.getProperties().remove("jdk.tls.client.protocols");
    77             }
    79             }
    78             contextProtocol = null;
    80             contextProtocol = null;
    79             expectedDefaultProtos = new String[] {
    81             expectedDefaultProtos = new String[] {
    80                     "TLSv1", "TLSv1.1", "TLSv1.2"
    82                     "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"
    81             };
    83             };
    82             break;
    84             break;
    83         case "SSLv3":
    85         case "SSLv3":
    84             contextProtocol = "SSLv3";
    86             contextProtocol = "SSLv3";
    85             expectedDefaultProtos = new String[] {
    87             expectedDefaultProtos = new String[] {
    99             break;
   101             break;
   100         case "TLSv12":
   102         case "TLSv12":
   101             contextProtocol = "TLSv1.2";
   103             contextProtocol = "TLSv1.2";
   102             expectedDefaultProtos = new String[] {
   104             expectedDefaultProtos = new String[] {
   103                     "TLSv1", "TLSv1.1", "TLSv1.2"
   105                     "TLSv1", "TLSv1.1", "TLSv1.2"
       
   106             };
       
   107             break;
       
   108         case "TLSv13":
       
   109         case "TLS":
       
   110             contextProtocol = "TLSv1.3";
       
   111             expectedDefaultProtos = new String[] {
       
   112                     "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"
   104             };
   113             };
   105             break;
   114             break;
   106         case "WrongProperty":
   115         case "WrongProperty":
   107             expectedDefaultProtos = new String[] {};
   116             expectedDefaultProtos = new String[] {};
   108             contextProtocol = "TLSV";
   117             contextProtocol = "TLSV";