use of org.springframework.security.access.expression.method.PreInvocationExpressionAttribute in project spring-security by spring-projects.
the class MethodExpressionVoterTests method ruleDefinedInAClassMethodIsApplied.
@Test
public void ruleDefinedInAClassMethodIsApplied() throws Exception {
MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingAString(), "joe");
assertThat(am.vote(joe, mi, createAttributes(new PreInvocationExpressionAttribute(null, null, "T(org.springframework.security.access.expression.method.SecurityRules).isJoe(#argument)")))).isEqualTo(AccessDecisionVoter.ACCESS_GRANTED);
}
use of org.springframework.security.access.expression.method.PreInvocationExpressionAttribute in project spring-security by spring-projects.
the class MethodExpressionVoterTests method arraysCannotBePrefiltered.
@Test(expected = IllegalArgumentException.class)
public void arraysCannotBePrefiltered() throws Exception {
MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingAnArray(), createArrayArg("sam", "joe"));
am.vote(joe, mi, createAttributes(new PreInvocationExpressionAttribute("(filterObject == 'jim')", "someArray", null)));
}
use of org.springframework.security.access.expression.method.PreInvocationExpressionAttribute in project spring-security by spring-projects.
the class MethodExpressionVoterTests method collectionPreFilteringIsSuccessful.
@Test
public void collectionPreFilteringIsSuccessful() throws Exception {
List arg = createCollectionArg("joe", "bob", "sam");
MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingACollection(), arg);
am.vote(joe, mi, createAttributes(new PreInvocationExpressionAttribute("(filterObject == 'joe' or filterObject == 'sam')", "collection", "permitAll")));
assertThat(arg).containsExactly("joe", "sam");
}
use of org.springframework.security.access.expression.method.PreInvocationExpressionAttribute in project spring-security by spring-projects.
the class MethodExpressionVoterTests method nullNamedFilterTargetIsRejected.
@Test(expected = IllegalArgumentException.class)
public void nullNamedFilterTargetIsRejected() throws Exception {
MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingACollection(), new Object[] { null });
am.vote(joe, mi, createAttributes(new PreInvocationExpressionAttribute("(filterObject == 'joe')", "collection", null)));
}
use of org.springframework.security.access.expression.method.PreInvocationExpressionAttribute in project spring-security by spring-projects.
the class MethodExpressionVoterTests method incorrectFilterTargetNameIsRejected.
@Test(expected = IllegalArgumentException.class)
public void incorrectFilterTargetNameIsRejected() throws Exception {
MethodInvocation mi = new SimpleMethodInvocation(new TargetImpl(), methodTakingACollection(), createCollectionArg("joe", "bob"));
am.vote(joe, mi, createAttributes(new PreInvocationExpressionAttribute("(filterObject == 'joe')", "collcetion", null)));
}
Aggregations