Skip to content

Commit

Permalink
fix: load static resources from default zone if zone not found
Browse files Browse the repository at this point in the history
This was already addressed with #979, but the fix there only works for a local setup.
In a typical productive deployment, the path is not starting with /uaa/, so the check need to be adopted to work in both local environment and a deployment.
  • Loading branch information
tack-sap committed Apr 15, 2024
1 parent 5c4fba0 commit 9ca2e6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
}
if (identityZone == null) {
// skip filter to static resources in order to serve images and css in case of invalid zones
boolean isStaticResource = request.getRequestURI().startsWith("/uaa/resources/");
boolean isStaticResource = request.getRequestURI().startsWith("/resources/") || request.getRequestURI().startsWith("/uaa/resources/");
if(isStaticResource) {
filterChain.doFilter(request, response);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,23 @@ void doNotThrowException_InCase_RetrievingZoneFails() throws Exception {
Mockito.verifyNoInteractions(chain);
}

@Test
public void serveStaticContent_InCase_RetrievingZoneFails_local() throws Exception {
checkStaticContent("/uaa/resources/css/application.css");
}

@Test
public void serveStaticContent_InCase_RetrievingZoneFails() throws Exception {
checkStaticContent("/resources/css/application.css");
}

private void checkStaticContent(String path) throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
String incomingSubdomain = "not_a_zone";
String uaaHostname = "uaa.mycf.com";
String incomingHostname = incomingSubdomain+"."+uaaHostname;
request.setServerName(incomingHostname);
request.setRequestURI("/uaa/resources/css/application.css");
request.setRequestURI(path);
MockHttpServletResponse response = new MockHttpServletResponse();

MockFilterChain filterChain = new MockFilterChain() {
Expand Down

0 comments on commit 9ca2e6d

Please sign in to comment.