knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject git commit: KNOX-381: Expansion of authority only URL should not be prefixed with //
Date Tue, 20 May 2014 21:13:05 GMT
Repository: knox
Updated Branches:
  refs/heads/master a4383ec24 -> 42dfaaee5


KNOX-381: Expansion of authority only URL should not be prefixed with //


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

Branch: refs/heads/master
Commit: 42dfaaee51b3f75849a0205927824b4812085bcb
Parents: a4383ec
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Tue May 20 17:12:17 2014 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Tue May 20 17:12:56 2014 -0400

----------------------------------------------------------------------
 .../apache/hadoop/gateway/util/urltemplate/Expander.java |  4 +++-
 .../hadoop/gateway/util/urltemplate/ExpanderTest.java    | 11 +++++++++++
 .../hadoop/gateway/util/urltemplate/TemplateTest.java    |  5 +++++
 3 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/42dfaaee/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Expander.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Expander.java
b/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Expander.java
index 3604511..4337f7a 100644
--- a/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Expander.java
+++ b/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Expander.java
@@ -68,7 +68,9 @@ public class Expander {
 
   private static void expandAuthority( Template template, Set<String> names, Params
params, Evaluator evaluator, StringBuilder builder ) {
     if( template.hasAuthority() ) {
-      builder.append( "//" );
+      if( !template.isAuthorityOnly() ) {
+        builder.append( "//" );
+      }
       Segment username = template.getUsername();
       Segment password = template.getPassword();
       Segment host = template.getHost();

http://git-wip-us.apache.org/repos/asf/knox/blob/42dfaaee/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ExpanderTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ExpanderTest.java
b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ExpanderTest.java
index 9d1dbbc..5b47b55 100644
--- a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ExpanderTest.java
+++ b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ExpanderTest.java
@@ -34,6 +34,17 @@ import static org.junit.Assert.fail;
 public class ExpanderTest {
 
   @Test
+  public void testHostAndPortOnlyExpansionBugKnox381() throws Exception {
+    String text = "{host}:{port}";
+    Template template = Parser.parse( text );
+    MockParams params = new MockParams();
+    params.addValue( "host", "test-host" );
+    params.addValue( "port", "777" );
+    URI expanded = Expander.expand( template, params, null );
+    assertThat( expanded.toString(), equalTo( "test-host:777" ) ) ;
+  }
+
+  @Test
   public void testCompleteUrl() throws URISyntaxException {
     String text;
     Template template;

http://git-wip-us.apache.org/repos/asf/knox/blob/42dfaaee/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
index 9856b93..cc0e720 100644
--- a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
+++ b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/TemplateTest.java
@@ -142,6 +142,11 @@ public class TemplateTest {
     template = Parser.parse( text );
     actual = template.toString();
     assertThat( actual, is( text ) );
+
+    text = "host:42";
+    template = Parser.parse( text );
+    actual = template.toString();
+    assertThat( actual, is( text ) );
   }
 
   @Test


Mime
View raw message