GH-1094: Fix JAAS initializer tests on CI
Before running the JAAS initilizer security tests, remove reference to JAAS related config files created previously in other tests. This is done through clearing a system property (java.security.auth.login.config) in the tests. Without clearing this property, these tests run into a race condition. Fixes https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/1094
This commit is contained in:
@@ -18,11 +18,12 @@ package org.springframework.cloud.stream.binder.kafka.streams.bootstrap;
|
||||
|
||||
import javax.security.auth.login.AppConfigurationEntry;
|
||||
|
||||
import org.apache.kafka.common.security.JaasUtils;
|
||||
import org.apache.kafka.streams.kstream.GlobalKTable;
|
||||
import org.apache.kafka.streams.kstream.KStream;
|
||||
import org.apache.kafka.streams.kstream.KTable;
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
@@ -44,6 +45,11 @@ public class KafkaStreamsBinderBootstrapTest {
|
||||
@ClassRule
|
||||
public static EmbeddedKafkaRule embeddedKafka = new EmbeddedKafkaRule(1, true, 10);
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
System.clearProperty(JaasUtils.JAVA_LOGIN_CONFIG_PARAM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKStreamBinderWithCustomEnvironmentCanStart() {
|
||||
ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(
|
||||
@@ -93,7 +99,6 @@ public class KafkaStreamsBinderBootstrapTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Need to investigate why this test fails on CI")
|
||||
public void testKafkaStreamsBinderJaasInitialization() {
|
||||
ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(
|
||||
SimpleKafkaStreamsApplication.class).web(WebApplicationType.NONE).run(
|
||||
|
||||
@@ -19,9 +19,12 @@ package org.springframework.cloud.stream.binder.kafka;
|
||||
import javax.security.auth.login.AppConfigurationEntry;
|
||||
|
||||
import com.sun.security.auth.login.ConfigFile;
|
||||
import org.apache.kafka.common.security.JaasUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -57,7 +60,12 @@ public class KafkaBinderJaasInitializerListenerTest {
|
||||
System.clearProperty(KAFKA_BROKERS_PROPERTY);
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Before
|
||||
public void before() {
|
||||
System.clearProperty(JaasUtils.JAVA_LOGIN_CONFIG_PARAM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurationParsedCorrectlyWithKafkaClientAndDefaultControlFlag()
|
||||
throws Exception {
|
||||
ConfigFile configFile = new ConfigFile(
|
||||
@@ -86,7 +94,7 @@ public class KafkaBinderJaasInitializerListenerTest {
|
||||
});
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void testConfigurationParsedCorrectlyWithKafkaClientAndNonDefaultControlFlag()
|
||||
throws Exception {
|
||||
ConfigFile configFile = new ConfigFile(
|
||||
|
||||
Reference in New Issue
Block a user