Skip to content

Commit a269d44

Browse files
miguelaranda0juergw
authored andcommitted
Project import generated by Copybara.
PiperOrigin-RevId: 898860129
1 parent 220e4a2 commit a269d44

1 file changed

Lines changed: 110 additions & 2 deletions

File tree

openjdk/src/test/java/org/conscrypt/NativeCryptoTest.java

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ public void test_SSL_set_mode_and_clear_mode() throws Exception {
524524

525525
@Test
526526
public void test_SSL_do_handshake_ech_grease_only() throws Exception {
527+
// This test only works on older versions of Java, see b/502061834.
528+
assumeFalse(TestUtils.isJavaVersion(17));
529+
527530
final ServerSocket listener = newServerSocket();
528531

529532
final byte[] key = readTestFile("boringssl-ech-private-key.bin");
@@ -572,6 +575,9 @@ public long beforeHandshake(long c) throws SSLException {
572575

573576
@Test
574577
public void test_SSL_do_handshake_ech_client_server() throws Exception {
578+
// This test only works on older versions of Java, see b/502061834.
579+
assumeFalse(TestUtils.isJavaVersion(17));
580+
575581
final ServerSocket listener = newServerSocket();
576582

577583
final byte[] key = readTestFile("boringssl-ech-private-key.bin");
@@ -1302,11 +1308,11 @@ public void clientCertificateRequested(long s) {
13021308
}
13031309

13041310
// wrapper method added for ECH testing
1311+
// Note: This method only works for pre Java 17 as it uses FD sockets.
1312+
// TODO(b/502061834): Rewrite this for engine sockets to make it work on Java 17+.
13051313
public static Future<TestSSLHandshakeCallbacks> handshake(
13061314
final ServerSocket listener, final int timeout, final boolean client, final Hooks hooks,
13071315
final byte[] alpnProtocols, final ApplicationProtocolSelectorAdapter alpnSelector) {
1308-
// TODO(prb) rewrite for engine socket. FD socket calls infeasible to test on Java 17+
1309-
assumeFalse(TestUtils.isJavaVersion(17));
13101316
ExecutorService executor = Executors.newSingleThreadExecutor();
13111317
Future<TestSSLHandshakeCallbacks> future =
13121318
executor.submit(new Callable<TestSSLHandshakeCallbacks>() {
@@ -1404,6 +1410,9 @@ public void test_SSL_do_handshake_withNullShcShouldThrow() throws Exception {
14041410

14051411
@Test
14061412
public void test_SSL_do_handshake_normal() throws Exception {
1413+
// This test only works on older versions of Java, see b/502061834.
1414+
assumeFalse(TestUtils.isJavaVersion(17));
1415+
14071416
// normal client and server case
14081417
final ServerSocket listener = newServerSocket();
14091418
Hooks cHooks = new Hooks();
@@ -1435,6 +1444,9 @@ public void test_SSL_do_handshake_normal() throws Exception {
14351444

14361445
@Test
14371446
public void test_SSL_do_handshake_reusedSession() throws Exception {
1447+
// This test only works on older versions of Java, see b/502061834.
1448+
assumeFalse(TestUtils.isJavaVersion(17));
1449+
14381450
// normal client and server case
14391451
final ServerSocket listener = newServerSocket();
14401452

@@ -1519,6 +1531,9 @@ public long beforeHandshake(long c) throws SSLException {
15191531

15201532
@Test
15211533
public void test_SSL_do_handshake_optional_client_certificate() throws Exception {
1534+
// This test only works on older versions of Java, see b/502061834.
1535+
assumeFalse(TestUtils.isJavaVersion(17));
1536+
15221537
// optional client certificate case
15231538
final ServerSocket listener = newServerSocket();
15241539

@@ -1575,6 +1590,9 @@ public long beforeHandshake(long c) throws SSLException {
15751590

15761591
@Test
15771592
public void test_SSL_do_handshake_missing_required_certificate() throws Exception {
1593+
// This test only works on older versions of Java, see b/502061834.
1594+
assumeFalse(TestUtils.isJavaVersion(17));
1595+
15781596
// required client certificate negative case
15791597
final ServerSocket listener = newServerSocket();
15801598
try {
@@ -1603,6 +1621,9 @@ public long beforeHandshake(long c) throws SSLException {
16031621

16041622
@Test
16051623
public void test_SSL_do_handshake_client_timeout() throws Exception {
1624+
// This test only works on older versions of Java, see b/502061834.
1625+
assumeFalse(TestUtils.isJavaVersion(17));
1626+
16061627
// client timeout
16071628
final ServerSocket listener = newServerSocket();
16081629
Socket serverSocket = null;
@@ -1626,6 +1647,9 @@ public void test_SSL_do_handshake_client_timeout() throws Exception {
16261647

16271648
@Test
16281649
public void test_SSL_do_handshake_server_timeout() throws Exception {
1650+
// This test only works on older versions of Java, see b/502061834.
1651+
assumeFalse(TestUtils.isJavaVersion(17));
1652+
16291653
// server timeout
16301654
final ServerSocket listener = newServerSocket();
16311655
Socket clientSocket = null;
@@ -1649,6 +1673,9 @@ public void test_SSL_do_handshake_server_timeout() throws Exception {
16491673

16501674
@Test
16511675
public void test_SSL_do_handshake_with_channel_id_normal() throws Exception {
1676+
// This test only works on older versions of Java, see b/502061834.
1677+
assumeFalse(TestUtils.isJavaVersion(17));
1678+
16521679
// Normal handshake with TLS Channel ID.
16531680
final ServerSocket listener = newServerSocket();
16541681
Hooks cHooks = new Hooks();
@@ -1685,6 +1712,9 @@ public void test_SSL_do_handshake_with_channel_id_normal() throws Exception {
16851712

16861713
@Test
16871714
public void test_SSL_do_handshake_with_channel_id_not_supported_by_server() throws Exception {
1715+
// This test only works on older versions of Java, see b/502061834.
1716+
assumeFalse(TestUtils.isJavaVersion(17));
1717+
16881718
// Client tries to use TLS Channel ID but the server does not enable/offer the extension.
16891719
final ServerSocket listener = newServerSocket();
16901720
Hooks cHooks = new Hooks();
@@ -1721,6 +1751,9 @@ public void test_SSL_do_handshake_with_channel_id_not_supported_by_server() thro
17211751

17221752
@Test
17231753
public void test_SSL_do_handshake_with_channel_id_not_enabled_by_client() throws Exception {
1754+
// This test only works on older versions of Java, see b/502061834.
1755+
assumeFalse(TestUtils.isJavaVersion(17));
1756+
17241757
// Client does not use TLS Channel ID when the server has the extension enabled/offered.
17251758
final ServerSocket listener = newServerSocket();
17261759
Hooks cHooks = new Hooks();
@@ -1757,6 +1790,9 @@ public void test_SSL_do_handshake_with_channel_id_not_enabled_by_client() throws
17571790

17581791
@Test
17591792
public void test_SSL_do_handshake_with_psk_normal() throws Exception {
1793+
// This test only works on older versions of Java, see b/502061834.
1794+
assumeFalse(TestUtils.isJavaVersion(17));
1795+
17601796
// normal TLS-PSK client and server case
17611797
final ServerSocket listener = newServerSocket();
17621798
Hooks cHooks = new ClientHooks();
@@ -1793,6 +1829,9 @@ public void test_SSL_do_handshake_with_psk_normal() throws Exception {
17931829

17941830
@Test
17951831
public void test_SSL_do_handshake_with_psk_with_identity_and_hint() throws Exception {
1832+
// This test only works on older versions of Java, see b/502061834.
1833+
assumeFalse(TestUtils.isJavaVersion(17));
1834+
17961835
// normal TLS-PSK client and server case where the server provides the client with a PSK
17971836
// identity hint, and the client provides the server with a PSK identity.
17981837
final ServerSocket listener = newServerSocket();
@@ -1834,6 +1873,9 @@ public void test_SSL_do_handshake_with_psk_with_identity_and_hint() throws Excep
18341873
@SuppressWarnings("deprecation") // PSKKeyManager is deprecated but still needs testing.
18351874
public void test_SSL_do_handshake_with_psk_with_identity_and_hint_of_max_length()
18361875
throws Exception {
1876+
// This test only works on older versions of Java, see b/502061834.
1877+
assumeFalse(TestUtils.isJavaVersion(17));
1878+
18371879
// normal TLS-PSK client and server case where the server provides the client with a PSK
18381880
// identity hint, and the client provides the server with a PSK identity.
18391881
final ServerSocket listener = newServerSocket();
@@ -1873,6 +1915,9 @@ public void test_SSL_do_handshake_with_psk_with_identity_and_hint_of_max_length(
18731915

18741916
@Test
18751917
public void test_SSL_do_handshake_with_psk_key_mismatch() throws Exception {
1918+
// This test only works on older versions of Java, see b/502061834.
1919+
assumeFalse(TestUtils.isJavaVersion(17));
1920+
18761921
final ServerSocket listener = newServerSocket();
18771922
ClientHooks cHooks = new ClientHooks();
18781923
ServerHooks sHooks = new ServerHooks();
@@ -1894,6 +1939,9 @@ public void test_SSL_do_handshake_with_psk_key_mismatch() throws Exception {
18941939

18951940
@Test
18961941
public void test_SSL_do_handshake_with_psk_with_no_client_key() throws Exception {
1942+
// This test only works on older versions of Java, see b/502061834.
1943+
assumeFalse(TestUtils.isJavaVersion(17));
1944+
18971945
final ServerSocket listener = newServerSocket();
18981946
ClientHooks cHooks = new ClientHooks();
18991947
ServerHooks sHooks = new ServerHooks();
@@ -1915,6 +1963,9 @@ public void test_SSL_do_handshake_with_psk_with_no_client_key() throws Exception
19151963

19161964
@Test
19171965
public void test_SSL_do_handshake_with_psk_with_no_server_key() throws Exception {
1966+
// This test only works on older versions of Java, see b/502061834.
1967+
assumeFalse(TestUtils.isJavaVersion(17));
1968+
19181969
final ServerSocket listener = newServerSocket();
19191970
ClientHooks cHooks = new ClientHooks();
19201971
ServerHooks sHooks = new ServerHooks();
@@ -1937,6 +1988,9 @@ public void test_SSL_do_handshake_with_psk_with_no_server_key() throws Exception
19371988
@Test
19381989
@SuppressWarnings("deprecation") // PSKKeyManager is deprecated but still needs testing.
19391990
public void test_SSL_do_handshake_with_psk_key_too_long() throws Exception {
1991+
// This test only works on older versions of Java, see b/502061834.
1992+
assumeFalse(TestUtils.isJavaVersion(17));
1993+
19401994
final ServerSocket listener = newServerSocket();
19411995
ClientHooks cHooks = new ClientHooks() {
19421996
@Override
@@ -1964,6 +2018,9 @@ public void configureCallbacks(TestSSLHandshakeCallbacks callbacks) {
19642018

19652019
@Test
19662020
public void test_SSL_do_handshake_with_ocsp_response() throws Exception {
2021+
// This test only works on older versions of Java, see b/502061834.
2022+
assumeFalse(TestUtils.isJavaVersion(17));
2023+
19672024
final byte[] OCSP_TEST_DATA = new byte[] {1, 2, 3, 4};
19682025

19692026
final ServerSocket listener = newServerSocket();
@@ -2006,6 +2063,9 @@ public long beforeHandshake(long c) throws SSLException {
20062063

20072064
@Test
20082065
public void test_SSL_do_handshake_with_sct_extension() throws Exception {
2066+
// This test only works on older versions of Java, see b/502061834.
2067+
assumeFalse(TestUtils.isJavaVersion(17));
2068+
20092069
// Fake SCT extension has a length of overall extension (unsigned 16-bit).
20102070
// Each SCT entry has a length (unsigned 16-bit) and data.
20112071
final byte[] SCT_TEST_DATA = new byte[] {0, 6, 0, 4, 1, 2, 3, 4};
@@ -2087,6 +2147,9 @@ public void SSL_set_session_withNullShouldThrow() throws Exception {
20872147

20882148
@Test
20892149
public void test_SSL_set_session() throws Exception {
2150+
// This test only works on older versions of Java, see b/502061834.
2151+
assumeFalse(TestUtils.isJavaVersion(17));
2152+
20902153
long c = NativeCrypto.SSL_CTX_new();
20912154
long s = NativeCrypto.SSL_new(c, null);
20922155
NativeCrypto.SSL_set_session(s, null, NULL);
@@ -2189,6 +2252,9 @@ public void SSL_set_session_creation_enabled_withNullShouldThrow() throws Except
21892252

21902253
@Test
21912254
public void test_SSL_set_session_creation_enabled() throws Exception {
2255+
// This test only works on older versions of Java, see b/502061834.
2256+
assumeFalse(TestUtils.isJavaVersion(17));
2257+
21922258
long c = NativeCrypto.SSL_CTX_new();
21932259
long s = NativeCrypto.SSL_new(c, null);
21942260
NativeCrypto.SSL_set_session_creation_enabled(s, null, false);
@@ -2299,6 +2365,9 @@ public void SSL_set_tlsext_host_name_withTooLongHostnameShouldThrow() throws Exc
22992365

23002366
@Test
23012367
public void test_SSL_set_tlsext_host_name() throws Exception {
2368+
// This test only works on older versions of Java, see b/502061834.
2369+
assumeFalse(TestUtils.isJavaVersion(17));
2370+
23022371
final String hostname = "www.android.com";
23032372
long c = NativeCrypto.SSL_CTX_new();
23042373
long s = NativeCrypto.SSL_new(c, null);
@@ -2338,6 +2407,9 @@ public void afterHandshake(long session, long s, long c, Socket sock, FileDescri
23382407

23392408
@Test
23402409
public void alpnWithProtocolListShouldSucceed() throws Exception {
2410+
// This test only works on older versions of Java, see b/502061834.
2411+
assumeFalse(TestUtils.isJavaVersion(17));
2412+
23412413
final byte[] clientAlpnProtocols =
23422414
SSLUtils.encodeProtocols(new String[] {"http/1.1", "foo", "spdy/2"});
23432415
final byte[] serverAlpnProtocols =
@@ -2375,6 +2447,9 @@ public void afterHandshake(long session, long ssl, long c, Socket sock,
23752447

23762448
@Test
23772449
public void alpnWithProtocolListShouldFail() throws Exception {
2450+
// This test only works on older versions of Java, see b/502061834.
2451+
assumeFalse(TestUtils.isJavaVersion(17));
2452+
23782453
final byte[] clientAlpnProtocols =
23792454
SSLUtils.encodeProtocols(new String[] {"http/1.1", "foo", "spdy/2"});
23802455
final byte[] serverAlpnProtocols =
@@ -2412,6 +2487,9 @@ public void afterHandshake(long session, long ssl, long c, Socket sock,
24122487

24132488
@Test
24142489
public void alpnWithServerProtocolSelectorShouldSucceed() throws Exception {
2490+
// This test only works on older versions of Java, see b/502061834.
2491+
assumeFalse(TestUtils.isJavaVersion(17));
2492+
24152493
final byte[] clientAlpnProtocols =
24162494
SSLUtils.encodeProtocols(new String[] {"http/1.1", "foo", "spdy/2"});
24172495

@@ -2454,6 +2532,9 @@ public void afterHandshake(long session, long ssl, long c, Socket sock,
24542532

24552533
@Test
24562534
public void alpnWithServerProtocolSelectorShouldFail() throws Exception {
2535+
// This test only works on older versions of Java, see b/502061834.
2536+
assumeFalse(TestUtils.isJavaVersion(17));
2537+
24572538
final byte[] clientAlpnProtocols =
24582539
SSLUtils.encodeProtocols(new String[] {"http/1.1", "foo", "spdy/2"});
24592540

@@ -2518,6 +2599,9 @@ public void SSL_get0_peer_certificates_withNullShouldThrow() throws Exception {
25182599

25192600
@Test
25202601
public void test_SSL_get0_peer_certificates() throws Exception {
2602+
// This test only works on older versions of Java, see b/502061834.
2603+
assumeFalse(TestUtils.isJavaVersion(17));
2604+
25212605
final ServerSocket listener = newServerSocket();
25222606

25232607
Hooks cHooks = new Hooks() {
@@ -2539,6 +2623,9 @@ public void afterHandshake(long session, long s, long c, Socket sock, FileDescri
25392623

25402624
@Test
25412625
public void test_SSL_cipher_names() throws Exception {
2626+
// This test only works on older versions of Java, see b/502061834.
2627+
assumeFalse(TestUtils.isJavaVersion(17));
2628+
25422629
final ServerSocket listener = newServerSocket();
25432630
Hooks cHooks = new Hooks();
25442631
Hooks sHooks = new ServerHooks(SERVER_PRIVATE_KEY, ENCODED_SERVER_CERTIFICATES);
@@ -2622,6 +2709,9 @@ public void SSL_read_beforeHandshakeShouldThrow() throws Exception {
26222709

26232710
@Test
26242711
public void test_SSL_read() throws Exception {
2712+
// This test only works on older versions of Java, see b/502061834.
2713+
assumeFalse(TestUtils.isJavaVersion(17));
2714+
26252715
final ServerSocket listener = newServerSocket();
26262716

26272717
// normal case
@@ -2770,6 +2860,9 @@ public void SSL_interrupt_withoutHandshakeShouldSucceed() throws Exception {
27702860

27712861
@Test
27722862
public void test_SSL_interrupt() throws Exception {
2863+
// This test only works on older versions of Java, see b/502061834.
2864+
assumeFalse(TestUtils.isJavaVersion(17));
2865+
27732866
final ServerSocket listener = newServerSocket();
27742867

27752868
Hooks cHooks = new Hooks() {
@@ -2887,6 +2980,9 @@ public void SSL_SESSION_session_id_withNullShouldThrow() throws Exception {
28872980

28882981
@Test
28892982
public void test_SSL_SESSION_session_id() throws Exception {
2983+
// This test only works on older versions of Java, see b/502061834.
2984+
assumeFalse(TestUtils.isJavaVersion(17));
2985+
28902986
final ServerSocket listener = newServerSocket();
28912987

28922988
Hooks cHooks = new Hooks() {
@@ -2914,6 +3010,9 @@ public void SSL_SESSION_get_time_withNullShouldThrow() throws Exception {
29143010

29153011
@Test
29163012
public void test_SSL_SESSION_get_time() throws Exception {
3013+
// This test only works on older versions of Java, see b/502061834.
3014+
assumeFalse(TestUtils.isJavaVersion(17));
3015+
29173016
// TODO(prb) seems to fail regularly on Windows with time < System.currentTimeMillis()
29183017
assumeFalse("Skipping SSLSession_getCreationTime() test on Windows", isWindows());
29193018

@@ -2947,6 +3046,9 @@ public void SSL_SESSION_get_version_withNullShouldThrow() throws Exception {
29473046

29483047
@Test
29493048
public void test_SSL_SESSION_get_version() throws Exception {
3049+
// This test only works on older versions of Java, see b/502061834.
3050+
assumeFalse(TestUtils.isJavaVersion(17));
3051+
29503052
final ServerSocket listener = newServerSocket();
29513053

29523054
Hooks cHooks = new Hooks() {
@@ -2973,6 +3075,9 @@ public void SSL_SESSION_cipher_withNullShouldThrow() throws Exception {
29733075

29743076
@Test
29753077
public void test_SSL_SESSION_cipher() throws Exception {
3078+
// This test only works on older versions of Java, see b/502061834.
3079+
assumeFalse(TestUtils.isJavaVersion(17));
3080+
29763081
final ServerSocket listener = newServerSocket();
29773082

29783083
Hooks cHooks = new Hooks() {
@@ -3011,6 +3116,9 @@ public void i2d_SSL_Session_WithNullSessionShouldThrow() throws Exception {
30113116

30123117
@Test
30133118
public void test_i2d_SSL_SESSION() throws Exception {
3119+
// This test only works on older versions of Java, see b/502061834.
3120+
assumeFalse(TestUtils.isJavaVersion(17));
3121+
30143122
final ServerSocket listener = newServerSocket();
30153123

30163124
Hooks cHooks = new Hooks() {

0 commit comments

Comments
 (0)