Filed https://issues.apache.org/jira/browse/KNOX-447

On 10/16/14, 10:30 AM, Kevin Minder wrote:
Hey Kris,

I played with your test this morning and it is a bug plain and (well not so simple). The way we tear apart and rebuilt URLs has some dark corners. If the output had been

https://webhcatTestHost.com:50111/templeton/v1/?version/hive=

I might have even said it was technically correct but

https://webhcatTestHost.com:50111/templeton/v1/?version/hive=null

Is just wrong.

The bottom line is that the URL parser isn't recording the fact that there is a query parameter without an equal sign or value well enough. As a result, when it is used in the expansion template via the {**}, the implied equal sign and value of the original query parameter are used. Two problems here: 1) The implied/default value should be the empty string not null and 2) the equal sign should not be output if it wasn't in the original URL.

BTW, you can prove this by changing your test's inputUri to
https://knoxHost:8443/gateway/knoxTopo/templeton/v1/?version/hive=foo
and then your test's assertion to
https://webhcatTestHost.com:50111/templeton/v1/?version/hive=foo

So clearly I have some work to do.

Question for you though. Did you mean for version/hive to be a valueless query parameter?

Kevin.


On 10/15/14, 11:08 PM, Kristopher Kane wrote:
Following the dev guide example class: testDevGuideSampleWithEvaluator
from: http://knox.apache.org/books/knox-0-4-0/dev-guide.html#Standard+Providers

outputUri = Expander.expand( template, match.getParams(), evaluator );
is returning a near match with '=null' appended to the end which is
failing my test.

Have been searching for a while but no luck yet.  Ideas?

Here is the full test:

       @Test
       public void testRules () throws IOException, URISyntaxException {
           URI inputUri, outputUri;
           Matcher<Void> matcher;
           Matcher<Void>.Match match;
           Template input, pattern, template;
           Evaluator evaluator;

           WebHCatDeploymentContributor contributor = new
WebHCatDeploymentContributor();
           UrlRewriteRulesDescriptor webhcatRules =
contributor.loadRulesFromTemplate();

           inputUri = new URI(
"https://knoxHost:8443/gateway/knoxTopo/templeton/v1/?version/hive"; );

           input = Parser.parse( inputUri.toString() );
           pattern = Parser.parse(
webhcatRules.getRule("WEBHCAT/webhcat/root/inbound").template().toString()
);
           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";));

       }


Assertion failure:

Expected: equalToIgnoringCase("https://webhcatTestHost.com:50111/templeton/v1/?version/hive";) but: was https://webhcatTestHost.com:50111/templeton/v1/?version/hive=null




--
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to which it is addressed and may contain information that is confidential, privileged and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any printing, copying, dissemination, distribution, disclosure or forwarding of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and delete it from your system. Thank You.

Reply via email to