use of org.springframework.security.web.util.matcher.MediaTypeRequestMatcher in project spring-security by spring-projects.
the class MediaTypeRequestMatcherRequestHCNSTests method mediaAllMatches.
@Test
public void mediaAllMatches() {
request.addHeader("Accept", MediaType.ALL_VALUE);
matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
assertThat(matcher.matches(request)).isTrue();
matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_XHTML_XML);
assertThat(matcher.matches(request)).isTrue();
}
use of org.springframework.security.web.util.matcher.MediaTypeRequestMatcher in project spring-security by spring-projects.
the class MediaTypeRequestMatcherRequestHCNSTests method mediaAllIgnoreMediaTypeAll.
// ignoreMediaTypeAll
@Test
public void mediaAllIgnoreMediaTypeAll() {
request.addHeader("Accept", MediaType.ALL_VALUE);
matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
assertThat(matcher.matches(request)).isFalse();
}
use of org.springframework.security.web.util.matcher.MediaTypeRequestMatcher in project spring-security by spring-projects.
the class MediaTypeRequestMatcherRequestHCNSTests method javadocJsonJsonUseEquals.
@Test
public void javadocJsonJsonUseEquals() {
request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE);
MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_JSON);
matcher.setUseEquals(true);
assertThat(matcher.matches(request)).isTrue();
}
use of org.springframework.security.web.util.matcher.MediaTypeRequestMatcher in project spring-security by spring-projects.
the class MediaTypeRequestMatcherRequestHCNSTests method javadocAllJsonUseFalse.
@Test
public void javadocAllJsonUseFalse() {
request.addHeader("Accept", MediaType.ALL_VALUE);
MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_JSON);
matcher.setUseEquals(true);
assertThat(matcher.matches(request)).isFalse();
}
use of org.springframework.security.web.util.matcher.MediaTypeRequestMatcher in project spring-security by spring-projects.
the class MediaTypeRequestMatcherTests method mediaAllIgnoreMediaTypeAll.
// ignoreMediaTypeAll
@Test
public void mediaAllIgnoreMediaTypeAll() throws HttpMediaTypeNotAcceptableException {
when(negotiationStrategy.resolveMediaTypes(any(NativeWebRequest.class))).thenReturn(Arrays.asList(MediaType.ALL));
matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
assertThat(matcher.matches(request)).isFalse();
}
Aggregations