private static HttpRequest createIgnoreCacheRequest() { return new HttpRequest(SPEC_URL) .setIgnoreCache(true) .setGadget(SPEC_URL) .setContainer(ContainerConfig.DEFAULT_CONTAINER); }
@Test public void ignoreCacheAddsPragmaHeader() throws Exception { HttpRequest request = new HttpRequest(DEFAULT_URI).setIgnoreCache(true); assertTrue("Pragma: no-cache not added when ignoreCache == true", request.getHeaders("Pragma").contains("no-cache")); }
private static HttpRequest createIgnoreCacheRequest() { return new HttpRequest(SPEC_URL) .setIgnoreCache(true) .setGadget(SPEC_URL) .setContainer(ContainerConfig.DEFAULT_CONTAINER); }
@Test public void ignoreCacheAddsPragmaHeader() throws Exception { HttpRequest request = new HttpRequest(DEFAULT_URI).setIgnoreCache(true); assertTrue("Pragma: no-cache not added when ignoreCache == true", request.getHeaders("Pragma").contains("no-cache")); }
@Test public void ignoreCacheAddsPragmaHeader() throws Exception { HttpRequest request = new HttpRequest(DEFAULT_URI).setIgnoreCache(true); assertTrue("Pragma: no-cache not added when ignoreCache == true", request.getHeaders("Pragma").contains("no-cache")); }
private static HttpRequest createIgnoreCacheRequest() { return new HttpRequest(SPEC_URL) .setIgnoreCache(true) .setGadget(SPEC_URL) .setContainer(ContainerConfig.DEFAULT_CONTAINER); }
@Test public void addResponseIgnoreCache() { HttpRequest request = new HttpRequest(DEFAULT_URI) .setIgnoreCache(true); HttpResponse response = new HttpResponse("does not matter"); assertFalse("response should not have been cached", cache.addResponse(request, response)); assertEquals(0, cache.map.size()); }
@Test public void getResponseIgnoreCache() { HttpRequest request = new HttpRequest(DEFAULT_URI); String key = cache.createKey(request); HttpResponse response = new HttpResponse("result"); cache.map.put(key, response); request.setIgnoreCache(true); assertNull("Did not return null when ignoreCache was true", cache.getResponse(request)); }
@Test public void getResponseIgnoreCache() { HttpRequest request = new HttpRequest(DEFAULT_URI); String key = cache.createKey(request); HttpResponse response = new HttpResponse("result"); cache.map.put(key, response); request.setIgnoreCache(true); assertNull("Did not return null when ignoreCache was true", cache.getResponse(request)); extendedStrictNoCacheTtlCache.map.put(key, response); assertNull("Did not return null when ignoreCache was true", extendedStrictNoCacheTtlCache.getResponse(request)); }
@Test public void getResponseIgnoreCache() { HttpRequest request = new HttpRequest(DEFAULT_URI); String key = cache.createKey(request); HttpResponse response = new HttpResponse("result"); cache.map.put(key, response); request.setIgnoreCache(true); assertNull("Did not return null when ignoreCache was true", cache.getResponse(request)); extendedStrictNoCacheTtlCache.map.put(key, response); assertNull("Did not return null when ignoreCache was true", extendedStrictNoCacheTtlCache.getResponse(request)); }
@Test public void addResponseIgnoreCache() { HttpRequest request = new HttpRequest(DEFAULT_URI) .setIgnoreCache(true); HttpResponse response = new HttpResponse("does not matter"); assertNull("response should not have been cached", cache.addResponse(request, response)); assertEquals(0, cache.map.size()); assertNull("response should not have been cached", extendedStrictNoCacheTtlCache.addResponse(request, response)); assertEquals(0, extendedStrictNoCacheTtlCache.map.size()); }
@Test public void addResponseIgnoreCache() { HttpRequest request = new HttpRequest(DEFAULT_URI) .setIgnoreCache(true); HttpResponse response = new HttpResponse("does not matter"); assertNull("response should not have been cached", cache.addResponse(request, response)); assertEquals(0, cache.map.size()); assertNull("response should not have been cached", extendedStrictNoCacheTtlCache.addResponse(request, response)); assertEquals(0, extendedStrictNoCacheTtlCache.map.size()); }
@Test public void testNoCache() throws Exception { String url = "http://example.org/file.evil"; String domain = "example.org"; setupProxyRequestMock(domain, url, true, -1, null, null); HttpRequest req = new HttpRequest(Uri.parse(url)).setIgnoreCache(true); HttpResponse resp = new HttpResponse("Hello"); expect(pipeline.execute(req)).andReturn(resp); replay(); proxyHandler.fetch(request); verify(); }
@Test public void testWithBadTtl() throws Exception { String url = "http://example.org/file.evil"; String domain = "example.org"; setupProxyRequestMock(domain, url, false, -1, null, null); HttpRequest req = new HttpRequestCache(Uri.parse(url)).setCacheTtl(-1).setIgnoreCache(false); HttpResponse resp = new HttpResponse("Hello"); expect(pipeline.execute(req)).andReturn(resp); replay(); proxyHandler.fetch(request); verify(); }
@Test public void testWithCache() throws Exception { String url = "http://example.org/file.evil"; String domain = "example.org"; setupProxyRequestMock(domain, url, false, 120, null, null); HttpRequest req = new HttpRequestCache(Uri.parse(url)).setCacheTtl(120).setIgnoreCache(false); HttpResponse resp = new HttpResponse("Hello"); expect(pipeline.execute(req)).andReturn(resp); replay(); proxyHandler.fetch(request); verify(); }
public static HttpRequest newHttpRequest(GadgetContext context, RequestAuthenticationInfo authenticationInfo) throws GadgetException { return new HttpRequest(authenticationInfo.getHref()) .setSecurityToken(context.getToken()) .setOAuthArguments(new OAuthArguments(authenticationInfo)) .setAuthType(authenticationInfo.getAuthType()) .setContainer(context.getContainer()) .setGadget(context.getUrl()) .setIgnoreCache(context.getIgnoreCache()); }
public static HttpRequest newHttpRequest(GadgetContext context, RequestAuthenticationInfo authenticationInfo) throws GadgetException { return new HttpRequest(authenticationInfo.getHref()) .setSecurityToken(context.getToken()) .setOAuthArguments(new OAuthArguments(authenticationInfo)) .setAuthType(authenticationInfo.getAuthType()) .setContainer(context.getContainer()) .setGadget(context.getUrl()) .setIgnoreCache(context.getIgnoreCache()); }
public static HttpRequest newHttpRequest(GadgetContext context, RequestAuthenticationInfo authenticationInfo) throws GadgetException { return new HttpRequest(authenticationInfo.getHref()) .setSecurityToken(context.getToken()) .setOAuthArguments(new OAuthArguments(authenticationInfo)) .setOAuth2Arguments(new OAuth2Arguments(authenticationInfo)) .setAuthType(authenticationInfo.getAuthType()) .setContainer(context.getContainer()) .setGadget(context.getUrl()) .setIgnoreCache(context.getIgnoreCache()); }
/** * Send an OAuth GET request to the given URL. */ public HttpResponse sendGet(String target) throws Exception { HttpRequest request = new HttpRequest(Uri.parse(target)); request.setOAuthArguments(recallState()); OAuthRequest dest = createRequest(); request.setIgnoreCache(ignoreCache); request.setSecurityToken(securityToken); HttpResponse response = dest.fetch(request); saveState(response); return response; }
@Test public void authTypeNoneIgnoreCache() throws Exception { HttpRequest request = new HttpRequest(DEFAULT_URI).setAuthType(AuthType.NONE).setIgnoreCache( true); HttpResponse fetched = new HttpResponse("fetched"); fetcher.response = fetched; HttpResponse response = pipeline.execute(request); assertEquals(fetched, response); assertEquals(request, fetcher.request); assertEquals(0, cache.readCount); assertEquals(0, cache.writeCount); assertEquals(1, fetcher.fetchCount); }