Code cleanups.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
6fee10d537
commit
66873e8637
|
@ -18,13 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.client;
|
package org.eclipse.jetty.client;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalToIgnoringCase;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -38,7 +31,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@ -74,6 +67,13 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.equalToIgnoringCase;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
{
|
{
|
||||||
private String realm = "TestRealm";
|
private String realm = "TestRealm";
|
||||||
|
@ -232,7 +232,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
private final AtomicInteger requests = new AtomicInteger();
|
private final AtomicInteger requests = new AtomicInteger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||||
{
|
{
|
||||||
baseRequest.setHandled(true);
|
baseRequest.setHandled(true);
|
||||||
if (requests.incrementAndGet() == 1)
|
if (requests.incrementAndGet() == 1)
|
||||||
|
@ -272,7 +272,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
startBasic(scenario, new AbstractHandler()
|
startBasic(scenario, new AbstractHandler()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||||
{
|
{
|
||||||
baseRequest.setHandled(true);
|
baseRequest.setHandled(true);
|
||||||
if (request.getRequestURI().endsWith("/redirect"))
|
if (request.getRequestURI().endsWith("/redirect"))
|
||||||
|
@ -401,15 +401,11 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
.scheme(scenario.getScheme())
|
.scheme(scenario.getScheme())
|
||||||
.path("/secure")
|
.path("/secure")
|
||||||
.timeout(5, TimeUnit.SECONDS)
|
.timeout(5, TimeUnit.SECONDS)
|
||||||
.send(new Response.CompleteListener()
|
.send(result ->
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onComplete(Result result)
|
|
||||||
{
|
{
|
||||||
assertTrue(result.isFailed());
|
assertTrue(result.isFailed());
|
||||||
assertEquals(cause, result.getFailure().getMessage());
|
assertEquals(cause, result.getFailure().getMessage());
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
assertTrue(latch.await(5, TimeUnit.SECONDS));
|
assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||||
|
@ -480,7 +476,6 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
assertTrue(resultLatch.await(5, TimeUnit.SECONDS));
|
assertTrue(resultLatch.await(5, TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(ScenarioProvider.class)
|
@ArgumentsSource(ScenarioProvider.class)
|
||||||
public void test_RequestFailsAfterResponse(Scenario scenario) throws Exception
|
public void test_RequestFailsAfterResponse(Scenario scenario) throws Exception
|
||||||
|
@ -488,8 +483,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
startBasic(scenario, new EmptyServerHandler()
|
startBasic(scenario, new EmptyServerHandler()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void service(String target, org.eclipse.jetty.server.Request jettyRequest, HttpServletRequest request,
|
protected void service(String target, org.eclipse.jetty.server.Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||||
HttpServletResponse response) throws IOException, ServletException
|
|
||||||
{
|
{
|
||||||
IO.readBytes(jettyRequest.getInputStream());
|
IO.readBytes(jettyRequest.getInputStream());
|
||||||
}
|
}
|
||||||
|
@ -543,8 +537,9 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
{
|
{
|
||||||
authLatch.await();
|
authLatch.await();
|
||||||
}
|
}
|
||||||
catch(InterruptedException e)
|
catch(InterruptedException ignored)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Trigger request failure.
|
// Trigger request failure.
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
|
@ -636,28 +631,27 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
|
|
||||||
HeaderInfo headerInfo = aph.getHeaderInfo("Digest realm=\"thermostat\", qop=\"auth\", nonce=\"1523430383\"").get(0);
|
HeaderInfo headerInfo = aph.getHeaderInfo("Digest realm=\"thermostat\", qop=\"auth\", nonce=\"1523430383\"").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfo.getParameter("qop").equals("auth"));
|
assertEquals("auth", headerInfo.getParameter("qop"));
|
||||||
assertTrue(headerInfo.getParameter("realm").equals("thermostat"));
|
assertEquals("thermostat", headerInfo.getParameter("realm"));
|
||||||
assertTrue(headerInfo.getParameter("nonce").equals("1523430383"));
|
assertEquals("1523430383", headerInfo.getParameter("nonce"));
|
||||||
|
|
||||||
headerInfo = aph.getHeaderInfo("Digest qop=\"auth\", realm=\"thermostat\", nonce=\"1523430383\"").get(0);
|
headerInfo = aph.getHeaderInfo("Digest qop=\"auth\", realm=\"thermostat\", nonce=\"1523430383\"").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfo.getParameter("qop").equals("auth"));
|
assertEquals("auth", headerInfo.getParameter("qop"));
|
||||||
assertTrue(headerInfo.getParameter("realm").equals("thermostat"));
|
assertEquals("thermostat", headerInfo.getParameter("realm"));
|
||||||
assertTrue(headerInfo.getParameter("nonce").equals("1523430383"));
|
assertEquals("1523430383", headerInfo.getParameter("nonce"));
|
||||||
|
|
||||||
headerInfo = aph.getHeaderInfo("Digest qop=\"auth\", nonce=\"1523430383\", realm=\"thermostat\"").get(0);
|
headerInfo = aph.getHeaderInfo("Digest qop=\"auth\", nonce=\"1523430383\", realm=\"thermostat\"").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfo.getParameter("qop").equals("auth"));
|
assertEquals("auth", headerInfo.getParameter("qop"));
|
||||||
assertTrue(headerInfo.getParameter("realm").equals("thermostat"));
|
assertEquals("thermostat", headerInfo.getParameter("realm"));
|
||||||
assertTrue(headerInfo.getParameter("nonce").equals("1523430383"));
|
assertEquals("1523430383", headerInfo.getParameter("nonce"));
|
||||||
|
|
||||||
headerInfo = aph.getHeaderInfo("Digest qop=\"auth\", nonce=\"1523430383\"").get(0);
|
headerInfo = aph.getHeaderInfo("Digest qop=\"auth\", nonce=\"1523430383\"").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfo.getParameter("qop").equals("auth"));
|
assertEquals("auth", headerInfo.getParameter("qop"));
|
||||||
assertTrue(headerInfo.getParameter("realm") == null);
|
assertNull(headerInfo.getParameter("realm"));
|
||||||
assertTrue(headerInfo.getParameter("nonce").equals("1523430383"));
|
assertEquals("1523430383", headerInfo.getParameter("nonce"));
|
||||||
|
|
||||||
|
|
||||||
// test multiple authentications
|
// test multiple authentications
|
||||||
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest qop=\"auth\", realm=\"thermostat\", nonce=\"1523430383\", "
|
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest qop=\"auth\", realm=\"thermostat\", nonce=\"1523430383\", "
|
||||||
|
@ -666,34 +660,34 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
+ "Digest qop=\"auth4\", nonce=\"3526435321\"");
|
+ "Digest qop=\"auth4\", nonce=\"3526435321\"");
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(0).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(0).getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfoList.get(0).getParameter("qop").equals("auth"));
|
assertEquals("auth", headerInfoList.get(0).getParameter("qop"));
|
||||||
assertTrue(headerInfoList.get(0).getParameter("realm").equals("thermostat"));
|
assertEquals("thermostat", headerInfoList.get(0).getParameter("realm"));
|
||||||
assertTrue(headerInfoList.get(0).getParameter("nonce").equals("1523430383"));
|
assertEquals("1523430383", headerInfoList.get(0).getParameter("nonce"));
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(1).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(1).getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfoList.get(1).getParameter("qop").equals("auth2"));
|
assertEquals("auth2", headerInfoList.get(1).getParameter("qop"));
|
||||||
assertTrue(headerInfoList.get(1).getParameter("realm").equals("thermostat2"));
|
assertEquals("thermostat2", headerInfoList.get(1).getParameter("realm"));
|
||||||
assertTrue(headerInfoList.get(1).getParameter("nonce").equals("4522530354"));
|
assertEquals("4522530354", headerInfoList.get(1).getParameter("nonce"));
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(2).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(2).getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfoList.get(2).getParameter("qop").equals("auth3"));
|
assertEquals("auth3", headerInfoList.get(2).getParameter("qop"));
|
||||||
assertTrue(headerInfoList.get(2).getParameter("realm").equals("thermostat3"));
|
assertEquals("thermostat3", headerInfoList.get(2).getParameter("realm"));
|
||||||
assertTrue(headerInfoList.get(2).getParameter("nonce").equals("9523570528"));
|
assertEquals("9523570528", headerInfoList.get(2).getParameter("nonce"));
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(3).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(3).getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfoList.get(3).getParameter("qop").equals("auth4"));
|
assertEquals("auth4", headerInfoList.get(3).getParameter("qop"));
|
||||||
assertTrue(headerInfoList.get(3).getParameter("realm") == null);
|
assertNull(headerInfoList.get(3).getParameter("realm"));
|
||||||
assertTrue(headerInfoList.get(3).getParameter("nonce").equals("3526435321"));
|
assertEquals("3526435321", headerInfoList.get(3).getParameter("nonce"));
|
||||||
|
|
||||||
List<HeaderInfo> headerInfos = aph.getHeaderInfo("Newauth realm=\"apps\", type=1, title=\"Login to \\\"apps\\\"\", Basic realm=\"simple\"");
|
List<HeaderInfo> headerInfos = aph.getHeaderInfo("Newauth realm=\"apps\", type=1, title=\"Login to \\\"apps\\\"\", Basic realm=\"simple\"");
|
||||||
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Newauth"));
|
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Newauth"));
|
||||||
assertTrue(headerInfos.get(0).getParameter("realm").equals("apps"));
|
assertEquals("apps", headerInfos.get(0).getParameter("realm"));
|
||||||
assertTrue(headerInfos.get(0).getParameter("type").equals("1"));
|
assertEquals("1", headerInfos.get(0).getParameter("type"));
|
||||||
|
|
||||||
assertEquals(headerInfos.get(0).getParameter("title"),"Login to \"apps\"");
|
assertEquals(headerInfos.get(0).getParameter("title"),"Login to \"apps\"");
|
||||||
|
|
||||||
assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Basic"));
|
assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Basic"));
|
||||||
assertTrue(headerInfos.get(1).getParameter("realm").equals("simple"));
|
assertEquals("simple", headerInfos.get(1).getParameter("realm"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -702,7 +696,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
|
|
||||||
HeaderInfo headerInfo = aph.getHeaderInfo("Scheme").get(0);
|
HeaderInfo headerInfo = aph.getHeaderInfo("Scheme").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Scheme"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Scheme"));
|
||||||
assertTrue(headerInfo.getParameter("realm") == null);
|
assertNull(headerInfo.getParameter("realm"));
|
||||||
|
|
||||||
List<HeaderInfo> headerInfos = aph.getHeaderInfo("Scheme1 , Scheme2 , Scheme3");
|
List<HeaderInfo> headerInfos = aph.getHeaderInfo("Scheme1 , Scheme2 , Scheme3");
|
||||||
assertEquals(3, headerInfos.size());
|
assertEquals(3, headerInfos.size());
|
||||||
|
@ -712,51 +706,49 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
|
|
||||||
headerInfo = aph.getHeaderInfo("Scheme name=\"value\", other=\"value2\"").get(0);
|
headerInfo = aph.getHeaderInfo("Scheme name=\"value\", other=\"value2\"").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Scheme"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Scheme"));
|
||||||
assertTrue(headerInfo.getParameter("name").equals("value"));
|
assertEquals("value", headerInfo.getParameter("name"));
|
||||||
assertTrue(headerInfo.getParameter("other").equals("value2"));
|
assertEquals("value2", headerInfo.getParameter("other"));
|
||||||
|
|
||||||
headerInfo = aph.getHeaderInfo("Scheme name = value , other = \"value2\" ").get(0);
|
headerInfo = aph.getHeaderInfo("Scheme name = value , other = \"value2\" ").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Scheme"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Scheme"));
|
||||||
assertTrue(headerInfo.getParameter("name").equals("value"));
|
assertEquals("value", headerInfo.getParameter("name"));
|
||||||
assertTrue(headerInfo.getParameter("other").equals("value2"));
|
assertEquals("value2", headerInfo.getParameter("other"));
|
||||||
|
|
||||||
headerInfos = aph.getHeaderInfo(", , , , ,,,Scheme name=value, ,,Scheme2 name=value2,, ,,");
|
headerInfos = aph.getHeaderInfo(", , , , ,,,Scheme name=value, ,,Scheme2 name=value2,, ,,");
|
||||||
assertEquals(headerInfos.size(), 2);
|
assertEquals(headerInfos.size(), 2);
|
||||||
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Scheme"));
|
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Scheme"));
|
||||||
assertTrue(headerInfos.get(0).getParameter("nAmE").equals("value"));
|
assertEquals("value", headerInfos.get(0).getParameter("nAmE"));
|
||||||
assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Scheme2"));
|
assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Scheme2"));
|
||||||
|
|
||||||
headerInfos = aph.getHeaderInfo("Scheme name=value, Scheme2 name=value2");
|
headerInfos = aph.getHeaderInfo("Scheme name=value, Scheme2 name=value2");
|
||||||
assertEquals(headerInfos.size(), 2);
|
assertEquals(headerInfos.size(), 2);
|
||||||
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Scheme"));
|
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Scheme"));
|
||||||
assertTrue(headerInfos.get(0).getParameter("nAmE").equals("value"));
|
assertEquals("value", headerInfos.get(0).getParameter("nAmE"));
|
||||||
assertThat(headerInfos.get(1).getType(), equalToIgnoringCase("Scheme2"));
|
assertThat(headerInfos.get(1).getType(), equalToIgnoringCase("Scheme2"));
|
||||||
|
|
||||||
assertTrue(headerInfos.get(1).getParameter("nAmE").equals("value2"));
|
assertEquals("value2", headerInfos.get(1).getParameter("nAmE"));
|
||||||
|
|
||||||
headerInfos = aph.getHeaderInfo("Scheme , ,, ,, name=value, Scheme2 name=value2");
|
headerInfos = aph.getHeaderInfo("Scheme , ,, ,, name=value, Scheme2 name=value2");
|
||||||
assertEquals(headerInfos.size(), 2);
|
assertEquals(headerInfos.size(), 2);
|
||||||
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Scheme"));
|
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Scheme"));
|
||||||
assertTrue(headerInfos.get(0).getParameter("name").equals("value"));
|
assertEquals("value", headerInfos.get(0).getParameter("name"));
|
||||||
assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Scheme2"));
|
assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Scheme2"));
|
||||||
assertTrue(headerInfos.get(1).getParameter("name").equals("value2"));
|
assertEquals("value2", headerInfos.get(1).getParameter("name"));
|
||||||
|
|
||||||
//Negotiate with base64 Content
|
//Negotiate with base64 Content
|
||||||
headerInfo = aph.getHeaderInfo("Negotiate TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAFAs4OAAAADw==").get(0);
|
headerInfo = aph.getHeaderInfo("Negotiate TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAFAs4OAAAADw==").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Negotiate"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Negotiate"));
|
||||||
assertTrue(headerInfo.getBase64().equals("TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAFAs4OAAAADw=="));
|
assertEquals("TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAFAs4OAAAADw==", headerInfo.getBase64());
|
||||||
|
|
||||||
headerInfos = aph.getHeaderInfo("Negotiate TlRMTVNTUAABAAAAAAAAAFAs4OAAAADw==, "
|
headerInfos = aph.getHeaderInfo("Negotiate TlRMTVNTUAABAAAAAAAAAFAs4OAAAADw==, "
|
||||||
+ "Negotiate YIIJvwYGKwYBBQUCoIIJszCCCa+gJDAi=");
|
+ "Negotiate YIIJvwYGKwYBBQUCoIIJszCCCa+gJDAi=");
|
||||||
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Negotiate"));
|
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Negotiate"));
|
||||||
assertTrue(headerInfos.get(0).getBase64().equals("TlRMTVNTUAABAAAAAAAAAFAs4OAAAADw=="));
|
assertEquals("TlRMTVNTUAABAAAAAAAAAFAs4OAAAADw==", headerInfos.get(0).getBase64());
|
||||||
|
|
||||||
assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Negotiate"));
|
assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Negotiate"));
|
||||||
assertTrue(headerInfos.get(1).getBase64().equals("YIIJvwYGKwYBBQUCoIIJszCCCa+gJDAi="));
|
assertEquals("YIIJvwYGKwYBBQUCoIIJszCCCa+gJDAi=", headerInfos.get(1).getBase64());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsInParam()
|
public void testEqualsInParam()
|
||||||
{
|
{
|
||||||
|
@ -765,10 +757,9 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
|
|
||||||
headerInfo = aph.getHeaderInfo("Digest realm=\"=the=rmo=stat=\", qop=\"=a=u=t=h=\", nonce=\"=1523430383=\"").get(0);
|
headerInfo = aph.getHeaderInfo("Digest realm=\"=the=rmo=stat=\", qop=\"=a=u=t=h=\", nonce=\"=1523430383=\"").get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfo.getParameter("qop").equals("=a=u=t=h="));
|
assertEquals("=a=u=t=h=", headerInfo.getParameter("qop"));
|
||||||
assertTrue(headerInfo.getParameter("realm").equals("=the=rmo=stat="));
|
assertEquals("=the=rmo=stat=", headerInfo.getParameter("realm"));
|
||||||
assertTrue(headerInfo.getParameter("nonce").equals("=1523430383="));
|
assertEquals("=1523430383=", headerInfo.getParameter("nonce"));
|
||||||
|
|
||||||
|
|
||||||
// test multiple authentications
|
// test multiple authentications
|
||||||
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest qop=\"=au=th=\", realm=\"=ther=mostat=\", nonce=\"=152343=0383=\", "
|
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest qop=\"=au=th=\", realm=\"=ther=mostat=\", nonce=\"=152343=0383=\", "
|
||||||
|
@ -776,23 +767,23 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
+ "Digest qop=\"auth3=\", nonce=\"9523570528=\", realm=\"thermostat3=\", ");
|
+ "Digest qop=\"auth3=\", nonce=\"9523570528=\", realm=\"thermostat3=\", ");
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(0).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(0).getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfoList.get(0).getParameter("qop").equals("=au=th="));
|
assertEquals("=au=th=", headerInfoList.get(0).getParameter("qop"));
|
||||||
assertTrue(headerInfoList.get(0).getParameter("realm").equals("=ther=mostat="));
|
assertEquals("=ther=mostat=", headerInfoList.get(0).getParameter("realm"));
|
||||||
assertTrue(headerInfoList.get(0).getParameter("nonce").equals("=152343=0383="));
|
assertEquals("=152343=0383=", headerInfoList.get(0).getParameter("nonce"));
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(1).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(1).getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfoList.get(1).getParameter("qop").equals("=auth2"));
|
assertEquals("=auth2", headerInfoList.get(1).getParameter("qop"));
|
||||||
assertTrue(headerInfoList.get(1).getParameter("realm").equals("=thermostat2"));
|
assertEquals("=thermostat2", headerInfoList.get(1).getParameter("realm"));
|
||||||
assertTrue(headerInfoList.get(1).getParameter("nonce").equals("=4522530354"));
|
assertEquals("=4522530354", headerInfoList.get(1).getParameter("nonce"));
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(2).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(2).getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfoList.get(2).getParameter("qop").equals("auth3="));
|
assertEquals("auth3=", headerInfoList.get(2).getParameter("qop"));
|
||||||
assertTrue(headerInfoList.get(2).getParameter("realm").equals("thermostat3="));
|
assertEquals("thermostat3=", headerInfoList.get(2).getParameter("realm"));
|
||||||
assertTrue(headerInfoList.get(2).getParameter("nonce").equals("9523570528="));
|
assertEquals("9523570528=", headerInfoList.get(2).getParameter("nonce"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingleChallangeLooksLikeMultipleChallenge()
|
public void testSingleChallengeLooksLikeMultipleChallenges()
|
||||||
{
|
{
|
||||||
AuthenticationProtocolHandler aph = new WWWAuthenticationProtocolHandler(client);
|
AuthenticationProtocolHandler aph = new WWWAuthenticationProtocolHandler(client);
|
||||||
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest param=\",f \"");
|
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest param=\",f \"");
|
||||||
|
@ -803,8 +794,8 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
|
|
||||||
HeaderInfo headerInfo = headerInfoList.get(0);
|
HeaderInfo headerInfo = headerInfoList.get(0);
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Digest"));
|
||||||
assertTrue(headerInfo.getParameter("qop").equals(",Digest realm=hello"));
|
assertEquals(",Digest realm=hello", headerInfo.getParameter("qop"));
|
||||||
assertTrue(headerInfo.getParameter("realm").equals("thermostat"));
|
assertEquals("thermostat", headerInfo.getParameter("realm"));
|
||||||
assertEquals(headerInfo.getParameter("nonce"), "1523430383=");
|
assertEquals(headerInfo.getParameter("nonce"), "1523430383=");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue