Skip to content

Commit

Permalink
8255584: HttpPrincipal::getName returns incorrect name
Browse files Browse the repository at this point in the history
Reviewed-by: dfuchs
  • Loading branch information
pconcannon committed Nov 5, 2020
1 parent a6ce6a5 commit 2b78a43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public boolean equals(Object another) {
* @return the contents of this principal in the form realm:username
*/
public String getName() {
return username;
return String.format("%s:%s", realm, username);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion test/jdk/com/sun/net/httpserver/HttpPrincipalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@
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());
}
}

1 comment on commit 2b78a43

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.