use of org.springframework.security.OtherTargetObject in project spring-security by spring-projects.
the class MethodInvocationPrivilegeEvaluatorTests method declinesAccessUsingCreateFromClass.
@Test
public void declinesAccessUsingCreateFromClass() throws Exception {
final MethodInvocation mi = MethodInvocationUtils.createFromClass(new OtherTargetObject(), ITargetObject.class, "makeLowerCase", new Class[] { String.class }, new Object[] { "helloWorld" });
MethodInvocationPrivilegeEvaluator mipe = new MethodInvocationPrivilegeEvaluator();
mipe.setSecurityInterceptor(interceptor);
when(mds.getAttributes(mi)).thenReturn(role);
doThrow(new AccessDeniedException("rejected")).when(adm).decide(token, mi, role);
assertThat(mipe.isAllowed(mi, token)).isFalse();
}
use of org.springframework.security.OtherTargetObject in project spring-security by spring-projects.
the class MethodInvocationPrivilegeEvaluatorTests method allowsAccessUsingCreateFromClass.
@Test
public void allowsAccessUsingCreateFromClass() throws Exception {
final MethodInvocation mi = MethodInvocationUtils.createFromClass(new OtherTargetObject(), ITargetObject.class, "makeLowerCase", new Class[] { String.class }, new Object[] { "Hello world" });
MethodInvocationPrivilegeEvaluator mipe = new MethodInvocationPrivilegeEvaluator();
mipe.setSecurityInterceptor(interceptor);
when(mds.getAttributes(mi)).thenReturn(role);
assertThat(mipe.isAllowed(mi, token)).isTrue();
}
Aggregations