@Test public void testUrlEscapingMockContainer() throws Exception { String css = ".xyz { background: url('http://www.example.org/img.gif');}"; CssTree.StyleSheet styleSheet = parser.parseDom(css); sanitizer.sanitize(styleSheet, DUMMY, gadgetContext, importRewriter, imageRewriter); assertEquals(".xyz{" + "background:url('//www.mock.com/dir/proxy?container=mockContainer&gadget=http%3A%2F%2Fwww.example.org%2Fbase" + "&debug=0&nocache=0&url=http%3A%2F%2Fwww.example.org%2Fimg.gif" + "&sanitize=1&rewriteMime=image%2F%2a');}", parser.serialize(styleSheet).replaceAll("\\s", "")); }
public void assertStyleEquals(String expected, CssTree.StyleSheet styleSheet) throws Exception { assertEquals(parser.serialize(parser.parseDom(expected)), parser.serialize(styleSheet)); } }
public void assertStyleEquals(String expected, CssTree.StyleSheet styleSheet) throws Exception { assertEquals(parser.serialize(parser.parseDom(expected)), parser.serialize(styleSheet)); } }
@Test public void testUrlEscapingMockContainer() throws Exception { String css = ".xyz { background: url('http://www.example.org/img.gif');}"; CssTree.StyleSheet styleSheet = parser.parseDom(css); sanitizer.sanitize(styleSheet, DUMMY, gadgetContext, importRewriter, imageRewriter); assertEquals(".xyz{" + "background:url('//www.mock.com/dir/proxy?container=mockContainer&gadget=http%3A%2F%2Fwww.example.org%2Fbase" + "&debug=0&nocache=0&rewriteMime=image%2F%2a&sanitize=1" + "&url=http%3A%2F%2Fwww.example.org%2Fimg.gif');}", parser.serialize(styleSheet).replaceAll("\\s", "")); }
@Test public void testUrlEscapingMockContainer() throws Exception { String css = ".xyz { background: url('http://www.example.org/img.gif');}"; CssTree.StyleSheet styleSheet = parser.parseDom(css); sanitizer.sanitize(styleSheet, DUMMY, gadgetContext, importRewriter, imageRewriter); assertEquals(".xyz{" + "background:url('//www.mock.com/dir/proxy?container=mockContainer&gadget=http%3A%2F%2Fwww.example.org%2Fbase" + "&debug=0&nocache=0&rewriteMime=image%2F%2a&sanitize=1" + "&url=http%3A%2F%2Fwww.example.org%2Fimg.gif');}", parser.serialize(styleSheet).replaceAll("\\s", "")); }
public void assertStyleEquals(String expected, CssTree.StyleSheet styleSheet) throws Exception { assertEquals(parser.serialize(parser.parseDom(expected)), parser.serialize(styleSheet)); } }
@Test public void testUrlEscapingDefaultContainer() throws Exception { String css = ".xyz { background: url('http://www.example.org/img.gif');}"; CssTree.StyleSheet styleSheet = parser.parseDom(css); GadgetContext gadgetContext = new GadgetContext() { @Override public String getContainer() { return ContainerConfig.DEFAULT_CONTAINER; } }; sanitizer.sanitize(styleSheet, DUMMY, gadgetContext, importRewriter, imageRewriter); assertEquals(".xyz{" + "background:url('//www.test.com/dir/proxy?container=default&gadget=http%3A%2F%2Fwww.example.org%2Fbase" + "&debug=0&nocache=0&rewriteMime=image%2F%2a&sanitize=1" + "&url=http%3A%2F%2Fwww.example.org%2Fimg.gif');}", parser.serialize(styleSheet).replaceAll("\\s", "")); }
@Test public void testUrlEscapingDefaultContainer() throws Exception { String css = ".xyz { background: url('http://www.example.org/img.gif');}"; CssTree.StyleSheet styleSheet = parser.parseDom(css); GadgetContext gadgetContext = new GadgetContext() { @Override public String getContainer() { return ContainerConfig.DEFAULT_CONTAINER; } }; sanitizer.sanitize(styleSheet, DUMMY, gadgetContext, importRewriter, imageRewriter); assertEquals(".xyz{" + "background:url('//www.test.com/dir/proxy?container=default&gadget=http%3A%2F%2Fwww.example.org%2Fbase" + "&debug=0&nocache=0&url=http%3A%2F%2Fwww.example.org%2Fimg.gif" + "&sanitize=1&rewriteMime=image%2F%2a');}", parser.serialize(styleSheet).replaceAll("\\s", "")); }
@Test public void testUrlEscapingDefaultContainer() throws Exception { String css = ".xyz { background: url('http://www.example.org/img.gif');}"; CssTree.StyleSheet styleSheet = parser.parseDom(css); GadgetContext gadgetContext = new GadgetContext() { @Override public String getContainer() { return ContainerConfig.DEFAULT_CONTAINER; } }; sanitizer.sanitize(styleSheet, DUMMY, gadgetContext, importRewriter, imageRewriter); assertEquals(".xyz{" + "background:url('//www.test.com/dir/proxy?container=default&gadget=http%3A%2F%2Fwww.example.org%2Fbase" + "&debug=0&nocache=0&rewriteMime=image%2F%2a&sanitize=1" + "&url=http%3A%2F%2Fwww.example.org%2Fimg.gif');}", parser.serialize(styleSheet).replaceAll("\\s", "")); }