Bugs item #1579479, was opened at 2006-10-18 10:09
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=497982&aid=1579479&group_id=61302
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: HtmlUnit plugin
Group: Release 1.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Bernard de Terwangne (bdt_star)
Assigned to: Nobody/Anonymous (nobody)
Summary: setAuthorization has no effect anymore
Initial Comment:
It used to work with jWebUnit 1.2/HttpUnit. Here is how
to get the problem :
tester = new WebTester();
tester.getTestContext().setBaseUrl("http://localhost:9091/config");
tester.getTestContext().setAuthorization("myUser",
"myPassword");
tester.beginAt("/"); //Bang error 401 Unauthorized
The fix I did is simple : In HtmlUnitDialog :
...
private void initWebClient() {
wc = new WebClient(new
BrowserVersion(BrowserVersion.INTERNET_EXPLORER,
"4.0", testContext.getUserAgent(),
"1.2", 6));
if (testContext.hasAuthorization())
{
Credentials credentials = new
UsernamePasswordCredentials(testContext.getUser(),
testContext.getPassword());
wc.setCredentialsProvider(new
SimpleCredentialProvider(credentials));
}
wc.setJavaScriptEnabled(jsEnabled);
...
And I added the following class (Improvable !) :
package net.sourceforge.jwebunit.htmlunit;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.auth.AuthScheme;
import
org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
import
org.apache.commons.httpclient.auth.CredentialsProvider;
public class SimpleCredentialProvider implements
CredentialsProvider
{
private Credentials credentials;
public SimpleCredentialProvider(Credentials credentials)
{
super();
this.credentials = credentials;
}
public Credentials getCredentials(AuthScheme scheme,
String host, int port, boolean proxy) throws
CredentialsNotAvailableException
{
return credentials;
}
}
Well it works now...
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=497982&aid=1579479&group_id=61302
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development