diff --git a/config/src/test/java/org/springframework/security/config/http/InterceptUrlConfigTests.java b/config/src/test/java/org/springframework/security/config/http/InterceptUrlConfigTests.java
index fab1e932c0..22c30bc185 100644
--- a/config/src/test/java/org/springframework/security/config/http/InterceptUrlConfigTests.java
+++ b/config/src/test/java/org/springframework/security/config/http/InterceptUrlConfigTests.java
@@ -337,6 +337,55 @@ public class InterceptUrlConfigTests {
assertThat(this.spring.getContext().getBean(AuthorizationManager.class)).isNotNull();
}
+ /**
+ * gh-18503
+ */
+ @Test
+ public void configWhenInterceptUrlMissingAccessThenException() {
+ assertThatExceptionOfType(BeanDefinitionParsingException.class)
+ .isThrownBy(() -> this.spring.configLocations(this.xml("MissingAccess")).autowire())
+ .withMessageContaining("access attribute cannot be empty or null");
+ }
+
+ /**
+ * gh-18503
+ */
+ @Test
+ public void configWhenInterceptUrlEmptyAccessThenException() {
+ assertThatExceptionOfType(BeanDefinitionParsingException.class)
+ .isThrownBy(() -> this.spring.configLocations(this.xml("EmptyAccess")).autowire())
+ .withMessageContaining("access attribute cannot be empty or null");
+ }
+
+ /**
+ * gh-18503
+ */
+ @Test
+ public void configWhenInterceptUrlValidAccessThenLoads() {
+ assertThatNoException()
+ .isThrownBy(() -> this.spring.configLocations(this.xml("ValidAccess")).autowire());
+ }
+
+ /**
+ * gh-18503
+ */
+ @Test
+ public void configWhenUseAuthorizationManagerFalseAndMissingAccessThenException() {
+ assertThatExceptionOfType(BeanDefinitionParsingException.class)
+ .isThrownBy(() -> this.spring.configLocations(this.xml("MissingAccessLegacy")).autowire())
+ .withMessageContaining("access attribute cannot be empty or null");
+ }
+
+ /**
+ * gh-18503
+ */
+ @Test
+ public void configWhenUseAuthorizationManagerFalseAndEmptyAccessThenException() {
+ assertThatExceptionOfType(BeanDefinitionParsingException.class)
+ .isThrownBy(() -> this.spring.configLocations(this.xml("EmptyAccessLegacy")).autowire())
+ .withMessageContaining("access attribute cannot be empty or null");
+ }
+
private static RequestPostProcessor adminCredentials() {
return httpBasic("admin", "password");
}
diff --git a/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-EmptyAccess.xml b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-EmptyAccess.xml
new file mode 100644
index 0000000000..26197d5bd4
--- /dev/null
+++ b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-EmptyAccess.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-EmptyAccessLegacy.xml b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-EmptyAccessLegacy.xml
new file mode 100644
index 0000000000..897a1852e4
--- /dev/null
+++ b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-EmptyAccessLegacy.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-MissingAccess.xml b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-MissingAccess.xml
new file mode 100644
index 0000000000..d09f24205b
--- /dev/null
+++ b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-MissingAccess.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-MissingAccessLegacy.xml b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-MissingAccessLegacy.xml
new file mode 100644
index 0000000000..ad9f6ef9c9
--- /dev/null
+++ b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-MissingAccessLegacy.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-ValidAccess.xml b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-ValidAccess.xml
new file mode 100644
index 0000000000..00a33b7f0f
--- /dev/null
+++ b/config/src/test/resources/org/springframework/security/config/http/InterceptUrlConfigTests-ValidAccess.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+