changeset 219:7a5d4d4f9cae

Use whitespace character to match in RealmAuthorizer Reviewed-by: stooke Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-July/024333.html
author Jie Kang <jkang@redhat.com>
date Thu, 27 Jul 2017 14:36:55 -0400
parents 61021e0a81d2
children 96345741f7ce
files common/core/src/main/java/com/redhat/thermostat/gateway/common/core/auth/keycloak/RealmAuthorizer.java common/core/src/test/java/com/redhat/thermostat/gateway/common/core/auth/keycloak/RealmAuthorizerTest.java
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/gateway/common/core/auth/keycloak/RealmAuthorizer.java	Wed Jul 26 14:31:56 2017 -0400
+++ b/common/core/src/main/java/com/redhat/thermostat/gateway/common/core/auth/keycloak/RealmAuthorizer.java	Thu Jul 27 14:36:55 2017 -0400
@@ -49,7 +49,7 @@
 public class RealmAuthorizer {
 
     public static final String REALMS_HEADER = "X-Thermostat-Realms";
-    private static final String REALMS_HEADER_DELIMITER_REGEX = " +";
+    private static final String REALMS_HEADER_DELIMITER_REGEX = "\\s+";
 
     private final Set<Role> clientRoles;
     private final RoleFactory roleFactory = new RoleFactory();
--- a/common/core/src/test/java/com/redhat/thermostat/gateway/common/core/auth/keycloak/RealmAuthorizerTest.java	Wed Jul 26 14:31:56 2017 -0400
+++ b/common/core/src/test/java/com/redhat/thermostat/gateway/common/core/auth/keycloak/RealmAuthorizerTest.java	Thu Jul 27 14:36:55 2017 -0400
@@ -267,7 +267,7 @@
         String[] roles = new String[]{"w-write", "r-read", "u-update"};
         when(access.getRoles()).thenReturn(new HashSet<>(Arrays.asList(roles)));
 
-        when(request.getHeader(eq("X-Thermostat-Realms"))).thenReturn("  read  update     write    ");
+        when(request.getHeader(eq("X-Thermostat-Realms"))).thenReturn("  read  update\twrite    ");
 
         RealmAuthorizer realmAuthorizer = new RealmAuthorizer(request);
         assertEquals(1, realmAuthorizer.getReadableRealms().size());