Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/com/epimorphics/registry/webapi/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ public Response getLogout() {
* Generate an absolute URL for the given registry-relative path (which should start with /).
*/
protected String fullURLForPath(String path) {
return String.format("%s://%s%s%s", request.getScheme(), request.getServerName(), Registry.get().getRootPath(), path);
return String.format("%s://%s%s%s%s",
request.getScheme(),
request.getServerName(),
("http".equalsIgnoreCase(request.getScheme()) && request.getServerPort() == 80) ? "" : (
("https".equalsIgnoreCase(request.getScheme()) && request.getServerPort() == 443) ? "" :
String.format(":%d", request.getServerPort())
),
Registry.get().getRootPath(),
path);
}

@Path("/pwlogin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ protected void checkLoginLogout() {
String user = c.target(BASE_URL + "system/security/username").request().get(String.class);
assertEquals("Alice", user);

c.target(BASE_URL + "system/security/logout").request().post(null);
Response response = c.target(BASE_URL + "system/security/username").request().get();
assertTrue(response.getStatus() >= 400);
Response logoutResponse = c.target(BASE_URL + "system/security/logout").request().post(null);
assertEquals(BASE_URL, logoutResponse.getLocation().toString());
Response userResponse = c.target(BASE_URL + "system/security/username").request().get();
assertTrue(userResponse.getStatus() >= 400);
}

/**
Expand Down