Add "hosts" property to RedirectView

Issue: SPR-13693
This commit is contained in:
Rossen Stoyanchev
2016-02-10 14:20:21 -05:00
parent aba04d576f
commit c45ad3022b
3 changed files with 99 additions and 6 deletions

View File

@@ -43,6 +43,7 @@ import org.springframework.web.servlet.support.SessionFlashMapManager;
import org.springframework.web.util.WebUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;
@@ -205,6 +206,24 @@ public class RedirectViewTests {
}
}
// SPR-13693
@Test
public void remoteHost() throws Exception {
RedirectView rv = new RedirectView();
assertFalse(rv.isRemoteHost("http://url.somewhere.com"));
assertFalse(rv.isRemoteHost("/path"));
assertFalse(rv.isRemoteHost("http://url.somewhereelse.com"));
rv.setHosts(new String[] {"url.somewhere.com"});
assertFalse(rv.isRemoteHost("http://url.somewhere.com"));
assertFalse(rv.isRemoteHost("/path"));
assertTrue(rv.isRemoteHost("http://url.somewhereelse.com"));
}
@Test
public void emptyMap() throws Exception {
String url = "/myUrl";