knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-790 - URL parameters with empty/null value are ignored (Nishant Bangarwa via lmccay)
Date Mon, 21 Nov 2016 23:26:38 GMT
Repository: knox
Updated Branches:
  refs/heads/master 3a394adb1 -> b4fea509f


KNOX-790 - URL parameters with empty/null value are ignored (Nishant Bangarwa via lmccay)

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

Branch: refs/heads/master
Commit: b4fea509fde4d292893bd98043f1efc5231d0103
Parents: 3a394ad
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Mon Nov 21 18:26:26 2016 -0500
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Mon Nov 21 18:26:26 2016 -0500

----------------------------------------------------------------------
 .../IdentityAsserterHttpServletRequestWrapper.java |  8 ++++----
 ...tityAssertionHttpServletRequestWrapperTest.java | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/b4fea509/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
b/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
index 835a7a3..a4e8546 100644
--- a/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
+++ b/gateway-provider-identity-assertion-common/src/main/java/org/apache/hadoop/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
@@ -203,18 +203,18 @@ private static SpiGatewayMessages log = MessagesFactory.get( SpiGatewayMessages.
         } else {
           for( int i = 0; i < values.length; i++ ) {
             String value = values[ i ];
-            if( value != null ) {
               if( sb.length() > 0 ) {
                 sb.append( "&" );
               }
               try {
                 sb.append( urlEncode( name, encoding ) );
-                sb.append( "=" );
-                sb.append( urlEncode( value, encoding ) );
+                if( value != null ) {
+                  sb.append("=");
+                  sb.append(urlEncode(value, encoding));
+                }
               } catch( IllegalArgumentException e ) {
                 log.skippingUnencodableParameter( name, value, encoding, e );
               }
-            }
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/b4fea509/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
b/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
index 8bb0420..e892717 100644
--- a/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
+++ b/gateway-provider-identity-assertion-common/src/test/java/org/apache/hadoop/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
@@ -206,6 +206,23 @@ public class IdentityAssertionHttpServletRequestWrapperTest {
   }
 
   @Test
+  public void testParameterWithNullValueInQueryString() {
+    String input = "paramWithNullValue&param2=abc";
+
+    MockHttpServletRequest request = new MockHttpServletRequest();
+    request.setQueryString( input );
+
+    IdentityAsserterHttpServletRequestWrapper wrapper
+      = new IdentityAsserterHttpServletRequestWrapper( request, "output-user" );
+
+    String output = wrapper.getQueryString();
+
+    assertThat( output, containsString( "user.name=output-user" ) );
+    assertThat( output, containsString( "paramWithNullValue" ) );
+    assertThat( output, containsString( "param2=abc" ) );
+  }
+
+  @Test
   public void testUrlEncode() {
     String s;
     HashMap<String,String[]> m;


Mime
View raw message