From aa81865776f4d664b829981071fbd9fd83203d6f Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Thu, 19 Oct 2017 20:07:49 +0200 Subject: [PATCH] HTTPCLIENT-1855: Removed code causing unnecessary auth cache updated; Reverted 7e44b96 --- .../client/protocol/RequestAuthCache.java | 7 ----- .../client/protocol/TestRequestAuthCache.java | 27 ------------------- 2 files changed, 34 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java index 7bf37e6b8..ab6851581 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java @@ -44,7 +44,6 @@ import org.apache.http.auth.AuthState; import org.apache.http.auth.Credentials; import org.apache.http.client.AuthCache; import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.config.AuthSchemes; import org.apache.http.conn.routing.RouteInfo; import org.apache.http.protocol.HttpContext; import org.apache.http.util.Args; @@ -136,12 +135,6 @@ public class RequestAuthCache implements HttpRequestInterceptor { final Credentials creds = credsProvider.getCredentials(authScope); if (creds != null) { - if (AuthSchemes.BASIC.equalsIgnoreCase(authScheme.getSchemeName()) - || AuthSchemes.DIGEST.equalsIgnoreCase(authScheme.getSchemeName())) { - authState.setState(AuthProtocolState.CHALLENGED); - } else { - authState.setState(AuthProtocolState.SUCCESS); - } authState.update(authScheme, creds); } else { this.log.debug("No credentials for preemptive authentication"); diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java index 1c0d32399..3f0d8e958 100644 --- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java +++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java @@ -123,33 +123,6 @@ public class TestRequestAuthCache { Assert.assertSame(this.creds2, this.proxyState.getCredentials()); } - @Test - public void testPreemptiveTargetAndProxyAuthDigest() throws Exception { - final HttpRequest request = new BasicHttpRequest("GET", "/"); - - final HttpClientContext context = HttpClientContext.create(); - context.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credProvider); - context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target); - context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false)); - context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState); - context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState); - - final AuthCache authCache = new BasicAuthCache(); - authCache.put(this.target, this.digestAuthscheme1); - authCache.put(this.proxy, this.digestAuthscheme2); - - context.setAttribute(HttpClientContext.AUTH_CACHE, authCache); - - final HttpRequestInterceptor interceptor = new RequestAuthCache(); - interceptor.process(request, context); - Assert.assertNotNull(this.targetState.getAuthScheme()); - Assert.assertSame(this.targetState.getState(), AuthProtocolState.CHALLENGED); - Assert.assertSame(this.creds1, this.targetState.getCredentials()); - Assert.assertNotNull(this.proxyState.getAuthScheme()); - Assert.assertSame(this.proxyState.getState(), AuthProtocolState.CHALLENGED); - Assert.assertSame(this.creds2, this.proxyState.getCredentials()); - } - @Test public void testCredentialsProviderNotSet() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/");