TestPlan does not support NTLM authentication with HTMLUnit

Bug #767478 reported by Stephane Mikaty (eCircle AG)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
TestPlan
New
Undecided
Unassigned

Bug Description

The problem is known, there are reasons for not having NTLM in the Apache HttpClient library, BUT
the jar file to support authentication to NTLM is just one click away, it could use Web.Session.User and
Web.Session.Pass

http://htmlunit.sourceforge.net/ntlm.html

Here is the diff that I think is relevant, the other classes are already in the mentioned web page

mikaty@clnt-qa-01:~/workspace/qa/trunk/testplan/src$ bzr diff share/testplan/auto/htmlunit/ResponseState.java
=== modified file 'src/share/testplan/auto/htmlunit/ResponseState.java'
--- src/share/testplan/auto/htmlunit/ResponseState.java 2010-11-18 20:14:10 +0000
+++ src/share/testplan/auto/htmlunit/ResponseState.java 2011-04-20 18:36:27 +0000
@@ -30,6 +30,9 @@
 import java.text.SimpleDateFormat;
 import javax.xml.transform.TransformerException;

+import ntlm.NTLMSchemeFactory;
+
+import org.apache.http.impl.client.AbstractHttpClient;
 import org.w3c.dom.*;

 import testplan.auto.*;
@@ -81,6 +84,17 @@
   //WTF? why doesn't it use the java default, and why is it default to 0 (infinite), that's just plain retarded
   wc.setTimeout( Integer.parseInt( System.getProperty( "sun.net.client.defaultConnectTimeout" ) ) );
   wc.getPage(WebClient.URL_ABOUT_BLANK);
+ wc.setWebConnection(new HttpWebConnection(wc) {
+
+ protected synchronized AbstractHttpClient getHttpClient() {
+ AbstractHttpClient httpClient = super.getHttpClient();
+ httpClient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
+ return httpClient;
+ }
+ });
+ DefaultCredentialsProvider credentialProvider =
+ (DefaultCredentialsProvider) wc.getCredentialsProvider();
+ credentialProvider.addNTLMCredentials("...", "...", "...", -1, "...", "...");
  }

  private SgmlPage getCurrentSgmlPage() {

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.