From 0f0f29cfed3787c6974579c719364aa463fa2e04 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Mon, 10 Jul 2023 14:20:32 -0400 Subject: [PATCH] Kafka binder security test changes - Before running a test, invalidate any existing JVM-wide static security configuration so that tests are forced to create/use fresh security configuration. Without this, test suites with multiple security tests might fail as they might overlap with security confugiruation from other tests. --- .../binder/kafka/KafkaBinderJaasInitializerListenerTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/binders/kafka-binder/spring-cloud-stream-binder-kafka/src/test/java/org/springframework/cloud/stream/binder/kafka/KafkaBinderJaasInitializerListenerTest.java b/binders/kafka-binder/spring-cloud-stream-binder-kafka/src/test/java/org/springframework/cloud/stream/binder/kafka/KafkaBinderJaasInitializerListenerTest.java index 9ca1be0e5..e5522b229 100644 --- a/binders/kafka-binder/spring-cloud-stream-binder-kafka/src/test/java/org/springframework/cloud/stream/binder/kafka/KafkaBinderJaasInitializerListenerTest.java +++ b/binders/kafka-binder/spring-cloud-stream-binder-kafka/src/test/java/org/springframework/cloud/stream/binder/kafka/KafkaBinderJaasInitializerListenerTest.java @@ -17,6 +17,7 @@ package org.springframework.cloud.stream.binder.kafka; import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.Configuration; import com.sun.security.auth.login.ConfigFile; import org.apache.kafka.common.security.JaasUtils; @@ -72,6 +73,8 @@ public class KafkaBinderJaasInitializerListenerTest { @BeforeEach public void before() { System.clearProperty(JaasUtils.JAVA_LOGIN_CONFIG_PARAM); + // Invalidate any existing security configuration so that tests are forced to create/use fresh configuration. + Configuration.setConfiguration(null); } @Test