Skip to content

Commit

Permalink
All vendor font
Browse files Browse the repository at this point in the history
  • Loading branch information
strehle committed Apr 15, 2024
1 parent 9ca2e6d commit 44b3ae2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.cloudfoundry.identity.uaa.zone;

import org.cloudfoundry.identity.uaa.util.UaaUrlUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
Expand All @@ -36,6 +37,7 @@
public class IdentityZoneResolvingFilter extends OncePerRequestFilter implements InitializingBean {

private final IdentityZoneProvisioning dao;
private final Set<String> staticResources = Set.of("/resources/", "/vendor/font-awesome/");
private Set<String> defaultZoneHostnames = new HashSet<>();
private Logger logger = LoggerFactory.getLogger(getClass());

Expand Down Expand Up @@ -63,7 +65,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("/resources/") || request.getRequestURI().startsWith("/uaa/resources/");
boolean isStaticResource = staticResources.stream().anyMatch(UaaUrlUtils.getRequestPath(request)::startsWith);
if(isStaticResource) {
filterChain.doFilter(request, response);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,25 @@ void doNotThrowException_InCase_RetrievingZoneFails() throws Exception {

@Test
public void serveStaticContent_InCase_RetrievingZoneFails_local() throws Exception {
checkStaticContent("/uaa/resources/css/application.css");
checkStaticContent("/uaa", "/resources/css/application.css");
checkStaticContent("/uaa", "/vendor/font-awesome/css/font-awesome.min.css");
}

@Test
public void serveStaticContent_InCase_RetrievingZoneFails() throws Exception {
checkStaticContent("/resources/css/application.css");
checkStaticContent(null, "/resources/css/application.css");
checkStaticContent(null, "/vendor/font-awesome/css/font-awesome.min.css");
}

private void checkStaticContent(String path) throws Exception {
private void checkStaticContent(String context, 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(path);
request.setRequestURI(context + path);
request.setContextPath(context);
request.setServletPath(path);
MockHttpServletResponse response = new MockHttpServletResponse();

MockFilterChain filterChain = new MockFilterChain() {
Expand Down

0 comments on commit 44b3ae2

Please sign in to comment.