Skip to content

Commit c7f5639

Browse files
authored
test(xds): relax getHandshakeSession mock verification in XdsX509TrustManagerTest (#12861) (#12966)
In JDK 28, `X509TrustManagerImpl` retrieves the handshake session multiple times during certificate verification. PR #12861 relaxed one verification to `atLeastOnce()`, but left `times(1)` on the remaining five test cases in `XdsX509TrustManagerTest`. This change relaxes all remaining `getHandshakeSession()` mock verifications in `XdsX509TrustManagerTest` from `times(1)` to `atLeastOnce()`.
1 parent e1fc64c commit c7f5639

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

xds/src/test/java/io/grpc/xds/internal/security/trust/XdsX509TrustManagerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public void checkServerTrustedSslEngineSpiffeTrustMap()
569569
trustManager = XdsTrustManagerFactory.createX509TrustManager(
570570
ImmutableMap.of("example.com", caCerts), null, false);
571571
trustManager.checkServerTrusted(serverCerts, "ECDHE_ECDSA", sslEngine);
572-
verify(sslEngine, times(1)).getHandshakeSession();
572+
verify(sslEngine, atLeastOnce()).getHandshakeSession();
573573
assertThat(sslEngine.getSSLParameters().getEndpointIdentificationAlgorithm()).isEmpty();
574574
}
575575

@@ -636,7 +636,7 @@ public void checkServerTrustedSslEngine_untrustedServer_expectException()
636636
assertThat(expected).hasMessageThat()
637637
.endsWith("unable to find valid certification path to requested target");
638638
}
639-
verify(sslEngine, times(1)).getHandshakeSession();
639+
verify(sslEngine, atLeastOnce()).getHandshakeSession();
640640
}
641641

642642
@Test
@@ -647,7 +647,7 @@ public void checkServerTrustedSslSocket()
647647
CertificateUtils.toX509Certificates(TlsTesting.loadCert(SERVER_1_PEM_FILE));
648648
trustManager.checkServerTrusted(serverCerts, "ECDHE_ECDSA", sslSocket);
649649
verify(sslSocket, times(1)).isConnected();
650-
verify(sslSocket, times(1)).getHandshakeSession();
650+
verify(sslSocket, atLeastOnce()).getHandshakeSession();
651651
assertThat(sslSocket.getSSLParameters().getEndpointIdentificationAlgorithm()).isEmpty();
652652
}
653653

@@ -663,7 +663,7 @@ public void checkServerTrustedSslSocketSpiffeTrustMap()
663663
ImmutableMap.of("example.com", caCerts), null, false);
664664
trustManager.checkServerTrusted(serverCerts, "ECDHE_ECDSA", sslSocket);
665665
verify(sslSocket, times(1)).isConnected();
666-
verify(sslSocket, times(1)).getHandshakeSession();
666+
verify(sslSocket, atLeastOnce()).getHandshakeSession();
667667
assertThat(sslSocket.getSSLParameters().getEndpointIdentificationAlgorithm()).isEmpty();
668668
}
669669

@@ -681,7 +681,7 @@ public void checkServerTrustedSslSocket_untrustedServer_expectException()
681681
.endsWith("unable to find valid certification path to requested target");
682682
}
683683
verify(sslSocket, times(1)).isConnected();
684-
verify(sslSocket, times(1)).getHandshakeSession();
684+
verify(sslSocket, atLeastOnce()).getHandshakeSession();
685685
}
686686

687687
@Test

0 commit comments

Comments
 (0)