Search in sources :

Example 6 with SecureChannelProcessor

use of org.springframework.security.web.access.channel.SecureChannelProcessor in project spring-security by spring-projects.

the class SecureChannelProcessorTests method testDecideDetectsAcceptableChannel.

// ~ Methods
// ========================================================================================================
@Test
public void testDecideDetectsAcceptableChannel() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setQueryString("info=true");
    request.setServerName("localhost");
    request.setContextPath("/bigapp");
    request.setServletPath("/servlet");
    request.setScheme("https");
    request.setSecure(true);
    request.setServerPort(8443);
    MockHttpServletResponse response = new MockHttpServletResponse();
    FilterInvocation fi = new FilterInvocation(request, response, mock(FilterChain.class));
    SecureChannelProcessor processor = new SecureChannelProcessor();
    processor.decide(fi, SecurityConfig.createList("SOME_IGNORED_ATTRIBUTE", "REQUIRES_SECURE_CHANNEL"));
    assertThat(fi.getResponse().isCommitted()).isFalse();
}
Also used : SecureChannelProcessor(org.springframework.security.web.access.channel.SecureChannelProcessor) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) FilterChain(javax.servlet.FilterChain) FilterInvocation(org.springframework.security.web.FilterInvocation) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 7 with SecureChannelProcessor

use of org.springframework.security.web.access.channel.SecureChannelProcessor in project spring-security by spring-projects.

the class SecureChannelProcessorTests method testDecideRejectsNulls.

@Test
public void testDecideRejectsNulls() throws Exception {
    SecureChannelProcessor processor = new SecureChannelProcessor();
    processor.afterPropertiesSet();
    try {
        processor.decide(null, null);
        fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
    }
}
Also used : SecureChannelProcessor(org.springframework.security.web.access.channel.SecureChannelProcessor) Test(org.junit.Test)

Example 8 with SecureChannelProcessor

use of org.springframework.security.web.access.channel.SecureChannelProcessor in project spring-security by spring-projects.

the class SecureChannelProcessorTests method testGettersSetters.

@Test
public void testGettersSetters() {
    SecureChannelProcessor processor = new SecureChannelProcessor();
    assertThat(processor.getSecureKeyword()).isEqualTo("REQUIRES_SECURE_CHANNEL");
    processor.setSecureKeyword("X");
    assertThat(processor.getSecureKeyword()).isEqualTo("X");
    assertThat(processor.getEntryPoint() != null).isTrue();
    processor.setEntryPoint(null);
    assertThat(processor.getEntryPoint() == null).isTrue();
}
Also used : SecureChannelProcessor(org.springframework.security.web.access.channel.SecureChannelProcessor) Test(org.junit.Test)

Aggregations

SecureChannelProcessor (org.springframework.security.web.access.channel.SecureChannelProcessor)8 Test (org.junit.Test)7 FilterChain (javax.servlet.FilterChain)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 FilterInvocation (org.springframework.security.web.FilterInvocation)2 SecurityConfig (org.springframework.security.access.SecurityConfig)1 PortMapper (org.springframework.security.web.PortMapper)1 ChannelProcessor (org.springframework.security.web.access.channel.ChannelProcessor)1 InsecureChannelProcessor (org.springframework.security.web.access.channel.InsecureChannelProcessor)1 RetryWithHttpEntryPoint (org.springframework.security.web.access.channel.RetryWithHttpEntryPoint)1 RetryWithHttpsEntryPoint (org.springframework.security.web.access.channel.RetryWithHttpsEntryPoint)1