1 /*
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.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8049432 8069038 8234723
27 * @summary New tests for TLS property jdk.tls.client.protocols
28 * @summary javax/net/ssl/TLS/TLSClientPropertyTest.java needs to be
29 * updated for JDK-8061210
30 * @run main/othervm TLSClientPropertyTest NoProperty
31 * @run main/othervm TLSClientPropertyTest SSLv3
32 * @run main/othervm TLSClientPropertyTest TLSv1
33 * @run main/othervm TLSClientPropertyTest TLSv11
34 * @run main/othervm TLSClientPropertyTest TLSv12
35 * @run main/othervm TLSClientPropertyTest TLSv13
36 * @run main/othervm TLSClientPropertyTest TLS
37 * @run main/othervm TLSClientPropertyTest WrongProperty
38 */
39
40 import java.security.KeyManagementException;
41 import java.security.NoSuchAlgorithmException;
42 import java.util.Arrays;
43 import java.util.List;
44 import javax.net.ssl.SSLContext;
45
46 /**
54 "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"
55 };
56
57 public static void main(String[] args) throws Exception {
58
59 if (args.length < 1) {
60 throw new RuntimeException(
61 "Incorrect arguments,expected arguments: testCase");
62 }
63
64 String[] expectedDefaultProtos;
65 String testCase = args[0];
66 String contextProtocol;
67 switch (testCase) {
68 case "NoProperty":
69 if (System.getProperty("jdk.tls.client.protocols") != null) {
70 System.getProperties().remove("jdk.tls.client.protocols");
71 }
72 contextProtocol = null;
73 expectedDefaultProtos = new String[] {
74 "TLSv1", "TLSv1.1", "TLSv1.2"
75 };
76 break;
77 case "SSLv3":
78 contextProtocol = "SSLv3";
79 expectedDefaultProtos = new String[] {
80 };
81 break;
82 case "TLSv1":
83 contextProtocol = "TLSv1";
84 expectedDefaultProtos = new String[] {
85 "TLSv1"
86 };
87 break;
88 case "TLSv11":
89 contextProtocol = "TLSv1.1";
90 expectedDefaultProtos = new String[] {
91 "TLSv1", "TLSv1.1"
92 };
93 break;
94 case "TLSv12":
95 case "TLS":
96 contextProtocol = "TLSv1.2";
97 expectedDefaultProtos = new String[] {
98 "TLSv1", "TLSv1.1", "TLSv1.2"
99 };
100 break;
101 case "TLSv13":
102 contextProtocol = "TLSv1.3";
103 expectedDefaultProtos = new String[] {
104 "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"
105 };
106 break;
107 case "WrongProperty":
108 expectedDefaultProtos = new String[] {};
109 contextProtocol = "TLSV";
110 break;
111 default:
112 throw new RuntimeException("test case is wrong");
113 }
114 if (contextProtocol != null) {
115 System.setProperty("jdk.tls.client.protocols", contextProtocol);
116 }
117 try {
118 TLSClientPropertyTest test = new TLSClientPropertyTest();
119 test.test(contextProtocol, expectedDefaultProtos);
120 if (testCase.equals("WrongProperty")) {
121 throw new RuntimeException(
122 "Test failed: NoSuchAlgorithmException " +
123 "is expected when input wrong protocol");
124 } else {
|
1 /*
2 * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8049432 8069038 8234723 8202343
27 * @summary New tests for TLS property jdk.tls.client.protocols
28 * @summary javax/net/ssl/TLS/TLSClientPropertyTest.java needs to be
29 * updated for JDK-8061210
30 * @run main/othervm TLSClientPropertyTest NoProperty
31 * @run main/othervm TLSClientPropertyTest SSLv3
32 * @run main/othervm TLSClientPropertyTest TLSv1
33 * @run main/othervm TLSClientPropertyTest TLSv11
34 * @run main/othervm TLSClientPropertyTest TLSv12
35 * @run main/othervm TLSClientPropertyTest TLSv13
36 * @run main/othervm TLSClientPropertyTest TLS
37 * @run main/othervm TLSClientPropertyTest WrongProperty
38 */
39
40 import java.security.KeyManagementException;
41 import java.security.NoSuchAlgorithmException;
42 import java.util.Arrays;
43 import java.util.List;
44 import javax.net.ssl.SSLContext;
45
46 /**
54 "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"
55 };
56
57 public static void main(String[] args) throws Exception {
58
59 if (args.length < 1) {
60 throw new RuntimeException(
61 "Incorrect arguments,expected arguments: testCase");
62 }
63
64 String[] expectedDefaultProtos;
65 String testCase = args[0];
66 String contextProtocol;
67 switch (testCase) {
68 case "NoProperty":
69 if (System.getProperty("jdk.tls.client.protocols") != null) {
70 System.getProperties().remove("jdk.tls.client.protocols");
71 }
72 contextProtocol = null;
73 expectedDefaultProtos = new String[] {
74 "TLSv1.2"
75 };
76 break;
77 case "SSLv3":
78 contextProtocol = "SSLv3";
79 expectedDefaultProtos = new String[] {
80 };
81 break;
82 case "TLSv1":
83 contextProtocol = "TLSv1";
84 expectedDefaultProtos = new String[] {
85 };
86 break;
87 case "TLSv11":
88 contextProtocol = "TLSv1.1";
89 expectedDefaultProtos = new String[] {
90 };
91 break;
92 case "TLSv12":
93 case "TLS":
94 contextProtocol = "TLSv1.2";
95 expectedDefaultProtos = new String[] {
96 "TLSv1.2"
97 };
98 break;
99 case "TLSv13":
100 contextProtocol = "TLSv1.3";
101 expectedDefaultProtos = new String[] {
102 "TLSv1.2", "TLSv1.3"
103 };
104 break;
105 case "WrongProperty":
106 expectedDefaultProtos = new String[] {};
107 contextProtocol = "TLSV";
108 break;
109 default:
110 throw new RuntimeException("test case is wrong");
111 }
112 if (contextProtocol != null) {
113 System.setProperty("jdk.tls.client.protocols", contextProtocol);
114 }
115 try {
116 TLSClientPropertyTest test = new TLSClientPropertyTest();
117 test.test(contextProtocol, expectedDefaultProtos);
118 if (testCase.equals("WrongProperty")) {
119 throw new RuntimeException(
120 "Test failed: NoSuchAlgorithmException " +
121 "is expected when input wrong protocol");
122 } else {
|