diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java index 8f7ef62b92b..77b6baa9294 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.thymeleaf.TemplateEngine; import org.thymeleaf.context.Context; import org.thymeleaf.context.WebContext; +import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect; import org.thymeleaf.extras.springsecurity6.util.SpringSecurityContextUtils; import org.thymeleaf.spring6.ISpringWebFluxTemplateEngine; import org.thymeleaf.spring6.SpringWebFluxTemplateEngine; @@ -37,6 +38,7 @@ import org.thymeleaf.spring6.web.webflux.SpringWebFluxWebApplication; import org.thymeleaf.templateresolver.ITemplateResolver; import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; @@ -218,6 +220,12 @@ class ThymeleafReactiveAutoConfigurationTests { }); } + @Test + void securityDialectAutoConfigurationBacksOffWithoutSpringSecurity() { + this.contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.security")) + .run((context) -> assertThat(context).doesNotHaveBean(SpringSecurityDialect.class)); + } + @Test void renderTemplate() { this.contextRunner.run((context) -> { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java index 409f61c1c1d..4c02ee0aa77 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.thymeleaf.TemplateEngine; import org.thymeleaf.context.Context; import org.thymeleaf.context.WebContext; +import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect; import org.thymeleaf.spring6.SpringTemplateEngine; import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver; import org.thymeleaf.spring6.view.ThymeleafView; @@ -234,6 +235,12 @@ class ThymeleafServletAutoConfigurationTests { }); } + @Test + void securityDialectAutoConfigurationBacksOffWithoutSpringSecurity() { + this.contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.security")) + .run((context) -> assertThat(context).doesNotHaveBean(SpringSecurityDialect.class)); + } + @Test void renderTemplate() { this.contextRunner.run((context) -> {