hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject hadoop git commit: HDDS-573. Make VirtualHostStyleFilter port agnostic. Contributed by Danilo Perez.
Date Mon, 29 Oct 2018 13:50:35 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 78ea897b6 -> bfb720ebc


HDDS-573. Make VirtualHostStyleFilter port agnostic. Contributed by Danilo Perez.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/bfb720eb
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/bfb720eb
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/bfb720eb

Branch: refs/heads/trunk
Commit: bfb720ebc84c976e264971fa655515093a695515
Parents: 78ea897
Author: Márton Elek <elek@apache.org>
Authored: Mon Oct 29 14:45:01 2018 +0100
Committer: Márton Elek <elek@apache.org>
Committed: Mon Oct 29 14:45:01 2018 +0100

----------------------------------------------------------------------
 .../org/apache/hadoop/ozone/s3/VirtualHostStyleFilter.java  | 9 +++++++++
 .../apache/hadoop/ozone/s3/TestVirtualHostStyleFilter.java  | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/bfb720eb/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/VirtualHostStyleFilter.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/VirtualHostStyleFilter.java
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/VirtualHostStyleFilter.java
index d4e7547..50014fe 100644
--- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/VirtualHostStyleFilter.java
+++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/VirtualHostStyleFilter.java
@@ -74,6 +74,7 @@ public class VirtualHostStyleFilter implements ContainerRequestFilter {
     }
     //Get the value of the host
     String host = requestContext.getHeaderString(HttpHeaders.HOST);
+    host = checkHostWithoutPort(host);
     String domain = getDomainName(host);
 
     if (domain == null) {
@@ -148,6 +149,14 @@ public class VirtualHostStyleFilter implements ContainerRequestFilter
{
     return match;
   }
 
+  private String checkHostWithoutPort(String host) {
+    if (host.contains(":")){
+      return host.substring(0, host.lastIndexOf(":"));
+    } else {
+      return host;
+    }
+  }
+
   @VisibleForTesting
   public void setAuthenticationHeaderParser(AuthenticationHeaderParser parser) {
     this.authenticationHeaderParser = parser;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/bfb720eb/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/TestVirtualHostStyleFilter.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/TestVirtualHostStyleFilter.java
b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/TestVirtualHostStyleFilter.java
index 1b706da..eead447 100644
--- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/TestVirtualHostStyleFilter.java
+++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/TestVirtualHostStyleFilter.java
@@ -49,6 +49,7 @@ public class TestVirtualHostStyleFilter {
     conf = new OzoneConfiguration();
     s3HttpAddr = "localhost:9878";
     conf.set(S3GatewayConfigKeys.OZONE_S3G_HTTP_ADDRESS_KEY, s3HttpAddr);
+    s3HttpAddr = s3HttpAddr.substring(0, s3HttpAddr.lastIndexOf(":"));
     conf.set(S3GatewayConfigKeys.OZONE_S3G_DOMAIN_NAME, s3HttpAddr);
     authenticationHeaderParser = new AuthenticationHeaderParser();
     authenticationHeaderParser.setAuthHeader("AWS ozone:scret");
@@ -185,9 +186,10 @@ public class TestVirtualHostStyleFilter {
         authenticationHeaderParser);
 
     ContainerRequest containerRequest = createContainerRequest("mybucket" +
-        ".localhost:9999", null, null, true);
+        ".myhost:9999", null, null, true);
     try {
       virtualHostStyleFilter.filter(containerRequest);
+      fail("testVirtualHostStyleWithNoMatchingDomain");
     } catch (InvalidRequestException ex) {
       GenericTestUtils.assertExceptionContains("No matching domain", ex);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message