5151import io .grpc .xds .internal .security .SecurityProtocolNegotiators .ClientSecurityHandler ;
5252import io .grpc .xds .internal .security .SecurityProtocolNegotiators .ClientSecurityProtocolNegotiator ;
5353import io .grpc .xds .internal .security .certprovider .CommonCertProviderTestUtils ;
54+ import io .grpc .xds .internal .security .trust .CertificateUtils ;
5455import io .netty .channel .ChannelHandler ;
5556import io .netty .channel .ChannelHandlerContext ;
5657import io .netty .channel .ChannelPipeline ;
@@ -145,7 +146,7 @@ public void clientSecurityProtocolNegotiatorNewHandler_withTlsContextAttribute()
145146
146147 @ Test
147148 public void clientSecurityProtocolNegotiatorNewHandler_autoHostSni_hostnameIsPassedToClientSecurityHandler () {
148- ClientSecurityHandler .isXdsSniEnabled = true ;
149+ CertificateUtils .isXdsSniEnabled = true ;
149150 try {
150151 UpstreamTlsContext upstreamTlsContext =
151152 CommonTlsContextTestsUtil .buildUpstreamTlsContext (CommonTlsContext .newBuilder ().build (), null , true , false );
@@ -168,7 +169,7 @@ public void clientSecurityProtocolNegotiatorNewHandler_autoHostSni_hostnameIsPas
168169 assertThat (newHandler ).isInstanceOf (ClientSecurityHandler .class );
169170 assertThat (((ClientSecurityHandler ) newHandler ).getSni ()).isEqualTo (FAKE_AUTHORITY );
170171 } finally {
171- ClientSecurityHandler .isXdsSniEnabled = false ;
172+ CertificateUtils .isXdsSniEnabled = false ;
172173 }
173174 }
174175
@@ -207,7 +208,7 @@ public void updateSslContext(SslContext sslContext) {
207208 protected void onException (Throwable throwable ) {
208209 future .set (throwable );
209210 }
210- }, null );
211+ }, FAKE_AUTHORITY );
211212 assertThat (executor .runDueTasks ()).isEqualTo (1 );
212213 channel .runPendingTasks ();
213214 Object fromFuture = future .get (2 , TimeUnit .SECONDS );
@@ -227,7 +228,7 @@ protected void onException(Throwable throwable) {
227228
228229 @ Test
229230 public void sniInClientSecurityHandler_autoHostSniIsTrue_usesEndpointHostname () {
230- ClientSecurityHandler .isXdsSniEnabled = true ;
231+ CertificateUtils .isXdsSniEnabled = true ;
231232 try {
232233 Bootstrapper .BootstrapInfo bootstrapInfoForClient = CommonBootstrapperTestUtils
233234 .buildBootstrapInfo ("google_cloud_private_spiffe-client" , CLIENT_KEY_FILE , CLIENT_PEM_FILE ,
@@ -244,13 +245,13 @@ public void sniInClientSecurityHandler_autoHostSniIsTrue_usesEndpointHostname()
244245
245246 assertThat (clientSecurityHandler .getSni ()).isEqualTo (HOSTNAME );
246247 } finally {
247- ClientSecurityHandler .isXdsSniEnabled = false ;
248+ CertificateUtils .isXdsSniEnabled = false ;
248249 }
249250 }
250251
251252 @ Test
252253 public void sniInClientSecurityHandler_autoHostSniIsTrue_endpointHostnameIsEmpty_usesSniFromUpstreamTlsContext () {
253- ClientSecurityHandler .isXdsSniEnabled = true ;
254+ CertificateUtils .isXdsSniEnabled = true ;
254255 try {
255256 Bootstrapper .BootstrapInfo bootstrapInfoForClient = CommonBootstrapperTestUtils
256257 .buildBootstrapInfo ("google_cloud_private_spiffe-client" , CLIENT_KEY_FILE , CLIENT_PEM_FILE ,
@@ -267,13 +268,13 @@ public void sniInClientSecurityHandler_autoHostSniIsTrue_endpointHostnameIsEmpty
267268
268269 assertThat (clientSecurityHandler .getSni ()).isEqualTo (SNI_IN_UTC );
269270 } finally {
270- ClientSecurityHandler .isXdsSniEnabled = false ;
271+ CertificateUtils .isXdsSniEnabled = false ;
271272 }
272273 }
273274
274275 @ Test
275276 public void sniInClientSecurityHandler_autoHostSniIsTrue_endpointHostnameIsNull_usesSniFromUpstreamTlsContext () {
276- ClientSecurityHandler .isXdsSniEnabled = true ;
277+ CertificateUtils .isXdsSniEnabled = true ;
277278 try {
278279 Bootstrapper .BootstrapInfo bootstrapInfoForClient = CommonBootstrapperTestUtils
279280 .buildBootstrapInfo ("google_cloud_private_spiffe-client" , CLIENT_KEY_FILE , CLIENT_PEM_FILE ,
@@ -290,13 +291,13 @@ public void sniInClientSecurityHandler_autoHostSniIsTrue_endpointHostnameIsNull_
290291
291292 assertThat (clientSecurityHandler .getSni ()).isEqualTo (SNI_IN_UTC );
292293 } finally {
293- ClientSecurityHandler .isXdsSniEnabled = false ;
294+ CertificateUtils .isXdsSniEnabled = false ;
294295 }
295296 }
296297
297298 @ Test
298299 public void sniInClientSecurityHandler_autoHostSniIsFalse_usesSniFromUpstreamTlsContext () {
299- ClientSecurityHandler .isXdsSniEnabled = true ;
300+ CertificateUtils .isXdsSniEnabled = true ;
300301 try {
301302 Bootstrapper .BootstrapInfo bootstrapInfoForClient = CommonBootstrapperTestUtils
302303 .buildBootstrapInfo ("google_cloud_private_spiffe-client" , CLIENT_KEY_FILE , CLIENT_PEM_FILE ,
@@ -313,13 +314,13 @@ public void sniInClientSecurityHandler_autoHostSniIsFalse_usesSniFromUpstreamTls
313314
314315 assertThat (clientSecurityHandler .getSni ()).isEqualTo (SNI_IN_UTC );
315316 } finally {
316- ClientSecurityHandler .isXdsSniEnabled = false ;
317+ CertificateUtils .isXdsSniEnabled = false ;
317318 }
318319 }
319320
320321 @ Test
321322 public void sniFeatureNotEnabled_usesChannelAuthorityForSni () {
322- ClientSecurityHandler .isXdsSniEnabled = false ;
323+ CertificateUtils .isXdsSniEnabled = false ;
323324 Bootstrapper .BootstrapInfo bootstrapInfoForClient = CommonBootstrapperTestUtils
324325 .buildBootstrapInfo ("google_cloud_private_spiffe-client" , CLIENT_KEY_FILE , CLIENT_PEM_FILE ,
325326 CA_PEM_FILE , null , null , null , null , null );
@@ -498,7 +499,7 @@ public void nullTlsContext_nullFallbackProtocolNegotiator_expectException() {
498499 @ Test
499500 public void clientSecurityProtocolNegotiatorNewHandler_fireProtocolNegotiationEvent ()
500501 throws InterruptedException , TimeoutException , ExecutionException {
501- ClientSecurityHandler .isXdsSniEnabled = true ;
502+ CertificateUtils .isXdsSniEnabled = true ;
502503 try {
503504 FakeClock executor = new FakeClock ();
504505 CommonCertProviderTestUtils .register (executor );
@@ -533,7 +534,7 @@ public void updateSslContext(SslContext sslContext) {
533534 protected void onException (Throwable throwable ) {
534535 future .set (throwable );
535536 }
536- }, null );
537+ }, "" );
537538 executor .runDueTasks ();
538539 channel .runPendingTasks (); // need this for tasks to execute on eventLoop
539540 Object fromFuture = future .get (5 , TimeUnit .SECONDS );
@@ -548,7 +549,7 @@ protected void onException(Throwable throwable) {
548549 assertTrue (channel .isOpen ());
549550 CommonCertProviderTestUtils .register0 ();
550551 } finally {
551- ClientSecurityHandler .isXdsSniEnabled = false ;
552+ CertificateUtils .isXdsSniEnabled = false ;
552553 }
553554 }
554555
0 commit comments