use of org.springframework.security.web.util.matcher.MediaTypeRequestMatcher in project spring-security by spring-projects.
the class MediaTypeRequestMatcherRequestHCNSTests method javadocJsonJson.
// JavaDoc
@Test
public void javadocJsonJson() {
request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE);
MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_JSON);
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 mediaAllAndTextHtmlIgnoreMediaTypeAll.
@Test
public void mediaAllAndTextHtmlIgnoreMediaTypeAll() {
request.addHeader("Accept", MediaType.ALL_VALUE + "," + MediaType.TEXT_HTML_VALUE);
matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
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 javadocAllJsonUseEquals.
@Test
public void javadocAllJsonUseEquals() {
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 MediaTypeRequestMatcherRequestHCNSTests method javadocAllJson.
@Test
public void javadocAllJson() {
request.addHeader("Accept", MediaType.ALL_VALUE);
MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_JSON);
assertThat(matcher.matches(request)).isTrue();
}
use of org.springframework.security.web.util.matcher.MediaTypeRequestMatcher in project spring-security by spring-projects.
the class MediaTypeRequestMatcherTests method mediaAllMatches.
@Test
public void mediaAllMatches() throws Exception {
when(negotiationStrategy.resolveMediaTypes(any(NativeWebRequest.class))).thenReturn(Arrays.asList(MediaType.ALL));
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();
}
Aggregations