Skip to content

Commit 5b7baee

Browse files
committed
Add Test
Issue gh-16819
1 parent 2417de3 commit 5b7baee

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

config/src/test/java/org/springframework/security/config/annotation/method/configuration/PrePostMethodSecurityConfigurationTests.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@
4747
import org.springframework.context.annotation.Configuration;
4848
import org.springframework.context.annotation.Import;
4949
import org.springframework.context.annotation.Role;
50+
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
5051
import org.springframework.core.annotation.AnnotationConfigurationException;
5152
import org.springframework.security.access.AccessDeniedException;
5253
import org.springframework.security.access.PermissionEvaluator;
@@ -1007,6 +1008,21 @@ public void methodWhenMetaAnnotationPropertiesHasClassProperties() {
10071008
assertThat(service.getIdPath("uid")).isEqualTo("uid");
10081009
}
10091010

1011+
// gh-16819
1012+
@Test
1013+
void autowireWhenDefaultsThenAdvisorAnnotationsAreSorted() {
1014+
this.spring.register(MethodSecurityServiceConfig.class).autowire();
1015+
AuthorizationAdvisorProxyFactory proxyFactory = this.spring.getContext()
1016+
.getBean(AuthorizationAdvisorProxyFactory.class);
1017+
AnnotationAwareOrderComparator comparator = AnnotationAwareOrderComparator.INSTANCE;
1018+
AuthorizationAdvisor previous = null;
1019+
for (AuthorizationAdvisor advisor : proxyFactory) {
1020+
boolean ordered = previous == null || comparator.compare(previous, advisor) < 0;
1021+
assertThat(ordered).isTrue();
1022+
previous = advisor;
1023+
}
1024+
}
1025+
10101026
private static Consumer<ConfigurableWebApplicationContext> disallowBeanOverriding() {
10111027
return (context) -> ((AnnotationConfigWebApplicationContext) context).setAllowBeanDefinitionOverriding(false);
10121028
}

0 commit comments

Comments
 (0)