Search in sources :

Example 6 with PreInvocationAttribute

use of org.springframework.security.access.prepost.PreInvocationAttribute in project spring-security by spring-projects.

the class ExpressionBasedPreInvocationAdviceTests method findFilterTargetNameNotProvidedTypeNotSupported.

@Test
public void findFilterTargetNameNotProvidedTypeNotSupported() throws Exception {
    PreInvocationAttribute attribute = new PreInvocationExpressionAttribute("true", "", null);
    MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class, "doSomethingString", new Class[] { String.class }, new Object[] { "param" });
    assertThatIllegalArgumentException().isThrownBy(() -> this.expressionBasedPreInvocationAdvice.before(this.authentication, methodInvocation, attribute));
}
Also used : MockMethodInvocation(org.springframework.security.access.intercept.method.MockMethodInvocation) PreInvocationAttribute(org.springframework.security.access.prepost.PreInvocationAttribute) Test(org.junit.jupiter.api.Test)

Example 7 with PreInvocationAttribute

use of org.springframework.security.access.prepost.PreInvocationAttribute in project spring-security by spring-projects.

the class ExpressionBasedPreInvocationAdviceTests method findFilterTargetNameProvidedButNotMatch.

@Test
public void findFilterTargetNameProvidedButNotMatch() throws Exception {
    PreInvocationAttribute attribute = new PreInvocationExpressionAttribute("true", "filterTargetDoesNotMatch", null);
    MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class, "doSomethingCollection", new Class[] { List.class }, new Object[] { new ArrayList<>() });
    assertThatIllegalArgumentException().isThrownBy(() -> this.expressionBasedPreInvocationAdvice.before(this.authentication, methodInvocation, attribute));
}
Also used : MockMethodInvocation(org.springframework.security.access.intercept.method.MockMethodInvocation) PreInvocationAttribute(org.springframework.security.access.prepost.PreInvocationAttribute) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)7 MockMethodInvocation (org.springframework.security.access.intercept.method.MockMethodInvocation)7 PreInvocationAttribute (org.springframework.security.access.prepost.PreInvocationAttribute)7