Skip to content

Commit 50de33e

Browse files
committed
document last pr and add test
1 parent 3805a77 commit 50de33e

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/changes/changes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
Jetty 9 websocket-client.
1919
</action>
2020

21+
<action type="fix" dev="Lai Quang Duong">
22+
Restore the ability to specify null as password value (regression in 3.4.0).
23+
</action>
2124
<action type="fix" dev="Lai Quang Duong" issue="https://github.com/HtmlUnit/htmlunit-neko/pull/92">
2225
neko: infinity loop problem fixed while processing &lt;plaintext&gt; using document.write().
2326
</action>
2427
<action type="fix" dev="rbri" issue="#740">
25-
Form elements available also when form detached from DOM (regression in 3.6.0).
28+
Form elements available also when the form is detached from DOM (regression in 3.6.0).
2629
</action>
2730
<action type="update" dev="rbri">
2831
Geoloction implementation changed, the location is now part of the WebClientOptions, means you can set the

src/main/java/org/htmlunit/httpclient/HtmlUnitUsernamePasswordCredentials.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Wrapper for {@link UsernamePasswordCredentials} to avoid direct references spread around.
2626
*
2727
* @author Ronald Brill
28+
* @author Lai Quang Duong
2829
*/
2930
public class HtmlUnitUsernamePasswordCredentials implements Credentials, Serializable {
3031

@@ -50,7 +51,9 @@ public HtmlUnitUsernamePasswordCredentials(final String userName, final String p
5051
* @param password the password
5152
*/
5253
public HtmlUnitUsernamePasswordCredentials(final String userName, final char[] password) {
53-
httpClientUsernamePasswordCredentials_ = new UsernamePasswordCredentials(userName, password != null ? String.valueOf(password) : null);
54+
httpClientUsernamePasswordCredentials_ = new UsernamePasswordCredentials(
55+
userName,
56+
password == null ? null : String.valueOf(password));
5457
}
5558

5659
@Override

src/test/java/org/htmlunit/DefaultCredentialsProviderTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* Tests for {@link DefaultCredentialsProvider}.
2727
*
2828
* @author Marc Guillemot
29+
* @author Ronald Brill
2930
*/
3031
@RunWith(BrowserRunner.class)
3132
public class DefaultCredentialsProviderTest extends SimpleWebTestCase {
@@ -94,4 +95,19 @@ public void removeCredentials() throws Exception {
9495
assertNull(credentials);
9596
}
9697

98+
/**
99+
* @throws Exception if the test fails
100+
*/
101+
@Test
102+
public void passwordNull() throws Exception {
103+
final String realm = "blah";
104+
final String scheme = new BasicScheme().getSchemeName();
105+
106+
final DefaultCredentialsProvider provider = new DefaultCredentialsProvider();
107+
provider.addCredentials("username", (char[]) null, HttpHeader.HOST_LC, 80, realm);
108+
109+
final Credentials credentials = provider.getCredentials(new AuthScope(HttpHeader.HOST_LC, 80, realm, scheme));
110+
assertEquals("username", credentials.getUserPrincipal().getName());
111+
assertNull(credentials.getPassword());
112+
}
97113
}

0 commit comments

Comments
 (0)