knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject knox git commit: KNOX-447: Incorrect parsing and expansion of valueless query params
Date Wed, 23 Sep 2015 15:00:26 GMT
Repository: knox
Updated Branches:
  refs/heads/master f165a6d19 -> cb5465755


KNOX-447: Incorrect parsing and expansion of valueless query params


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

Branch: refs/heads/master
Commit: cb5465755a81d9826a3160af3b626f5ef9b39514
Parents: f165a6d
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Wed Sep 23 11:00:17 2015 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Wed Sep 23 11:00:17 2015 -0400

----------------------------------------------------------------------
 .../gateway/util/urltemplate/ExpanderTest.java  | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/cb546575/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 4b32979..fb3166e 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
@@ -25,8 +25,11 @@ import org.junit.experimental.categories.Category;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.List;
 
 import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.Matchers.equalToIgnoringCase;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
@@ -389,4 +392,36 @@ public class ExpanderTest {
     assertThat( expanded.toString(), equalTo( "http://hortonworks.com:8888/top/mid/bot/file?name&flag="
) ) ;
   }
 
+  @Test
+  public void testValuelessQueryParamParsingAndExpansionBugKnox599Knox447() throws Exception
{
+    URI inputUri, outputUri;
+    Matcher<Void> matcher;
+    Matcher<Void>.Match match;
+    Template input, pattern, template;
+    Evaluator evaluator;
+
+    inputUri = new URI( "https://knoxHost:8443/gateway/knoxTopo/templeton/v1/?version/hive"
);
+
+    input = Parser.parse( inputUri.toString() );
+    pattern = Parser.parse( "*://*:*/**/templeton/v1/?{**}" );
+    template = Parser.parse( "{$serviceUrl[WEBHCAT]}/v1/?{**}" );
+
+    matcher = new Matcher<Void>();
+    matcher.add( pattern, null );
+    match = matcher.match( input );
+
+    evaluator = new Evaluator() {
+      @Override
+      public List<String> evaluate( String function, List<String> parameters
) {
+        return Arrays.asList( "https://webhcatTestHost.com:50111/templeton" );
+      }
+    };
+
+    outputUri = Expander.expand( template, match.getParams(), evaluator );
+    assertThat(
+        outputUri.toString(),
+        equalToIgnoringCase( "https://webhcatTestHost.com:50111/templeton/v1/?version/hive"
) );
+
+  }
+
 }


Mime
View raw message