use of org.springframework.security.access.ConfigAttribute in project spring-security by spring-projects.
the class DefaultFilterInvocationSecurityMetadataSourceTests method requestWithDifferentHttpMethodDoesntMatch.
@Test
public void requestWithDifferentHttpMethodDoesntMatch() {
createFids("/somepage**", "GET");
FilterInvocation fi = createFilterInvocation("/somepage", null, null, "POST");
Collection<ConfigAttribute> attrs = this.fids.getAttributes(fi);
assertThat(attrs).isNull();
}
use of org.springframework.security.access.ConfigAttribute in project spring-security by spring-projects.
the class ExpressionBasedFilterInvocationSecurityMetadataSourceTests method expectedAttributeIsReturned.
@Test
public void expectedAttributeIsReturned() {
final String expression = "hasRole('X')";
LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>();
requestMap.put(AnyRequestMatcher.INSTANCE, SecurityConfig.createList(expression));
ExpressionBasedFilterInvocationSecurityMetadataSource mds = new ExpressionBasedFilterInvocationSecurityMetadataSource(requestMap, new DefaultWebSecurityExpressionHandler());
assertThat(mds.getAllConfigAttributes()).hasSize(1);
Collection<ConfigAttribute> attrs = mds.getAttributes(new FilterInvocation("/path", "GET"));
assertThat(attrs).hasSize(1);
WebExpressionConfigAttribute attribute = (WebExpressionConfigAttribute) attrs.toArray()[0];
assertThat(attribute.getAttribute()).isNull();
assertThat(attribute.getAuthorizeExpression().getExpressionString()).isEqualTo(expression);
assertThat(attribute.toString()).isEqualTo(expression);
}
use of org.springframework.security.access.ConfigAttribute in project spring-security by spring-projects.
the class DefaultFilterInvocationSecurityMetadataSourceTests method lookupNotRequiringExactMatchSucceedsIfSecureUrlPathContainsUpperCase.
/**
* SEC-501. Note that as of 2.0, lower case comparisons are the default for this
* class.
*/
@Test
public void lookupNotRequiringExactMatchSucceedsIfSecureUrlPathContainsUpperCase() {
createFids("/secure/super/**", null);
FilterInvocation fi = createFilterInvocation("/secure", "/super/somefile.html", null, null);
Collection<ConfigAttribute> response = this.fids.getAttributes(fi);
assertThat(response).isEqualTo(this.def);
}
use of org.springframework.security.access.ConfigAttribute in project spring-security by spring-projects.
the class DefaultFilterInvocationSecurityMetadataSourceTests method createFids.
// ~ Methods
// ========================================================================================================
private void createFids(String pattern, String method) {
LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>();
requestMap.put(new AntPathRequestMatcher(pattern, method), this.def);
this.fids = new DefaultFilterInvocationSecurityMetadataSource(requestMap);
}
use of org.springframework.security.access.ConfigAttribute in project spring-security by spring-projects.
the class DefaultFilterInvocationSecurityMetadataSourceTests method lookupRequiringExactMatchIsSuccessful.
@Test
public void lookupRequiringExactMatchIsSuccessful() {
createFids("/SeCurE/super/**", null);
FilterInvocation fi = createFilterInvocation("/SeCurE/super/somefile.html", null, null, null);
Collection<ConfigAttribute> response = this.fids.getAttributes(fi);
assertThat(response).isEqualTo(this.def);
}
Aggregations