forked from restlet/restlet-framework-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed potential bug with the "userinfo" deprecated format "login:pass…
…word". Reported by Eben.
- Loading branch information
1 parent
9c3773f
commit f15b44e
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -587,4 +587,32 @@ public void testMatrix() { | |
assertEquals("a=1;b=2;c=4", newForm.getMatrixString()); | ||
} | ||
|
||
public void testUserinfo() { | ||
Reference reference = new Reference("http://localhost:81"); | ||
// This format is deprecated, however we may prevent failures. | ||
reference.setUserInfo("login:password"); | ||
assertEquals("login:password@localhost:81", reference.getAuthority()); | ||
assertEquals("localhost", reference.getHostDomain()); | ||
assertEquals("81", reference.getHostPort()); | ||
assertEquals("login:password", reference.getUserInfo()); | ||
|
||
reference.setHostDomain("www.example.com"); | ||
assertEquals("login:[email protected]:81", reference.getAuthority()); | ||
assertEquals("localhost", reference.getHostDomain()); | ||
assertEquals("81", reference.getHostPort()); | ||
assertEquals("login:password", reference.getUserInfo()); | ||
|
||
reference.setHostPort(82); | ||
assertEquals("login:[email protected]:82", reference.getAuthority()); | ||
assertEquals("localhost", reference.getHostDomain()); | ||
assertEquals("82", reference.getHostPort()); | ||
assertEquals("login:password", reference.getUserInfo()); | ||
|
||
reference.setUserInfo("login"); | ||
assertEquals("[email protected]:82", reference.getAuthority()); | ||
assertEquals("localhost", reference.getHostDomain()); | ||
assertEquals("82", reference.getHostPort()); | ||
assertEquals("login", reference.getUserInfo()); | ||
} | ||
|
||
} |