Rename DelegatingAuthorizationManager

Closes gh-9692
This commit is contained in:
Josh Cummings
2021-04-28 09:27:04 -06:00
parent 17cfc6ade3
commit df6ebc7051
2 changed files with 17 additions and 15 deletions

View File

@@ -30,36 +30,38 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Tests for {@link DelegatingAuthorizationManager}.
* Tests for {@link RequestMatcherDelegatingAuthorizationManager}.
*
* @author Evgeniy Cheban
*/
public class DelegatingAuthorizationManagerTests {
public class RequestMatcherDelegatingAuthorizationManagerTests {
@Test
public void buildWhenMappingsEmptyThenException() {
assertThatIllegalArgumentException().isThrownBy(() -> DelegatingAuthorizationManager.builder().build())
assertThatIllegalArgumentException()
.isThrownBy(() -> RequestMatcherDelegatingAuthorizationManager.builder().build())
.withMessage("mappings cannot be empty");
}
@Test
public void addWhenMatcherNullThenException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> DelegatingAuthorizationManager.builder()
.isThrownBy(() -> RequestMatcherDelegatingAuthorizationManager.builder()
.add(null, (a, o) -> new AuthorizationDecision(true)).build())
.withMessage("matcher cannot be null");
}
@Test
public void addWhenManagerNullThenException() {
assertThatIllegalArgumentException().isThrownBy(
() -> DelegatingAuthorizationManager.builder().add(new MvcRequestMatcher(null, "/grant"), null).build())
assertThatIllegalArgumentException()
.isThrownBy(() -> RequestMatcherDelegatingAuthorizationManager.builder()
.add(new MvcRequestMatcher(null, "/grant"), null).build())
.withMessage("manager cannot be null");
}
@Test
public void checkWhenMultipleMappingsConfiguredThenDelegatesMatchingManager() {
DelegatingAuthorizationManager manager = DelegatingAuthorizationManager.builder()
RequestMatcherDelegatingAuthorizationManager manager = RequestMatcherDelegatingAuthorizationManager.builder()
.add(new MvcRequestMatcher(null, "/grant"), (a, o) -> new AuthorizationDecision(true))
.add(new MvcRequestMatcher(null, "/deny"), (a, o) -> new AuthorizationDecision(false))
.add(new MvcRequestMatcher(null, "/neutral"), (a, o) -> null).build();