Search in sources :

Example 1 with WhiteListedAllowFromStrategy

use of org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy in project spring-security by spring-projects.

the class WhiteListedAllowFromStrategyTests method requestWithoutParameterShouldNotMatch.

@Test
public void requestWithoutParameterShouldNotMatch() {
    List<String> allowed = new ArrayList<String>();
    allowed.add("http://www.test.com");
    WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
    strategy.setAllowFromParameterName("from");
    MockHttpServletRequest request = new MockHttpServletRequest();
    String result = strategy.getAllowFromValue(request);
    assertThat(result).isEqualTo("DENY");
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ArrayList(java.util.ArrayList) WhiteListedAllowFromStrategy(org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy) Test(org.junit.Test)

Example 2 with WhiteListedAllowFromStrategy

use of org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy in project spring-security by spring-projects.

the class WhiteListedAllowFromStrategyTests method listWithMultipleElementShouldMatch.

@Test
public void listWithMultipleElementShouldMatch() {
    List<String> allowed = new ArrayList<String>();
    allowed.add("http://www.test.com");
    allowed.add("http://www.springsource.org");
    WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
    strategy.setAllowFromParameterName("from");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter("from", "http://www.test.com");
    String result = strategy.getAllowFromValue(request);
    assertThat(result).isEqualTo("http://www.test.com");
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ArrayList(java.util.ArrayList) WhiteListedAllowFromStrategy(org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy) Test(org.junit.Test)

Example 3 with WhiteListedAllowFromStrategy

use of org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy in project spring-security by spring-projects.

the class WhiteListedAllowFromStrategyTests method listWithSingleElementShouldMatch.

@Test
public void listWithSingleElementShouldMatch() {
    List<String> allowed = new ArrayList<String>();
    allowed.add("http://www.test.com");
    WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
    strategy.setAllowFromParameterName("from");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter("from", "http://www.test.com");
    String result = strategy.getAllowFromValue(request);
    assertThat(result).isEqualTo("http://www.test.com");
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ArrayList(java.util.ArrayList) WhiteListedAllowFromStrategy(org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy) Test(org.junit.Test)

Example 4 with WhiteListedAllowFromStrategy

use of org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy in project spring-security by spring-projects.

the class WhiteListedAllowFromStrategyTests method listWithSingleElementShouldNotMatch.

@Test
public void listWithSingleElementShouldNotMatch() {
    List<String> allowed = new ArrayList<String>();
    allowed.add("http://www.test.com");
    WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
    strategy.setAllowFromParameterName("from");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter("from", "http://www.test123.com");
    String result = strategy.getAllowFromValue(request);
    assertThat(result).isEqualTo("DENY");
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ArrayList(java.util.ArrayList) WhiteListedAllowFromStrategy(org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)4 WhiteListedAllowFromStrategy (org.springframework.security.web.header.writers.frameoptions.WhiteListedAllowFromStrategy)4