From 9af4707556a6d90e8dcc1ef6fb4ff55e63173e35 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Sat, 2 Feb 2019 18:56:58 +0100 Subject: [PATCH] Issue #3234 - AuthenticationProtocolHandler should not cache the failed results. Fixed failing test. Signed-off-by: Simone Bordet --- .../eclipse/jetty/client/util/BasicAuthentication.java | 3 ++- .../org/eclipse/jetty/client/HttpClientProxyTest.java | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/util/BasicAuthentication.java b/jetty-client/src/main/java/org/eclipse/jetty/client/util/BasicAuthentication.java index 4d8c2680f6a..50a2bdc344b 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/util/BasicAuthentication.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/util/BasicAuthentication.java @@ -103,7 +103,8 @@ public class BasicAuthentication extends AbstractAuthentication @Override public void apply(Request request) { - request.header(header, value); + if (!request.getHeaders().contains(header, value)) + request.header(header, value); } @Override diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyTest.java index f46d58d330e..f28893ca4e8 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientProxyTest.java @@ -18,8 +18,6 @@ package org.eclipse.jetty.client; -import static org.junit.jupiter.api.Assertions.assertEquals; - import java.io.IOException; import java.net.URI; import java.nio.charset.StandardCharsets; @@ -41,6 +39,8 @@ import org.eclipse.jetty.util.B64Code; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ArgumentsSource; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class HttpClientProxyTest extends AbstractHttpClientServerTest { @ParameterizedTest @@ -315,7 +315,7 @@ public class HttpClientProxyTest extends AbstractHttpClientServerTest assertEquals(status, response1.getStatus()); assertEquals(3, requests.get()); - // Make again the request, authentication is cached, expect 204. + // Make again the request, only the server authentication is cached, expect 407 + 204. requests.set(0); ContentResponse response2 = client.newRequest(serverHost, serverPort) .scheme(scenario.getScheme()) @@ -323,7 +323,7 @@ public class HttpClientProxyTest extends AbstractHttpClientServerTest .send(); assertEquals(status, response2.getStatus()); - assertEquals(1, requests.get()); + assertEquals(2, requests.get()); } @ParameterizedTest