HTTPCLIENT-1855: Removed code causing unnecessary auth cache updated; Reverted 7e44b96

This commit is contained in:
Oleg Kalnichevski 2017-10-19 20:07:49 +02:00
parent cfbbea0ee3
commit aa81865776
2 changed files with 0 additions and 34 deletions

View File

@ -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");

View File

@ -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", "/");