@@ -208,6 +208,72 @@ public void createCertProviderClientSslContextProvider_2providers()
208208 verifyWatcher (sslContextProvider , watcherCaptor [1 ]);
209209 }
210210
211+ @ Test
212+ public void createNewCertProviderClientSslContextProvider_withSans () {
213+ final CertificateProvider .DistributorWatcher [] watcherCaptor =
214+ new CertificateProvider .DistributorWatcher [2 ];
215+ createAndRegisterProviderProvider (certificateProviderRegistry , watcherCaptor , "testca" , 0 );
216+ createAndRegisterProviderProvider (
217+ certificateProviderRegistry , watcherCaptor , "file_watcher" , 1 );
218+
219+ CertificateValidationContext staticCertValidationContext =
220+ CertificateValidationContext .newBuilder ()
221+ .addAllMatchSubjectAltNames (
222+ ImmutableSet .of (
223+ StringMatcher .newBuilder ().setExact ("foo" ).build (),
224+ StringMatcher .newBuilder ().setExact ("bar" ).build ()))
225+ .build ();
226+ UpstreamTlsContext upstreamTlsContext =
227+ CommonTlsContextTestsUtil .buildNewUpstreamTlsContextForCertProviderInstance (
228+ "gcp_id" ,
229+ "cert-default" ,
230+ "file_provider" ,
231+ "root-default" ,
232+ /* alpnProtocols= */ null ,
233+ staticCertValidationContext );
234+
235+ Bootstrapper .BootstrapInfo bootstrapInfo = CommonBootstrapperTestUtils .getTestBootstrapInfo ();
236+ clientSslContextProviderFactory =
237+ new ClientSslContextProviderFactory (
238+ bootstrapInfo , certProviderClientSslContextProviderFactory );
239+ SslContextProvider sslContextProvider =
240+ clientSslContextProviderFactory .create (upstreamTlsContext );
241+ assertThat (sslContextProvider ).isInstanceOf (CertProviderClientSslContextProvider .class );
242+ verifyWatcher (sslContextProvider , watcherCaptor [0 ]);
243+ verifyWatcher (sslContextProvider , watcherCaptor [1 ]);
244+ }
245+
246+ @ Test
247+ public void createNewCertProviderClientSslContextProvider_onlyRootCert () {
248+ final CertificateProvider .DistributorWatcher [] watcherCaptor =
249+ new CertificateProvider .DistributorWatcher [1 ];
250+ createAndRegisterProviderProvider (certificateProviderRegistry , watcherCaptor , "testca" , 0 );
251+ CertificateValidationContext staticCertValidationContext =
252+ CertificateValidationContext .newBuilder ()
253+ .addAllMatchSubjectAltNames (
254+ ImmutableSet .of (
255+ StringMatcher .newBuilder ().setExact ("foo" ).build (),
256+ StringMatcher .newBuilder ().setExact ("bar" ).build ()))
257+ .build ();
258+ UpstreamTlsContext upstreamTlsContext =
259+ CommonTlsContextTestsUtil .buildNewUpstreamTlsContextForCertProviderInstance (
260+ /* certInstanceName= */ null ,
261+ /* certName= */ null ,
262+ "gcp_id" ,
263+ "root-default" ,
264+ /* alpnProtocols= */ null ,
265+ staticCertValidationContext );
266+
267+ Bootstrapper .BootstrapInfo bootstrapInfo = CommonBootstrapperTestUtils .getTestBootstrapInfo ();
268+ clientSslContextProviderFactory =
269+ new ClientSslContextProviderFactory (
270+ bootstrapInfo , certProviderClientSslContextProviderFactory );
271+ SslContextProvider sslContextProvider =
272+ clientSslContextProviderFactory .create (upstreamTlsContext );
273+ assertThat (sslContextProvider ).isInstanceOf (CertProviderClientSslContextProvider .class );
274+ verifyWatcher (sslContextProvider , watcherCaptor [0 ]);
275+ }
276+
211277 @ Test
212278 public void createNullCommonTlsContext_exception () throws IOException {
213279 clientSslContextProviderFactory =
0 commit comments