From b1f2b6825a2d3c241d9b89ae13b9842628e4ef56 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Tue, 11 Aug 2015 11:27:04 +0000 Subject: [PATCH] Properly name instance and method variables of AuthExchange git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1695265 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/impl/auth/HttpAuthenticator.java | 50 +++--- .../impl/client/DefaultUserTokenHandler.java | 4 +- .../http/impl/auth/TestHttpAuthenticator.java | 148 +++++++++--------- 3 files changed, 101 insertions(+), 101 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java b/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java index 1ef9c09c4..1fbacd561 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java @@ -86,7 +86,7 @@ public boolean isChallenged( final HttpHost host, final ChallengeType challengeType, final HttpResponse response, - final AuthExchange authState, + final AuthExchange authExchange, final HttpContext context) { final int challengeCode; switch (challengeType) { @@ -104,22 +104,22 @@ public boolean isChallenged( if (response.getStatusLine().getStatusCode() == challengeCode) { this.log.debug("Authentication required"); - if (authState.getState() == AuthExchange.State.SUCCESS) { + if (authExchange.getState() == AuthExchange.State.SUCCESS) { clearCache(host, clientContext); } return true; } else { - switch (authState.getState()) { + switch (authExchange.getState()) { case CHALLENGED: case HANDSHAKE: this.log.debug("Authentication succeeded"); - authState.setState(AuthExchange.State.SUCCESS); - updateCache(host, authState.getAuthScheme(), clientContext); + authExchange.setState(AuthExchange.State.SUCCESS); + updateCache(host, authExchange.getAuthScheme(), clientContext); break; case SUCCESS: break; default: - authState.setState(AuthExchange.State.UNCHALLENGED); + authExchange.setState(AuthExchange.State.UNCHALLENGED); } return false; } @@ -130,7 +130,7 @@ public boolean prepareAuthResponse( final ChallengeType challengeType, final HttpResponse response, final AuthenticationStrategy authStrategy, - final AuthExchange authState, + final AuthExchange authExchange, final HttpContext context) { if (this.log.isDebugEnabled()) { @@ -177,21 +177,21 @@ public boolean prepareAuthResponse( if (challengeMap.isEmpty()) { this.log.debug("Response contains no valid authentication challenges"); clearCache(host, clientContext); - authState.reset(); + authExchange.reset(); return false; } - switch (authState.getState()) { + switch (authExchange.getState()) { case FAILURE: return false; case SUCCESS: - authState.reset(); + authExchange.reset(); break; case CHALLENGED: case HANDSHAKE: - Asserts.notNull(authState.getAuthScheme(), "AuthScheme"); + Asserts.notNull(authExchange.getAuthScheme(), "AuthScheme"); case UNCHALLENGED: - final AuthScheme authScheme = authState.getAuthScheme(); + final AuthScheme authScheme = authExchange.getAuthScheme(); if (authScheme != null) { final String id = authScheme.getName(); final AuthChallenge challenge = challengeMap.get(id.toLowerCase(Locale.ROOT)); @@ -204,21 +204,21 @@ public boolean prepareAuthResponse( this.log.warn(ex.getMessage()); } clearCache(host, clientContext); - authState.reset(); + authExchange.reset(); return false; } if (authScheme.isChallengeComplete()) { this.log.debug("Authentication failed"); clearCache(host, clientContext); - authState.reset(); - authState.setState(AuthExchange.State.FAILURE); + authExchange.reset(); + authExchange.setState(AuthExchange.State.FAILURE); return false; } else { - authState.setState(AuthExchange.State.HANDSHAKE); + authExchange.setState(AuthExchange.State.HANDSHAKE); return true; } } else { - authState.reset(); + authExchange.reset(); // Retry authentication with a different scheme } } @@ -250,9 +250,9 @@ public boolean prepareAuthResponse( if (this.log.isDebugEnabled()) { this.log.debug("Selected authentication options: " + authOptions); } - authState.reset(); - authState.setState(AuthExchange.State.CHALLENGED); - authState.setOptions(authOptions); + authExchange.reset(); + authExchange.setState(AuthExchange.State.CHALLENGED); + authExchange.setOptions(authOptions); return true; } else { return false; @@ -263,10 +263,10 @@ public void addAuthResponse( final HttpHost host, final ChallengeType challengeType, final HttpRequest request, - final AuthExchange authState, + final AuthExchange authExchange, final HttpContext context) throws HttpException, IOException { - AuthScheme authScheme = authState.getAuthScheme(); - switch (authState.getState()) { + AuthScheme authScheme = authExchange.getAuthScheme(); + switch (authExchange.getState()) { case FAILURE: return; case SUCCESS: @@ -279,11 +279,11 @@ public void addAuthResponse( Asserts.notNull(authScheme, "AuthScheme"); break; case CHALLENGED: - final Queue authOptions = authState.getAuthOptions(); + final Queue authOptions = authExchange.getAuthOptions(); if (authOptions != null) { while (!authOptions.isEmpty()) { authScheme = authOptions.remove(); - authState.select(authScheme); + authExchange.select(authScheme); if (this.log.isDebugEnabled()) { this.log.debug("Generating response to an authentication challenge using " + authScheme.getName() + " scheme"); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java index b5ff02cb3..ee6e1e6c4 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java @@ -88,8 +88,8 @@ public Object getUserToken(final HttpRoute route, final HttpContext context) { return userPrincipal; } - private static Principal getAuthPrincipal(final AuthExchange authState) { - final AuthScheme scheme = authState.getAuthScheme(); + private static Principal getAuthPrincipal(final AuthExchange authExchange) { + final AuthScheme scheme = authExchange.getAuthScheme(); if (scheme != null && scheme.isConnectionBased()) { return scheme.getPrincipal(); } diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java index cb5f374d2..7a1632390 100644 --- a/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java +++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java @@ -63,7 +63,7 @@ @SuppressWarnings({"boxing","static-access"}) public class TestHttpAuthenticator { - private AuthExchange authState; + private AuthExchange authExchange; private AuthScheme authScheme; private HttpContext context; private HttpHost defaultHost; @@ -74,7 +74,7 @@ public class TestHttpAuthenticator { @Before public void setUp() throws Exception { - this.authState = new AuthExchange(); + this.authExchange = new AuthExchange(); this.authScheme = Mockito.mock(AuthScheme.class); Mockito.when(this.authScheme.getName()).thenReturn("Basic"); Mockito.when(this.authScheme.isChallengeComplete()).thenReturn(Boolean.TRUE); @@ -94,11 +94,11 @@ public void setUp() throws Exception { } @Test - public void testUpdateAuthState() throws Exception { + public void testUpdateAuthExchange() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.setHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=test"); Assert.assertTrue(this.httpAuthenticator.isChallenged( - this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context)); + this.defaultHost, ChallengeType.TARGET, response, this.authExchange, this.context)); Mockito.verifyZeroInteractions(this.authCache); } @@ -107,11 +107,11 @@ public void testAuthenticationRequestedAfterSuccess() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.setHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=test"); - this.authState.select(this.authScheme); - this.authState.setState(AuthExchange.State.SUCCESS); + this.authExchange.select(this.authScheme); + this.authExchange.setState(AuthExchange.State.SUCCESS); Assert.assertTrue(this.httpAuthenticator.isChallenged( - this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context)); + this.defaultHost, ChallengeType.TARGET, response, this.authExchange, this.context)); Mockito.verify(this.authCache).remove(this.defaultHost); } @@ -121,19 +121,19 @@ public void testAuthenticationNotRequestedUnchallenged() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"); Assert.assertFalse(this.httpAuthenticator.isChallenged( - this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context)); - Assert.assertEquals(AuthExchange.State.UNCHALLENGED, this.authState.getState()); + this.defaultHost, ChallengeType.TARGET, response, this.authExchange, this.context)); + Assert.assertEquals(AuthExchange.State.UNCHALLENGED, this.authExchange.getState()); } @Test public void testAuthenticationNotRequestedSuccess1() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"); - this.authState.select(this.authScheme); - this.authState.setState(AuthExchange.State.CHALLENGED); + this.authExchange.select(this.authScheme); + this.authExchange.setState(AuthExchange.State.CHALLENGED); Assert.assertFalse(this.httpAuthenticator.isChallenged( - this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context)); - Assert.assertEquals(AuthExchange.State.SUCCESS, this.authState.getState()); + this.defaultHost, ChallengeType.TARGET, response, this.authExchange, this.context)); + Assert.assertEquals(AuthExchange.State.SUCCESS, this.authExchange.getState()); Mockito.verify(this.authCache).put(this.defaultHost, this.authScheme); } @@ -141,12 +141,12 @@ public void testAuthenticationNotRequestedSuccess1() throws Exception { @Test public void testAuthenticationNotRequestedSuccess2() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"); - this.authState.select(this.authScheme); - this.authState.setState(AuthExchange.State.HANDSHAKE); + this.authExchange.select(this.authScheme); + this.authExchange.setState(AuthExchange.State.HANDSHAKE); Assert.assertFalse(this.httpAuthenticator.isChallenged( - this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context)); - Assert.assertEquals(AuthExchange.State.SUCCESS, this.authState.getState()); + this.defaultHost, ChallengeType.TARGET, response, this.authExchange, this.context)); + Assert.assertEquals(AuthExchange.State.SUCCESS, this.authExchange.getState()); Mockito.verify(this.authCache).put(this.defaultHost, this.authScheme); } @@ -165,10 +165,10 @@ public void testAuthentication() throws Exception { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); Assert.assertTrue(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); - Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authState.getState()); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); + Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authExchange.getState()); - final Queue options = this.authState.getAuthOptions(); + final Queue options = this.authExchange.getAuthOptions(); Assert.assertNotNull(options); final AuthScheme authScheme1 = options.poll(); Assert.assertNotNull(authScheme1); @@ -192,10 +192,10 @@ public void testAuthenticationCredentialsForBasic() throws Exception { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); Assert.assertTrue(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); - Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authState.getState()); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); + Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authExchange.getState()); - final Queue options = this.authState.getAuthOptions(); + final Queue options = this.authExchange.getAuthOptions(); Assert.assertNotNull(options); final AuthScheme authScheme1 = options.poll(); Assert.assertNotNull(authScheme1); @@ -211,7 +211,7 @@ public void testAuthenticationNoChallenges() throws Exception { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); } @Test @@ -224,7 +224,7 @@ public void testAuthenticationNoSupportedChallenges() throws Exception { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); } @Test @@ -237,7 +237,7 @@ public void testAuthenticationNoCredentials() throws Exception { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); } @Test @@ -247,15 +247,15 @@ public void testAuthenticationFailed() throws Exception { response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\"")); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\"")); - this.authState.setState(AuthExchange.State.CHALLENGED); - this.authState.select(this.authScheme); + this.authExchange.setState(AuthExchange.State.CHALLENGED); + this.authExchange.select(this.authScheme); final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); - Assert.assertEquals(AuthExchange.State.FAILURE, this.authState.getState()); + Assert.assertEquals(AuthExchange.State.FAILURE, this.authExchange.getState()); Mockito.verify(this.authCache).remove(host); } @@ -267,14 +267,14 @@ public void testAuthenticationFailedPreviously() throws Exception { response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\"")); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\"")); - this.authState.setState(AuthExchange.State.FAILURE); + this.authExchange.setState(AuthExchange.State.FAILURE); final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); - Assert.assertEquals(AuthExchange.State.FAILURE, this.authState.getState()); + Assert.assertEquals(AuthExchange.State.FAILURE, this.authExchange.getState()); } @Test @@ -287,12 +287,12 @@ public void testAuthenticationFailure() throws Exception { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); - this.authState.setState(AuthExchange.State.CHALLENGED); - this.authState.select(new BasicScheme()); + this.authExchange.setState(AuthExchange.State.CHALLENGED); + this.authExchange.select(new BasicScheme()); Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); - Assert.assertEquals(AuthExchange.State.FAILURE, this.authState.getState()); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); + Assert.assertEquals(AuthExchange.State.FAILURE, this.authExchange.getState()); } @Test @@ -305,13 +305,13 @@ public void testAuthenticationHandshaking() throws Exception { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); - this.authState.setState(AuthExchange.State.CHALLENGED); - this.authState.select(new DigestScheme()); + this.authExchange.setState(AuthExchange.State.CHALLENGED); + this.authExchange.select(new DigestScheme()); Assert.assertTrue(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); - Assert.assertEquals(AuthExchange.State.HANDSHAKE, this.authState.getState()); + Assert.assertEquals(AuthExchange.State.HANDSHAKE, this.authExchange.getState()); } @Test @@ -326,14 +326,14 @@ public void testAuthenticationNoMatchingChallenge() throws Exception { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); - this.authState.setState(AuthExchange.State.CHALLENGED); - this.authState.select(new BasicScheme()); + this.authExchange.setState(AuthExchange.State.CHALLENGED); + this.authExchange.select(new BasicScheme()); Assert.assertTrue(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); - Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authState.getState()); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); + Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authExchange.getState()); - final Queue options = this.authState.getAuthOptions(); + final Queue options = this.authExchange.getAuthOptions(); Assert.assertNotNull(options); final AuthScheme authScheme1 = options.poll(); Assert.assertNotNull(authScheme1); @@ -347,24 +347,24 @@ public void testAuthenticationException() throws Exception { final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "blah blah blah")); - this.authState.setState(AuthExchange.State.CHALLENGED); + this.authExchange.setState(AuthExchange.State.CHALLENGED); final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse( - host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context)); + host, ChallengeType.TARGET, response, authStrategy, this.authExchange, this.context)); - Assert.assertEquals(AuthExchange.State.UNCHALLENGED, this.authState.getState()); - Assert.assertNull(this.authState.getAuthScheme()); + Assert.assertEquals(AuthExchange.State.UNCHALLENGED, this.authExchange.getState()); + Assert.assertNull(this.authExchange.getAuthScheme()); } @Test public void testAuthFailureState() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); - this.authState.setState(AuthExchange.State.FAILURE); - this.authState.select(this.authScheme); + this.authExchange.setState(AuthExchange.State.FAILURE); + this.authExchange.select(this.authScheme); - this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authState, context); + this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authExchange, context); Assert.assertFalse(request.containsHeader(HttpHeaders.AUTHORIZATION)); @@ -377,15 +377,15 @@ public void testAuthFailureState() throws Exception { @Test public void testAuthChallengeStateNoOption() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); - this.authState.setState(AuthExchange.State.CHALLENGED); - this.authState.select(this.authScheme); + this.authExchange.setState(AuthExchange.State.CHALLENGED); + this.authExchange.select(this.authScheme); Mockito.when(this.authScheme.generateAuthResponse( Mockito.eq(defaultHost), Mockito.any(HttpRequest.class), Mockito.any(HttpContext.class))).thenReturn("stuff"); - this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authState, context); + this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authExchange, context); Assert.assertTrue(request.containsHeader(HttpHeaders.AUTHORIZATION)); } @@ -393,20 +393,20 @@ public void testAuthChallengeStateNoOption() throws Exception { @Test public void testAuthChallengeStateOneOptions() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); - this.authState.setState(AuthExchange.State.CHALLENGED); + this.authExchange.setState(AuthExchange.State.CHALLENGED); final LinkedList authOptions = new LinkedList<>(); authOptions.add(this.authScheme); - this.authState.setOptions(authOptions); + this.authExchange.setOptions(authOptions); Mockito.when(this.authScheme.generateAuthResponse( Mockito.eq(defaultHost), Mockito.any(HttpRequest.class), Mockito.any(HttpContext.class))).thenReturn("stuff"); - this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authState, context); + this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authExchange, context); - Assert.assertSame(this.authScheme, this.authState.getAuthScheme()); - Assert.assertNull(this.authState.getAuthOptions()); + Assert.assertSame(this.authScheme, this.authExchange.getAuthScheme()); + Assert.assertNull(this.authExchange.getAuthOptions()); Assert.assertTrue(request.containsHeader(HttpHeaders.AUTHORIZATION)); } @@ -414,7 +414,7 @@ public void testAuthChallengeStateOneOptions() throws Exception { @Test public void testAuthChallengeStateMultipleOption() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); - this.authState.setState(AuthExchange.State.CHALLENGED); + this.authExchange.setState(AuthExchange.State.CHALLENGED); final LinkedList authOptions = new LinkedList<>(); final AuthScheme authScheme1 = Mockito.mock(AuthScheme.class); @@ -429,12 +429,12 @@ public void testAuthChallengeStateMultipleOption() throws Exception { Mockito.any(HttpContext.class))).thenReturn("stuff"); authOptions.add(authScheme1); authOptions.add(authScheme2); - this.authState.setOptions(authOptions); + this.authExchange.setOptions(authOptions); - this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authState, context); + this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authExchange, context); - Assert.assertSame(authScheme2, this.authState.getAuthScheme()); - Assert.assertNull(this.authState.getAuthOptions()); + Assert.assertSame(authScheme2, this.authExchange.getAuthScheme()); + Assert.assertNull(this.authExchange.getAuthOptions()); Assert.assertTrue(request.containsHeader(HttpHeaders.AUTHORIZATION)); } @@ -442,8 +442,8 @@ public void testAuthChallengeStateMultipleOption() throws Exception { @Test public void testAuthSuccess() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); - this.authState.setState(AuthExchange.State.SUCCESS); - this.authState.select(this.authScheme); + this.authExchange.setState(AuthExchange.State.SUCCESS); + this.authExchange.select(this.authScheme); Mockito.when(this.authScheme.isConnectionBased()).thenReturn(Boolean.FALSE); Mockito.when(this.authScheme.generateAuthResponse( @@ -451,10 +451,10 @@ public void testAuthSuccess() throws Exception { Mockito.any(HttpRequest.class), Mockito.any(HttpContext.class))).thenReturn("stuff"); - this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authState, context); + this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authExchange, context); - Assert.assertSame(this.authScheme, this.authState.getAuthScheme()); - Assert.assertNull(this.authState.getAuthOptions()); + Assert.assertSame(this.authScheme, this.authExchange.getAuthScheme()); + Assert.assertNull(this.authExchange.getAuthOptions()); Assert.assertTrue(request.containsHeader(HttpHeaders.AUTHORIZATION)); } @@ -462,8 +462,8 @@ public void testAuthSuccess() throws Exception { @Test public void testAuthSuccessConnectionBased() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); - this.authState.setState(AuthExchange.State.SUCCESS); - this.authState.select(this.authScheme); + this.authExchange.setState(AuthExchange.State.SUCCESS); + this.authExchange.select(this.authScheme); Mockito.when(this.authScheme.isConnectionBased()).thenReturn(Boolean.TRUE); Mockito.when(this.authScheme.generateAuthResponse( @@ -471,7 +471,7 @@ public void testAuthSuccessConnectionBased() throws Exception { Mockito.any(HttpRequest.class), Mockito.any(HttpContext.class))).thenReturn("stuff"); - this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authState, context); + this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authExchange, context); Assert.assertFalse(request.containsHeader(HttpHeaders.AUTHORIZATION));