Search in sources :

Example 1 with ExpressionBasedFilterInvocationSecurityMetadataSource

use of org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource in project spring-security by spring-projects.

the class FilterSecurityMetadataSourceBeanDefinitionParserTests method expressionsAreSupported.

@Test
public void expressionsAreSupported() {
    setContext("<filter-security-metadata-source id='fids'>" + "   <intercept-url pattern='/**' access=\"hasRole('ROLE_A')\" />" + "</filter-security-metadata-source>");
    ExpressionBasedFilterInvocationSecurityMetadataSource fids = (ExpressionBasedFilterInvocationSecurityMetadataSource) this.appContext.getBean("fids");
    ConfigAttribute[] cad = fids.getAttributes(createFilterInvocation("/anything", "GET")).toArray(new ConfigAttribute[0]);
    assertThat(cad.length).isEqualTo(1);
    assertThat(cad[0].toString()).isEqualTo("hasRole('ROLE_A')");
}
Also used : ConfigAttribute(org.springframework.security.access.ConfigAttribute) ExpressionBasedFilterInvocationSecurityMetadataSource(org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 ConfigAttribute (org.springframework.security.access.ConfigAttribute)1 ExpressionBasedFilterInvocationSecurityMetadataSource (org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource)1