fix: cleans up FileWatcherCertificateProvider in XdsSecurityClientServerTest

This commit is contained in:
Abhishek Agrawal 2025-03-26 06:13:05 +00:00 committed by GitHub
parent 350f90e1a3
commit a332eddc13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 2 deletions

View File

@ -130,6 +130,7 @@ public class XdsSecurityClientServerTest {
private FakeXdsClient xdsClient = new FakeXdsClient(); private FakeXdsClient xdsClient = new FakeXdsClient();
private FakeXdsClientPoolFactory fakePoolFactory = new FakeXdsClientPoolFactory(xdsClient); private FakeXdsClientPoolFactory fakePoolFactory = new FakeXdsClientPoolFactory(xdsClient);
private static final String OVERRIDE_AUTHORITY = "foo.test.google.fr"; private static final String OVERRIDE_AUTHORITY = "foo.test.google.fr";
private Attributes sslContextAttributes;
@Parameters(name = "enableSpiffe={0}") @Parameters(name = "enableSpiffe={0}")
public static Collection<Boolean> data() { public static Collection<Boolean> data() {
@ -152,6 +153,14 @@ public class XdsSecurityClientServerTest {
NameResolverRegistry.getDefaultRegistry().deregister(fakeNameResolverFactory); NameResolverRegistry.getDefaultRegistry().deregister(fakeNameResolverFactory);
} }
FileWatcherCertificateProviderProvider.enableSpiffe = originalEnableSpiffe; FileWatcherCertificateProviderProvider.enableSpiffe = originalEnableSpiffe;
if (sslContextAttributes != null) {
SslContextProviderSupplier sslContextProviderSupplier = sslContextAttributes.get(
SecurityProtocolNegotiators.ATTR_SSL_CONTEXT_PROVIDER_SUPPLIER);
if (sslContextProviderSupplier != null) {
sslContextProviderSupplier.close();
}
sslContextAttributes = null;
}
} }
@Test @Test
@ -651,7 +660,7 @@ public class XdsSecurityClientServerTest {
InetSocketAddress socketAddress = InetSocketAddress socketAddress =
new InetSocketAddress(Inet4Address.getLoopbackAddress(), port); new InetSocketAddress(Inet4Address.getLoopbackAddress(), port);
tlsContextManagerForClient = new TlsContextManagerImpl(bootstrapInfoForClient); tlsContextManagerForClient = new TlsContextManagerImpl(bootstrapInfoForClient);
Attributes attrs = sslContextAttributes =
(upstreamTlsContext != null) (upstreamTlsContext != null)
? Attributes.newBuilder() ? Attributes.newBuilder()
.set(SecurityProtocolNegotiators.ATTR_SSL_CONTEXT_PROVIDER_SUPPLIER, .set(SecurityProtocolNegotiators.ATTR_SSL_CONTEXT_PROVIDER_SUPPLIER,
@ -660,7 +669,7 @@ public class XdsSecurityClientServerTest {
.build() .build()
: Attributes.EMPTY; : Attributes.EMPTY;
fakeNameResolverFactory.setServers( fakeNameResolverFactory.setServers(
ImmutableList.of(new EquivalentAddressGroup(socketAddress, attrs))); ImmutableList.of(new EquivalentAddressGroup(socketAddress, sslContextAttributes)));
return SimpleServiceGrpc.newBlockingStub(cleanupRule.register(channelBuilder.build())); return SimpleServiceGrpc.newBlockingStub(cleanupRule.register(channelBuilder.build()));
} }