|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
[HtmlUnit] SF.net SVN: htmlunit:[5151] trunk/htmlunit/srcRevision: 5151
http://htmlunit.svn.sourceforge.net/htmlunit/?rev=5151&view=rev Author: mguillem Date: 2009-11-02 15:12:27 +0000 (Mon, 02 Nov 2009) Log Message: ----------- DefaultCredentialsProvider: addCredentials should overwrite previous values. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProvider.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProviderTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2009-11-02 13:04:10 UTC (rev 5150) +++ trunk/htmlunit/src/changes/changes.xml 2009-11-02 15:12:27 UTC (rev 5151) @@ -6,6 +6,9 @@ <body> <release version="2.7" date="?" description="Bugfixes, initial IE8 support, HttpClient 4 migration"> + <action type="fix" dev="mguillem"> + DefaultCredentialsProvider: addCredentials should overwrite previous values. + </action> <action type="fix" dev="asashour" issue="2889583"> JavaScript: fix setting of element.innerText and .textContent with empty string or null. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProvider.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProvider.java 2009-11-02 13:04:10 UTC (rev 5150) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProvider.java 2009-11-02 15:12:27 UTC (rev 5151) @@ -66,7 +66,7 @@ * The credentials may be for any authentication scheme, including NTLM, digest and basic * HTTP authentication. If you are using sensitive username/password information, please do * NOT use this method. If you add credentials using this method, any server that requires - * authentication will receive the specified username and password. + * authentication may receive the specified username and password. * @param username the username for the new credentials * @param password the password for the new credentials */ @@ -315,6 +315,14 @@ final String scheme = (String) stream.readObject(); authScope_ = new AuthScope(host, port, realm, scheme); } + @Override + public int hashCode() { + return authScope_.hashCode(); + } + @Override + public boolean equals(final Object obj) { + return obj instanceof AuthScopeProxy && authScope_.equals(((AuthScopeProxy) obj).getAuthScope()); + } } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProviderTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProviderTest.java 2009-11-02 13:04:10 UTC (rev 5150) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProviderTest.java 2009-11-02 15:12:27 UTC (rev 5151) @@ -18,6 +18,8 @@ import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.NTCredentials; +import org.apache.commons.httpclient.UsernamePasswordCredentials; +import org.apache.commons.httpclient.auth.BasicScheme; import org.apache.commons.httpclient.auth.NTLMScheme; import org.junit.Test; @@ -90,4 +92,29 @@ assertNull(provider.getCredentials(scheme, "invalidHost", port, true)); } + /** + * Test that successive calls to {@link DefaultCredentialsProvider#addCredentials(String, String)} + * overwrite values previously set. + * @throws Exception if the test fails + */ + @Test + public void overwrite() throws Exception { + final DefaultCredentialsProvider provider = new DefaultCredentialsProvider(); + provider.addCredentials("username", "password"); + + UsernamePasswordCredentials credentials = + (UsernamePasswordCredentials) provider.getCredentials(new BasicScheme(), "host", 80, false); + assertEquals("username", credentials.getUserName()); + assertEquals("password", credentials.getPassword()); + + provider.addCredentials("username", "new password"); + credentials = (UsernamePasswordCredentials) provider.getCredentials(new BasicScheme(), "host", 80, false); + assertEquals("username", credentials.getUserName()); + assertEquals("new password", credentials.getPassword()); + + provider.addCredentials("new username", "other password"); + credentials = (UsernamePasswordCredentials) provider.getCredentials(new BasicScheme(), "host", 80, false); + assertEquals("new username", credentials.getUserName()); + assertEquals("other password", credentials.getPassword()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ HtmlUnit-develop mailing list HtmlUnit-develop@... https://lists.sourceforge.net/lists/listinfo/htmlunit-develop |
| Free embeddable forum powered by Nabble | Forum Help |