6 messages in com.canoo.lists.webtestRE: [Webtest] RE: RE: problem with NT...
FromSent OnAttachments
Michael Dunn21 Apr 2006 13:54 
Marc Guillemot25 Apr 2006 01:08 
Michael Dunn25 Apr 2006 11:48 
Marc Guillemot25 Apr 2006 23:45 
Michael Dunn27 Apr 2006 15:29 
Marc Guillemot28 Apr 2006 00:09 
Subject:RE: [Webtest] RE: RE: problem with NT authentication
From:Michael Dunn (mdu@adaptisinc.com)
Date:04/21/2006 01:54:41 PM
List:com.canoo.lists.webtest

marc,

as you can see from the previous message below, I ran an htmlunit test with DefaultCredentialsProvider and everything worked correctly.

when I debug my webtest, there is an error and I get a 401 error. if I follow the stack trace, I see that there is a problem in TargetHelper.java. I downloaded the source code associated with webtest release R_1217, and I look at TargetHelper.java. below is the section from prepareConversationIfNeeded where it is using the credentials:

if (hasSuppliedCredentials()) { LOG.info("Setting password for username: " + fUserName); // credentials provider has already been set as DefaultCredentialsProvider // in Setup (may already contain credentials for proxy) final DefaultCredentialsProvider credentialsProvider = (DefaultCredentialsProvider) context.getWebClient().getCredentialsProvider(); credentialsProvider.addCredentials(fUserName, fPassword); context.setSavedUserName(fUserName); context.setSavedPassword(fPassword); }

I am assuming that this is the section that is trying to use the credentials since the LOG.info line is output as part of the debug information. take a look at the line above starting with "final Default...", it is using a .getCredentialsProvider() call. in my HtmlUnit test below what I used in this context was .setCredentialsProvider(). could this be the problem with webtest failing this test? where would is the .setCredentialsProvider() called. I may be totally off base here.

below is the debug output surrounding this: first it looks like DefaultCredentialsProvider has the correct information from these lines in the debug output that list the correct username and password: [invoke] DEBUG (org.apache.commons.httpclient.HttpMethodDirector) - Credentials required [invoke] DEBUG (com.gargoylesoftware.htmlunit.DefaultCredentialsProvider) - Returning *username*:*password* for ntlm null ts09utl:80 false [invoke] DEBUG (org.apache.commons.httpclient.HttpState) - enter HttpState.setCredentials(AuthScope, Credentials) [invoke] DEBUG (org.apache.commons.httpclient.HttpMethodDirector) - NTLM <any realm>@ts09utl:80 new credentials given [invoke] DEBUG (org.apache.commons.httpclient.HttpMethodDirector) - Retry authentication

then later on we get the error in the webtest [invoke] DEBUG (org.apache.commons.httpclient.HttpMethodBase) - Should close connection in response to directive: close [invoke] DEBUG (org.apache.commons.httpclient.HttpConnection) - enter HttpConnection.close() [invoke] DEBUG (org.apache.commons.httpclient.HttpConnection) - enter HttpConnection.closeSockedAndStreams() [invoke] DEBUG (org.apache.commons.httpclient.HttpConnection) - enter HttpConnection.releaseConnection() [invoke] DEBUG (org.apache.commons.httpclient.HttpConnection) - Connection is locked. Call to releaseConnection() ignored. [invoke] DEBUG (org.apache.commons.httpclient.HttpMethodDirector) - Authenticating with NTLM <any realm>@ts09utl:80 [invoke] DEBUG (org.apache.commons.httpclient.HttpState) - enter HttpState.getCredentials(AuthScope) [invoke] DEBUG (org.apache.commons.httpclient.auth.NTLMScheme) - enter NTLMScheme.authenticate(Credentials, HttpMethod) [invoke] ERROR (org.apache.commons.httpclient.HttpMethodDirector) - Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials [invoke] org.apache.commons.httpclient.auth.InvalidCredentialsException: Credentials cannot be used for NTLM authentication: org.apache.commons.httpclient.UsernamePasswordCredentials [invoke] at org.apache.commons.httpclient.auth.NTLMScheme.authenticate(NTLMScheme.ja va:331) [invoke] at org.apache.commons.httpclient.HttpMethodDirector.authenticateHost(HttpMe thodDirector.java:281) [invoke] at org.apache.commons.httpclient.HttpMethodDirector.authenticate(HttpMethod Director.java:233) [invoke] at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMetho dDirector.java:169) [invoke] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:3 96) [invoke] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:3 46) [invoke] at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConne ction.java:125) [invoke] at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection (WebClient.java:1354) [invoke] at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1 321) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:331) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:384) [invoke] at com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.ja va:69) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(Abstrac tTargetAction.java:68) [invoke] at com.canoo.webtest.steps.request.InvokePage.findTarget(InvokePage.java:13 5) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTarg etAction.java:108) [invoke] at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper. java:88) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(Abstract TargetAction.java:106) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractT argetAction.java:78) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:135) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:38) [invoke] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:105) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [invoke] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecut or.java:40) [invoke] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTar gets(EclipseDefaultExecutor.java:32) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAnt Runner.java:423) [invoke] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAn tRunner.java:137) [invoke] DEBUG (org.apache.commons.httpclient.HttpMethodDirector) - Attempt number 1 to process request

later, mikey

-----Original Message----- From: webt@lists.canoo.com [mailto:webt@lists.canoo.com] On Behalf Of Michael Dunn Sent: Friday, April 14, 2006 3:17 PM To: webt@lists.canoo.com Subject: RE: [Webtest] RE: RE: problem with NT authentication

marc,

the following test of htmlunit works fine, therefore there must be something wrong with webtest's implementation.

public void testNTLM() throws Exception { try{ DefaultCredentialsProvider prov = new DefaultCredentialsProvider(); prov.addCredentials("*username*","*password*"); final WebClient webClient = new WebClient(); webClient.setCredentialsProvider(prov); final URL url = new URL("http://ts09utl/tmtrack/tmtrack.dll"); final HtmlPage page = (HtmlPage)webClient.getPage(url); assertEquals( "TeamTrack", page.getTitleText() ); } catch(Exception e){ } }

I am having a challenge getting more debug information from the run of webtest as you suggested, but will continue sometime next week.

later, mikey

Michael Dunn Product Test Manager Adaptis 206 342 7478

-----Original Message----- From: webt@lists.canoo.com [mailto:webt@lists.canoo.com] On Behalf Of Marc Guillemot Sent: Thursday, April 13, 2006 12:05 AM To: webt@lists.canoo.com Subject: [Webtest] RE: RE: problem with NT authentication

Hi Mike,

I have never tested personally htmlunit with NT authentication but as far as I've heard from, this is working.

In your case, I would check it first directly with htmlunit without webtest. This makes debugging easier and could allow to identify if the problems come from htmlunit or from webtest. For this purpose, you just have to setup a project with htmlunit (you can use the libs provided with webtest), create a WebClient, set the credentials on the CredentialsProvider and call your page.

If it doesn't work, then webtest is not guilty and the problem should be fixed at the hmlunit level. If it works, then it means that webtest uses htmlunit incorectly. In this case it can be interesting to start webtest from your IDE in debug mode. Here are some key points to configure when working with Ecllipse: - create an Eclipse project and put the the Webtest related jars in the classpath (the easier way is perhaps to checkout from Webtest CVS) - menu Run / Debug... - in the dialog on the left side, Configurations, right click on Java Application to create a new one - choose the project where the webtest libraries are on the classpath - choose org.apache.tools.ant.Main as Main class - in the Arguments tab - choose the working directory where you normally start your ant command - add the Programm Arguments you normally write after the ant command

Marc. -- View this message in context: http://www.nabble.com/RE%3A-RE%3A-problem-with-NT-authentication-t144058 9.html#a3895592 Sent from the WebTest forum at Nabble.com.