8255584: HttpPrincipal::getName returns incorrect name

Reviewed-by: dfuchs
This commit is contained in:
Patrick Concannon 2020-11-05 10:10:21 +00:00
parent a6ce6a5d80
commit 2b78a43f77
2 changed files with 6 additions and 2 deletions

View File

@ -75,7 +75,7 @@ public class HttpPrincipal implements Principal {
* @return the contents of this principal in the form realm:username
*/
public String getName() {
return username;
return String.format("%s:%s", realm, username);
}
/**

View File

@ -36,9 +36,13 @@ import static org.testng.Assert.assertEquals;
public class HttpPrincipalTest {
@Test
public void TestGetters() {
public void testGetters() {
var principal = new HttpPrincipal("test", "123");
assertEquals(principal.getUsername(), "test");
assertEquals(principal.getRealm(), "123");
assertEquals(principal.getName(), "123:test");
assertEquals(principal.toString(), principal.getName());
assertEquals(("test"+"123").hashCode(), principal.hashCode());
}
}