|
1 | 1 | /* |
2 | | - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
47 | 47 | import org.springframework.context.annotation.Configuration; |
48 | 48 | import org.springframework.context.annotation.Import; |
49 | 49 | import org.springframework.context.annotation.Role; |
| 50 | +import org.springframework.core.annotation.AnnotationAwareOrderComparator; |
50 | 51 | import org.springframework.core.annotation.AnnotationConfigurationException; |
51 | 52 | import org.springframework.security.access.AccessDeniedException; |
52 | 53 | import org.springframework.security.access.PermissionEvaluator; |
@@ -1007,6 +1008,21 @@ public void methodWhenMetaAnnotationPropertiesHasClassProperties() { |
1007 | 1008 | assertThat(service.getIdPath("uid")).isEqualTo("uid"); |
1008 | 1009 | } |
1009 | 1010 |
|
| 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 | + |
1010 | 1026 | private static Consumer<ConfigurableWebApplicationContext> disallowBeanOverriding() { |
1011 | 1027 | return (context) -> ((AnnotationConfigWebApplicationContext) context).setAllowBeanDefinitionOverriding(false); |
1012 | 1028 | } |
|
0 commit comments