From 1b9d8d99cd6d50d7114916508a13677a0fe6f345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8D=9A?= <604501693@qq.com> Date: Thu, 5 Nov 2020 00:21:09 +0800 Subject: [PATCH 1/3] hotfix springboot spring.factories --- .../src/main/resources/META-INF/spring.factories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/spring-boot/spring-boot-web-starter/src/main/resources/META-INF/spring.factories b/support/spring-boot/spring-boot-web-starter/src/main/resources/META-INF/spring.factories index 328062d5f2..1546fc18cc 100644 --- a/support/spring-boot/spring-boot-web-starter/src/main/resources/META-INF/spring.factories +++ b/support/spring-boot/spring-boot-web-starter/src/main/resources/META-INF/spring.factories @@ -1,4 +1,4 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration = \ org.apache.shiro.spring.config.web.autoconfigure.ShiroWebAutoConfiguration,\ - org.apache.shiro.spring.config.web.autoconfigure.ShiroWebFilterConfiguration, \ + org.apache.shiro.spring.config.web.autoconfigure.ShiroWebFilterConfiguration,\ org.apache.shiro.spring.config.web.autoconfigure.ShiroWebMvcAutoConfiguration From bd152bac39bdb0255f62a96005d5bc787d82c413 Mon Sep 17 00:00:00 2001 From: Brian Demers Date: Mon, 9 Nov 2020 14:18:04 -0500 Subject: [PATCH 2/3] Add basic tests to assert no whitespace in spring.factories fiels --- .../autoconfigure/SpringFactoriesTest.groovy | 24 +++++++++++++++++++ .../web/WebSpringFactoriesTest.groovy | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/SpringFactoriesTest.groovy create mode 100644 support/spring-boot/spring-boot-web-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/web/WebSpringFactoriesTest.groovy diff --git a/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/SpringFactoriesTest.groovy b/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/SpringFactoriesTest.groovy new file mode 100644 index 0000000000..43dba2730d --- /dev/null +++ b/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/SpringFactoriesTest.groovy @@ -0,0 +1,24 @@ +package org.apache.shiro.spring.boot.autoconfigure + +import org.junit.Test + +import static org.hamcrest.MatcherAssert.assertThat +import static org.hamcrest.Matchers.matchesPattern +import static org.hamcrest.Matchers.not + +class SpringFactoriesTest { + + @Test + void springFactoriesConfigContainsNoWhitespace() { + Properties props = new Properties() + props.load(new FileReader("src/main/resources/META-INF/spring.factories")) + assertNoWhitespaceInEntries(props) + } + + static private assertNoWhitespaceInEntries(Properties props) { + props.each{ key, val -> + assertThat "Property [${key}] contains whitespace", + props.get("org.springframework.boot.autoconfigure.EnableAutoConfiguration"), not(matchesPattern(".*\\s.*")) + } + } +} diff --git a/support/spring-boot/spring-boot-web-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/web/WebSpringFactoriesTest.groovy b/support/spring-boot/spring-boot-web-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/web/WebSpringFactoriesTest.groovy new file mode 100644 index 0000000000..b0892a13ea --- /dev/null +++ b/support/spring-boot/spring-boot-web-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/web/WebSpringFactoriesTest.groovy @@ -0,0 +1,24 @@ +package org.apache.shiro.spring.boot.autoconfigure.web + +import org.junit.Test + +import static org.hamcrest.MatcherAssert.assertThat +import static org.hamcrest.Matchers.matchesPattern +import static org.hamcrest.Matchers.not + +class WebSpringFactoriesTest { + + @Test + void springFactoriesConfigContainsNoWhitespace() { + Properties props = new Properties() + props.load(new FileReader("src/main/resources/META-INF/spring.factories")) + assertNoWhitespaceInEntries(props) + } + + static private assertNoWhitespaceInEntries(Properties props) { + props.each{ key, val -> + assertThat "Property [${key}] contains whitespace", + props.get("org.springframework.boot.autoconfigure.EnableAutoConfiguration"), not(matchesPattern(".*\\s.*")) + } + } +} From 9a2de1649f72ecacdaabfd43f3ab9f89ae2d1f98 Mon Sep 17 00:00:00 2001 From: Brian Demers Date: Tue, 10 Nov 2020 09:41:07 -0500 Subject: [PATCH 3/3] Add missing license headers to new tests --- .../autoconfigure/SpringFactoriesTest.groovy | 18 ++++++++++++++++++ .../web/WebSpringFactoriesTest.groovy | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/SpringFactoriesTest.groovy b/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/SpringFactoriesTest.groovy index 43dba2730d..9b1e1cc800 100644 --- a/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/SpringFactoriesTest.groovy +++ b/support/spring-boot/spring-boot-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/SpringFactoriesTest.groovy @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.shiro.spring.boot.autoconfigure import org.junit.Test diff --git a/support/spring-boot/spring-boot-web-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/web/WebSpringFactoriesTest.groovy b/support/spring-boot/spring-boot-web-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/web/WebSpringFactoriesTest.groovy index b0892a13ea..491bc0a7fc 100644 --- a/support/spring-boot/spring-boot-web-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/web/WebSpringFactoriesTest.groovy +++ b/support/spring-boot/spring-boot-web-starter/src/test/groovy/org/apache/shiro/spring/boot/autoconfigure/web/WebSpringFactoriesTest.groovy @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.shiro.spring.boot.autoconfigure.web import org.junit.Test