1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Replace expected @Test attributes with AssertJ

Replace JUnit expected @Test attributes with AssertJ calls.
This commit is contained in:
Phillip Webb
2020-09-10 21:33:16 -07:00
committed by Josh Cummings
parent 20baa7d409
commit c502312719
243 changed files with 2115 additions and 1591 deletions
@@ -98,9 +98,10 @@ public class AnnotationSecurityAspectTests {
this.secured.securedMethod();
}
@Test(expected = AuthenticationCredentialsNotFoundException.class)
@Test
public void securedClassMethodDeniesUnauthenticatedAccess() {
this.secured.securedClassMethod();
assertThatExceptionOfType(AuthenticationCredentialsNotFoundException.class)
.isThrownBy(() -> this.secured.securedClassMethod());
}
@Test
@@ -109,17 +110,17 @@ public class AnnotationSecurityAspectTests {
this.secured.securedClassMethod();
}
@Test(expected = AccessDeniedException.class)
@Test
public void internalPrivateCallIsIntercepted() {
SecurityContextHolder.getContext().setAuthentication(this.anne);
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(() -> this.secured.publicCallsPrivate());
this.securedSub.publicCallsPrivate();
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(() -> this.securedSub.publicCallsPrivate());
}
@Test(expected = AccessDeniedException.class)
@Test
public void protectedMethodIsIntercepted() {
SecurityContextHolder.getContext().setAuthentication(this.anne);
this.secured.protectedMethod();
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(() -> this.secured.protectedMethod());
}
@Test
@@ -129,11 +130,11 @@ public class AnnotationSecurityAspectTests {
}
// SEC-1262
@Test(expected = AccessDeniedException.class)
@Test
public void denyAllPreAuthorizeDeniesAccess() {
configureForElAnnotations();
SecurityContextHolder.getContext().setAuthentication(this.anne);
this.prePostSecured.denyAllMethod();
assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(this.prePostSecured::denyAllMethod);
}
@Test