use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class MethodExpressionVoterTests method hasRoleExpressionDeniesUserWithoutRole.
@Test
public void hasRoleExpressionDeniesUserWithoutRole() throws Exception {
List<ConfigAttribute> cad = new ArrayList<>(1);
cad.add(new PreInvocationExpressionAttribute(null, null, "hasRole('joedoesnt')"));
MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingAnArray());
assertThat(this.am.vote(this.joe, mi, cad)).isEqualTo(AccessDecisionVoter.ACCESS_DENIED);
}
use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class MethodExpressionVoterTests method hasRoleExpressionAllowsUserWithRole.
@Test
public void hasRoleExpressionAllowsUserWithRole() throws Exception {
MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingAnArray());
assertThat(this.am.vote(this.joe, mi, createAttributes(new PreInvocationExpressionAttribute(null, null, "hasRole('blah')")))).isEqualTo(AccessDecisionVoter.ACCESS_GRANTED);
}
use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class MethodExpressionVoterTests method incorrectFilterTargetNameIsRejected.
@Test
public void incorrectFilterTargetNameIsRejected() throws Exception {
MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingACollection(), createCollectionArg("joe", "bob"));
assertThatIllegalArgumentException().isThrownBy(() -> this.am.vote(this.joe, mi, createAttributes(new PreInvocationExpressionAttribute("(filterObject == 'joe')", "collcetion", null))));
}
use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class AbstractAclVoterTests method correctArgumentIsSelectedFromMultipleArgs.
@Test
public void correctArgumentIsSelectedFromMultipleArgs() {
this.voter.setProcessDomainObjectClass(String.class);
MethodInvocation mi = MethodInvocationUtils.create(new TestClass(), "methodTakingAListAndAString", new ArrayList<>(), "The Argument");
assertThat(this.voter.getDomainObjectInstance(mi)).isEqualTo("The Argument");
}
use of org.aopalliance.intercept.MethodInvocation in project spring-security by spring-projects.
the class MethodInvocationUtilsTests method createFromClassReturnsMethodIfArgInfoOmittedAndMethodNameIsUnique.
@Test
public void createFromClassReturnsMethodIfArgInfoOmittedAndMethodNameIsUnique() {
MethodInvocation mi = MethodInvocationUtils.createFromClass(BusinessServiceImpl.class, "methodReturningAnArray");
assertThat(mi).isNotNull();
}
Aggregations