@Test(expected = GadgetException.class) public void missingContainerParamChained() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath( "/proxy/refresh=123/path/http://foo.com").toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void missingUrlChained() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath( "/proxy/container=" + CONTAINER + "/path/").toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void missingUrlChained() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath( "/proxy/container=" + CONTAINER + "/path/").toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void missingUrlChained() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN + "/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath( "/proxy/container=" + CONTAINER + "/path/").toUri(); manager.process(testUri); }
@Test public void testProxyGadgetsChainDecode() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/refresh%3d55%26container%3dcontainer/" + "http://www.cnn.com/news?refresh=45"); ProxyUri pUri = uriManager.process(uri); assertEquals(new Integer(55), pUri.getRefresh()); assertEquals("http://www.cnn.com/news?refresh=45", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); }
@Test public void testProxyGadgetsChainDecode() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/refresh%3d55%26container%3dcontainer/" + "http://www.cnn.com/news?refresh=45"); ProxyUri pUri = uriManager.process(uri); assertEquals(new Integer(55), pUri.getRefresh()); assertEquals("http://www.cnn.com/news?refresh=45", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); }
@Test public void testProxyGadgetsChainDecode() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/refresh%3d55%26container%3dcontainer/" + "http://www.cnn.com/news?refresh=45"); ProxyUri pUri = uriManager.process(uri); assertEquals(new Integer(55), pUri.getRefresh()); assertEquals("http://www.cnn.com/news?refresh=45", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); }
@Test(expected = GadgetException.class) public void missingUrlQuery() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER).toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void missingUrlQuery() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER).toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void missingContainerParamQuery() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.URL.getKey(), "http://foo.com").toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void missingUrlQuery() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER).toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void missingContainerParamQuery() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.URL.getKey(), "http://foo.com").toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void mismatchedHostStrict() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager("foo" + host, path, null); manager.setUseStrictParsing(true); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.URL.getKey(), "http://foo.com").toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void mismatchedHostStrict() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager("foo" + host, path, null); manager.setUseStrictParsing(true); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.URL.getKey(), "http://foo.com").toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void mismatchedHostStrict() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager("foo" + host, path, null); manager.setUseStrictParsing(true); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.URL.getKey(), "http://foo.com").toUri(); manager.process(testUri); }
@Test public void mismatchedHostNonStrict() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager("foo" + host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.URL.getKey(), "http://foo.com") .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER).toUri(); manager.process(testUri); }
@Test public void mismatchedHostNonStrict() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager("foo" + host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.URL.getKey(), "http://foo.com") .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER).toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void invalidUrlParamQuery() throws Exception { // Only test query style, since chained style should be impossible. String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER) .addQueryParameter(Param.URL.getKey(), "!^!").toUri(); manager.process(testUri); }
@Test(expected = GadgetException.class) public void invalidUrlParamQuery() throws Exception { // Only test query style, since chained style should be impossible. String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER) .addQueryParameter(Param.URL.getKey(), "!^!").toUri(); manager.process(testUri); }
@Test public void mismatchedHostNonStrict() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager("foo" + host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.URL.getKey(), "http://foo.com") .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER).toUri(); manager.process(testUri); }