From ff0ac568f450623567fda135f8bb073d791c3b8f Mon Sep 17 00:00:00 2001 From: Trevor Mack Date: Sat, 21 Jan 2017 23:12:45 -0800 Subject: [PATCH] addressing issues/1636 ZuulProperties.ZuulRoute consturctor missing explicitly setting of customSensitiveHeaders boolean when provided with sensitiveHeaders --- .../netflix/zuul/filters/ZuulProperties.java | 1 + .../zuul/filters/ZuulPropertiesTests.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ZuulProperties.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ZuulProperties.java index 687f18e6..f411fad2 100644 --- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ZuulProperties.java +++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ZuulProperties.java @@ -249,6 +249,7 @@ public class ZuulProperties { this.stripPrefix = stripPrefix; this.retryable = retryable; this.sensitiveHeaders = sensitiveHeaders; + this.customSensitiveHeaders = sensitiveHeaders != null; } public ZuulRoute(String text) { diff --git a/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/ZuulPropertiesTests.java b/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/ZuulPropertiesTests.java index 9ea87b50..e0b737ee 100644 --- a/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/ZuulPropertiesTests.java +++ b/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/ZuulPropertiesTests.java @@ -72,6 +72,7 @@ public class ZuulPropertiesTests { assertTrue(this.zuul.getRoutes().get("foo").getSensitiveHeaders().isEmpty()); assertTrue(this.zuul.getSensitiveHeaders() .containsAll(Arrays.asList("Cookie", "Set-Cookie", "Authorization"))); + assertFalse(route.isCustomSensitiveHeaders()); } @Test @@ -83,6 +84,21 @@ public class ZuulPropertiesTests { ZuulRoute foo = this.zuul.getRoutes().get("foo"); assertTrue(foo.getSensitiveHeaders().contains("x-foo")); assertFalse(foo.getSensitiveHeaders().contains("Cookie")); + assertTrue(foo.isCustomSensitiveHeaders()); + assertTrue(this.zuul.getSensitiveHeaders().contains("x-bar")); + assertFalse(this.zuul.getSensitiveHeaders().contains("Cookie")); + } + + @Test + public void createWithSensitiveHeaders() { + this.zuul.setSensitiveHeaders(Collections.singleton("x-bar")); + ZuulRoute route = new ZuulRoute("foo", "/path", "foo", "/path", + false, false, Collections.singleton("x-foo")); + this.zuul.getRoutes().put("foo", route); + ZuulRoute foo = this.zuul.getRoutes().get("foo"); + assertTrue(foo.getSensitiveHeaders().contains("x-foo")); + assertFalse(foo.getSensitiveHeaders().contains("Cookie")); + assertTrue(foo.isCustomSensitiveHeaders()); assertTrue(this.zuul.getSensitiveHeaders().contains("x-bar")); assertFalse(this.zuul.getSensitiveHeaders().contains("Cookie")); }