Browse Source

Correct Tests About Conflicting Annotations

Issue gh-9289
Josh Cummings 1 year ago
parent
commit
56c93afc66

+ 2 - 2
core/src/test/java/org/springframework/security/authorization/method/PostAuthorizeAuthorizationManagerTests.java

@@ -159,8 +159,8 @@ public class PostAuthorizeAuthorizationManagerTests {
 	@Test
 	@Test
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 		Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
 		Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
-				ClassLevelAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		MethodInvocationResult result = new MethodInvocationResult(methodInvocation, null);
 		MethodInvocationResult result = new MethodInvocationResult(methodInvocation, null);
 		PostAuthorizeAuthorizationManager manager = new PostAuthorizeAuthorizationManager();
 		PostAuthorizeAuthorizationManager manager = new PostAuthorizeAuthorizationManager();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)

+ 2 - 2
core/src/test/java/org/springframework/security/authorization/method/PostAuthorizeReactiveAuthorizationManagerTests.java

@@ -165,8 +165,8 @@ public class PostAuthorizeReactiveAuthorizationManagerTests {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 		Mono<Authentication> authentication = Mono
 		Mono<Authentication> authentication = Mono
 			.just(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
 			.just(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
-				ClassLevelAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		MethodInvocationResult result = new MethodInvocationResult(methodInvocation, null);
 		MethodInvocationResult result = new MethodInvocationResult(methodInvocation, null);
 		PostAuthorizeReactiveAuthorizationManager manager = new PostAuthorizeReactiveAuthorizationManager();
 		PostAuthorizeReactiveAuthorizationManager manager = new PostAuthorizeReactiveAuthorizationManager();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)

+ 2 - 12
core/src/test/java/org/springframework/security/authorization/method/PostFilterAuthorizationMethodInterceptorTests.java

@@ -120,8 +120,8 @@ public class PostFilterAuthorizationMethodInterceptorTests {
 
 
 	@Test
 	@Test
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ConflictingAnnotations(),
-				ConflictingAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		PostFilterAuthorizationMethodInterceptor advice = new PostFilterAuthorizationMethodInterceptor();
 		PostFilterAuthorizationMethodInterceptor advice = new PostFilterAuthorizationMethodInterceptor();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 			.isThrownBy(() -> advice.invoke(methodInvocation));
 			.isThrownBy(() -> advice.invoke(methodInvocation));
@@ -230,16 +230,6 @@ public class PostFilterAuthorizationMethodInterceptorTests {
 
 
 	}
 	}
 
 
-	public static class ConflictingAnnotations implements InterfaceAnnotationsThree {
-
-		@Override
-		@PostFilter("filterObject == 'jack'")
-		public void inheritedAnnotations() {
-
-		}
-
-	}
-
 	public interface InterfaceAnnotationsOne {
 	public interface InterfaceAnnotationsOne {
 
 
 		@PostFilter("filterObject == 'jim'")
 		@PostFilter("filterObject == 'jim'")

+ 2 - 12
core/src/test/java/org/springframework/security/authorization/method/PostFilterAuthorizationReactiveMethodInterceptorTests.java

@@ -116,8 +116,8 @@ public class PostFilterAuthorizationReactiveMethodInterceptorTests {
 
 
 	@Test
 	@Test
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ConflictingAnnotations(),
-				ConflictingAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		PostFilterAuthorizationReactiveMethodInterceptor interceptor = new PostFilterAuthorizationReactiveMethodInterceptor();
 		PostFilterAuthorizationReactiveMethodInterceptor interceptor = new PostFilterAuthorizationReactiveMethodInterceptor();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 			.isThrownBy(() -> interceptor.invoke(methodInvocation));
 			.isThrownBy(() -> interceptor.invoke(methodInvocation));
@@ -155,16 +155,6 @@ public class PostFilterAuthorizationReactiveMethodInterceptorTests {
 
 
 	}
 	}
 
 
-	public static class ConflictingAnnotations implements InterfaceAnnotationsThree {
-
-		@Override
-		@PostFilter("filterObject == 'jack'")
-		public void inheritedAnnotations() {
-
-		}
-
-	}
-
 	public interface InterfaceAnnotationsOne {
 	public interface InterfaceAnnotationsOne {
 
 
 		@PostFilter("filterObject == 'jim'")
 		@PostFilter("filterObject == 'jim'")

+ 2 - 2
core/src/test/java/org/springframework/security/authorization/method/PreAuthorizeAuthorizationManagerTests.java

@@ -127,8 +127,8 @@ public class PreAuthorizeAuthorizationManagerTests {
 	@Test
 	@Test
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 		Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
 		Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
-				ClassLevelAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		PreAuthorizeAuthorizationManager manager = new PreAuthorizeAuthorizationManager();
 		PreAuthorizeAuthorizationManager manager = new PreAuthorizeAuthorizationManager();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 			.isThrownBy(() -> manager.check(authentication, methodInvocation));
 			.isThrownBy(() -> manager.check(authentication, methodInvocation));

+ 2 - 2
core/src/test/java/org/springframework/security/authorization/method/PreAuthorizeReactiveAuthorizationManagerTests.java

@@ -138,8 +138,8 @@ public class PreAuthorizeReactiveAuthorizationManagerTests {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 		Mono<Authentication> authentication = Mono
 		Mono<Authentication> authentication = Mono
 			.just(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
 			.just(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
-				ClassLevelAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		PreAuthorizeReactiveAuthorizationManager manager = new PreAuthorizeReactiveAuthorizationManager();
 		PreAuthorizeReactiveAuthorizationManager manager = new PreAuthorizeReactiveAuthorizationManager();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 			.isThrownBy(() -> manager.check(authentication, methodInvocation));
 			.isThrownBy(() -> manager.check(authentication, methodInvocation));

+ 2 - 12
core/src/test/java/org/springframework/security/authorization/method/PreFilterAuthorizationMethodInterceptorTests.java

@@ -180,8 +180,8 @@ public class PreFilterAuthorizationMethodInterceptorTests {
 
 
 	@Test
 	@Test
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ConflictingAnnotations(),
-				ConflictingAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		PreFilterAuthorizationMethodInterceptor advice = new PreFilterAuthorizationMethodInterceptor();
 		PreFilterAuthorizationMethodInterceptor advice = new PreFilterAuthorizationMethodInterceptor();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 			.isThrownBy(() -> advice.invoke(methodInvocation));
 			.isThrownBy(() -> advice.invoke(methodInvocation));
@@ -297,16 +297,6 @@ public class PreFilterAuthorizationMethodInterceptorTests {
 
 
 	}
 	}
 
 
-	public static class ConflictingAnnotations implements InterfaceAnnotationsThree {
-
-		@Override
-		@PreFilter("filterObject == 'jack'")
-		public void inheritedAnnotations() {
-
-		}
-
-	}
-
 	public interface InterfaceAnnotationsOne {
 	public interface InterfaceAnnotationsOne {
 
 
 		@PreFilter("filterObject == 'jim'")
 		@PreFilter("filterObject == 'jim'")

+ 2 - 12
core/src/test/java/org/springframework/security/authorization/method/PreFilterAuthorizationReactiveMethodInterceptorTests.java

@@ -151,8 +151,8 @@ public class PreFilterAuthorizationReactiveMethodInterceptorTests {
 
 
 	@Test
 	@Test
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ConflictingAnnotations(),
-				ConflictingAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		PreFilterAuthorizationReactiveMethodInterceptor interceptor = new PreFilterAuthorizationReactiveMethodInterceptor();
 		PreFilterAuthorizationReactiveMethodInterceptor interceptor = new PreFilterAuthorizationReactiveMethodInterceptor();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 			.isThrownBy(() -> interceptor.invoke(methodInvocation));
 			.isThrownBy(() -> interceptor.invoke(methodInvocation));
@@ -200,16 +200,6 @@ public class PreFilterAuthorizationReactiveMethodInterceptorTests {
 
 
 	}
 	}
 
 
-	public static class ConflictingAnnotations implements InterfaceAnnotationsThree {
-
-		@Override
-		@PreFilter("filterObject == 'jack'")
-		public void inheritedAnnotations() {
-
-		}
-
-	}
-
 	public interface InterfaceAnnotationsOne {
 	public interface InterfaceAnnotationsOne {
 
 
 		@PreFilter("filterObject == 'jim'")
 		@PreFilter("filterObject == 'jim'")

+ 2 - 2
core/src/test/java/org/springframework/security/authorization/method/SecuredAuthorizationManagerTests.java

@@ -147,8 +147,8 @@ public class SecuredAuthorizationManagerTests {
 	@Test
 	@Test
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 	public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
 		Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
 		Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
-		MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
-				ClassLevelAnnotations.class, "inheritedAnnotations");
+		MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
+				"inheritedAnnotations");
 		SecuredAuthorizationManager manager = new SecuredAuthorizationManager();
 		SecuredAuthorizationManager manager = new SecuredAuthorizationManager();
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 		assertThatExceptionOfType(AnnotationConfigurationException.class)
 			.isThrownBy(() -> manager.check(authentication, methodInvocation));
 			.isThrownBy(() -> manager.check(authentication, methodInvocation));