1
+ /*
2
+ * Copyright 2002-2023 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
package org .springframework .security .authorization .method ;
2
18
3
19
import java .lang .reflect .Method ;
4
20
import java .lang .reflect .Proxy ;
5
21
import java .util .List ;
6
22
7
23
import org .junit .jupiter .api .Test ;
24
+
8
25
import org .springframework .security .access .prepost .PreAuthorize ;
9
26
10
27
import static org .assertj .core .api .Assertions .assertThatNoException ;
15
32
class AuthorizationAnnotationUtilsTests {
16
33
17
34
@ Test // gh-13132
18
- public void annotationsOnSyntheticMethodsShouldNotTriggerAnnotationConfigurationException ()
19
- throws NoSuchMethodException {
20
- StringRepository proxy =
21
- (StringRepository ) Proxy .newProxyInstance (Thread .currentThread ().getContextClassLoader (),
22
- new Class [] {StringRepository .class }, (p , m , args ) -> null );
35
+ void annotationsOnSyntheticMethodsShouldNotTriggerAnnotationConfigurationException () throws NoSuchMethodException {
36
+ StringRepository proxy = (StringRepository ) Proxy .newProxyInstance (
37
+ Thread .currentThread ().getContextClassLoader (), new Class [] { StringRepository .class },
38
+ (p , m , args ) -> null );
23
39
Method method = proxy .getClass ().getDeclaredMethod ("findAll" );
24
40
assertThatNoException ()
25
41
.isThrownBy (() -> AuthorizationAnnotationUtils .findUniqueAnnotation (method , PreAuthorize .class ));
@@ -28,12 +44,15 @@ public void annotationsOnSyntheticMethodsShouldNotTriggerAnnotationConfiguration
28
44
private interface BaseRepository <T > {
29
45
30
46
Iterable <T > findAll ();
47
+
31
48
}
32
49
33
50
private interface StringRepository extends BaseRepository <String > {
34
51
35
52
@ Override
36
53
@ PreAuthorize ("hasRole('someRole')" )
37
54
List <String > findAll ();
55
+
38
56
}
57
+
39
58
}
0 commit comments