|
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. |
|
38 | 38 | import org.junit.jupiter.api.Test; |
39 | 39 |
|
40 | 40 | import org.springframework.aop.Pointcut; |
| 41 | +import org.springframework.core.annotation.AnnotationAwareOrderComparator; |
41 | 42 | import org.springframework.security.access.AccessDeniedException; |
42 | 43 | import org.springframework.security.access.prepost.PreAuthorize; |
43 | 44 | import org.springframework.security.authentication.TestAuthentication; |
@@ -336,6 +337,32 @@ public void setTargetVisitorIgnoreValueTypesThenIgnores() { |
336 | 337 | assertThat(factory.proxy(35)).isEqualTo(35); |
337 | 338 | } |
338 | 339 |
|
| 340 | + // gh-16819 |
| 341 | + @Test |
| 342 | + void advisorsWhenWithDefaultsThenAreSorted() { |
| 343 | + AuthorizationAdvisorProxyFactory proxyFactory = AuthorizationAdvisorProxyFactory.withDefaults(); |
| 344 | + AnnotationAwareOrderComparator comparator = AnnotationAwareOrderComparator.INSTANCE; |
| 345 | + AuthorizationAdvisor previous = null; |
| 346 | + for (AuthorizationAdvisor advisor : proxyFactory) { |
| 347 | + boolean ordered = previous == null || comparator.compare(previous, advisor) < 0; |
| 348 | + assertThat(ordered).isTrue(); |
| 349 | + previous = advisor; |
| 350 | + } |
| 351 | + } |
| 352 | + |
| 353 | + // gh-16819 |
| 354 | + @Test |
| 355 | + void advisorsWhenWithReactiveDefaultsThenAreSorted() { |
| 356 | + AuthorizationAdvisorProxyFactory proxyFactory = AuthorizationAdvisorProxyFactory.withReactiveDefaults(); |
| 357 | + AnnotationAwareOrderComparator comparator = AnnotationAwareOrderComparator.INSTANCE; |
| 358 | + AuthorizationAdvisor previous = null; |
| 359 | + for (AuthorizationAdvisor advisor : proxyFactory) { |
| 360 | + boolean ordered = previous == null || comparator.compare(previous, advisor) < 0; |
| 361 | + assertThat(ordered).isTrue(); |
| 362 | + previous = advisor; |
| 363 | + } |
| 364 | + } |
| 365 | + |
339 | 366 | private Authentication authenticated(String user, String... authorities) { |
340 | 367 | return TestAuthentication.authenticated(TestAuthentication.withUsername(user).authorities(authorities).build()); |
341 | 368 | } |
|
0 commit comments