You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2016/03/05 22:59:52 UTC

[1/3] knox git commit: Revert "[KNOX-681] - A PUT with Content-Type application/xml but no body causes NullPointerException"

Repository: knox
Updated Branches:
  refs/heads/master 8a6545109 -> 3d37f7b27


Revert "[KNOX-681] - A PUT with Content-Type application/xml but no body causes NullPointerException"

This reverts commit 8a6545109f257977838e015820ca9f1ca18aac74.


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

Branch: refs/heads/master
Commit: 8bee25912d72500a800e1759185ef5330cc3a995
Parents: 8a65451
Author: Kevin Minder <km...@apache.org>
Authored: Sat Mar 5 15:44:58 2016 -0500
Committer: Kevin Minder <km...@apache.org>
Committed: Sat Mar 5 15:44:58 2016 -0500

----------------------------------------------------------------------
 CHANGES                                         |   1 -
 .../filter/rewrite/impl/UrlRewriteRequest.java  |  19 ++--
 .../rewrite/impl/xml/XmlFilterReader.java       |   6 +-
 .../hadoop/gateway/GatewayMultiFuncTest.java    | 102 +------------------
 .../gateway/OozieServiceDefinitionTest.java     |   1 -
 .../test-knox678-utf8-chars-topology.xml        |   2 +-
 6 files changed, 12 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/8bee2591/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index a757eaa..06efd2d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,7 +10,6 @@ Release Notes - Apache Knox - Version 0.9.0
     * [KNOX-678] - Malformed UTF-8 characters in JSON Response
     * [KNOX-680] - Update Knox's HttpClient dependency to latest version
 ** Bug
-    * [KNOX-681] - A PUT with Content-Type application/xml but no body causes NullPointerException
 
 ------------------------------------------------------------------------------
 Release Notes - Apache Knox - Version 0.8.0

http://git-wip-us.apache.org/repos/asf/knox/blob/8bee2591/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
index fd6cd24..4197d65 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
@@ -211,14 +211,11 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver
 
   @Override
   public ServletInputStream getInputStream() throws IOException {
-    ServletInputStream input = super.getInputStream();
-    if( getContentLength() != 0 ) {
-      MimeType mimeType = getMimeType();
-      UrlRewriteFilterContentDescriptor filterContentConfig = getRewriteFilterConfig( bodyFilterName, mimeType );
-      InputStream stream = UrlRewriteStreamFilterFactory.create( mimeType, null, input, rewriter, this, UrlRewriter.Direction.IN, filterContentConfig );
-      input = new UrlRewriteRequestStream( stream );
-    }
-    return input;
+    MimeType mimeType = getMimeType();
+    UrlRewriteFilterContentDescriptor filterContentConfig = getRewriteFilterConfig( bodyFilterName, mimeType );
+    InputStream stream = UrlRewriteStreamFilterFactory.create(
+        mimeType, null, super.getInputStream(), rewriter, this, UrlRewriter.Direction.IN, filterContentConfig );
+    return new UrlRewriteRequestStream( stream );
   }
 
   @Override
@@ -229,11 +226,7 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver
   @Override
   public int getContentLength() {
     // The rewrite might change the content length so return the default of -1 to indicate the length is unknown.
-    int contentLength = super.getContentLength();
-    if( contentLength > 0 ) {
-      contentLength = -1;
-    }
-    return contentLength;
+    return -1;
   }
 
   private UrlRewriteFilterContentDescriptor getRewriteFilterConfig( String filterName, MimeType mimeType ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/8bee2591/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
index cfaebd2..fe1682c 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
@@ -120,12 +120,10 @@ public abstract class XmlFilterReader extends Reader {
         try {
           XMLEvent event = parser.nextEvent();
           processEvent( event );
-        } catch( IOException e ) {
-          throw e;
         } catch( RuntimeException e ) {
           throw e;
-        } catch ( Exception e ) {
-          throw new RuntimeException( e );
+        } catch( Exception e ) {
+          throw e instanceof IOException ? (IOException)e : new IOException( e );
         }
         available = buffer.length() - offset;
       } else {

http://git-wip-us.apache.org/repos/asf/knox/blob/8bee2591/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
index cb3a1a1..8c29ce5 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
@@ -26,8 +26,8 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.UUID;
 
+import com.jayway.restassured.RestAssured;
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.hadoop.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.hadoop.gateway.services.DefaultGatewayServices;
@@ -37,20 +37,7 @@ import org.apache.hadoop.gateway.services.topology.TopologyService;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.hadoop.test.category.ReleaseTest;
 import org.apache.hadoop.test.mock.MockServer;
-import org.apache.http.HttpHost;
 import org.apache.http.HttpStatus;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
 import org.junit.After;
@@ -62,15 +49,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static com.jayway.restassured.RestAssured.given;
+import static com.jayway.restassured.config.ConnectionConfig.connectionConfig;
+import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
 import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
 import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
-import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
-import static org.xmlmatchers.XmlMatchers.hasXPath;
-import static org.xmlmatchers.transform.XmlConverters.the;
 
 @Category(ReleaseTest.class)
 public class GatewayMultiFuncTest {
@@ -239,86 +225,4 @@ public class GatewayMultiFuncTest {
     LOG_EXIT();
   }
 
-  @Test( timeout = TestUtils.MEDIUM_TIMEOUT )
-  public void testPostWithContentTypeKnox681() throws Exception {
-    LOG_ENTER();
-
-    MockServer mock = new MockServer( "REPEAT", true );
-
-    params.put( "MOCK_SERVER_PORT", mock.getPort() );
-
-    String topoStr = TestUtils.merge( DAT, "topologies/test-knox678-utf8-chars-topology.xml", params );
-    File topoFile = new File( config.getGatewayTopologyDir(), "topology.xml" );
-    FileUtils.writeStringToFile( topoFile, topoStr );
-
-    topos.reloadTopologies();
-
-    mock
-        .expect()
-        .method( "PUT" )
-        .pathInfo( "/repeat-context/" )
-        .respond()
-        .status( HttpStatus.SC_CREATED )
-        .content( "{\"name\":\"value\"}".getBytes() )
-        .contentType( "application/json; charset=UTF-8" )
-        .header( "Location", gatewayUrl + "/topology/repeat" );
-
-    String uname = "guest";
-    String pword = uname + "-password";
-
-    HttpHost targetHost = new HttpHost( "localhost", gatewayPort, "http" );
-    CredentialsProvider credsProvider = new BasicCredentialsProvider();
-    credsProvider.setCredentials(
-        new AuthScope( targetHost.getHostName(), targetHost.getPort() ),
-        new UsernamePasswordCredentials( uname, pword ) );
-
-    AuthCache authCache = new BasicAuthCache();
-    BasicScheme basicAuth = new BasicScheme();
-    authCache.put( targetHost, basicAuth );
-
-    HttpClientContext context = HttpClientContext.create();
-    context.setCredentialsProvider( credsProvider );
-    context.setAuthCache( authCache );
-
-    CloseableHttpClient client = HttpClients.createDefault();
-    HttpPut request = new HttpPut( gatewayUrl + "/topology/repeat" );
-    request.addHeader( "X-XSRF-Header", "jksdhfkhdsf" );
-    request.addHeader( "Content-Type", "application/json" );
-    CloseableHttpResponse response = client.execute( request, context );
-    assertThat( response.getStatusLine().getStatusCode(), is( HttpStatus.SC_CREATED ) );
-    assertThat( response.getFirstHeader( "Location" ).getValue(), endsWith("/gateway/topology/repeat" ) );
-    assertThat( response.getFirstHeader( "Content-Type" ).getValue(), is("application/json; charset=UTF-8") );
-    String body = new String( IOUtils.toByteArray( response.getEntity().getContent() ), Charset.forName( "UTF-8" ) );
-    assertThat( body, is( "{\"name\":\"value\"}" ) );
-    response.close();
-    client.close();
-
-    mock
-        .expect()
-        .method( "PUT" )
-        .pathInfo( "/repeat-context/" )
-        .respond()
-        .status( HttpStatus.SC_CREATED )
-        .content( "<test-xml/>".getBytes() )
-        .contentType( "application/xml; charset=UTF-8" )
-        .header( "Location", gatewayUrl + "/topology/repeat" );
-
-    client = HttpClients.createDefault();
-    request = new HttpPut( gatewayUrl + "/topology/repeat" );
-    request.addHeader( "X-XSRF-Header", "jksdhfkhdsf" );
-    request.addHeader( "Content-Type", "application/xml" );
-    response = client.execute( request, context );
-    assertThat( response.getStatusLine().getStatusCode(), is( HttpStatus.SC_CREATED ) );
-    assertThat( response.getFirstHeader( "Location" ).getValue(), endsWith("/gateway/topology/repeat" ) );
-    assertThat( response.getFirstHeader( "Content-Type" ).getValue(), is("application/xml; charset=UTF-8") );
-    body = new String( IOUtils.toByteArray( response.getEntity().getContent() ), Charset.forName( "UTF-8" ) );
-    assertThat( the(body), hasXPath( "/test-xml" ) );
-    response.close();
-    client.close();
-
-    LOG_EXIT();
-  }
-
 }
-
-

http://git-wip-us.apache.org/repos/asf/knox/blob/8bee2591/gateway-test/src/test/java/org/apache/hadoop/gateway/OozieServiceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/OozieServiceDefinitionTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/OozieServiceDefinitionTest.java
index 6a91a87..b2f982b 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/OozieServiceDefinitionTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/OozieServiceDefinitionTest.java
@@ -181,7 +181,6 @@ public class OozieServiceDefinitionTest {
     HttpServletRequest servletRequest = EasyMock.createNiceMock( HttpServletRequest.class );
     EasyMock.expect( servletRequest.getInputStream() ).andReturn( new MockServletInputStream( TestUtils.getResourceStream( OozieServiceDefinitionTest.class, testResource ) ) ).anyTimes();
     EasyMock.expect( servletRequest.getContentType() ).andReturn( "text/xml" ).anyTimes();
-    EasyMock.expect( servletRequest.getContentLength() ).andReturn( -1 ).anyTimes();
 
     FilterConfig filterConfig = EasyMock.createNiceMock( FilterConfig.class );
     EasyMock.expect( filterConfig.getServletContext() ).andReturn( servletContext ).anyTimes();

http://git-wip-us.apache.org/repos/asf/knox/blob/8bee2591/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml
index 7a0a916..fbbab48 100644
--- a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml
@@ -49,6 +49,6 @@
     </gateway>
     <service>
         <role>REPEAT</role>
-        <url>http://localhost:$MOCK_SERVER_PORT/repeat-context</url>
+        <url>http://localhost:${MOCK_SERVER_PORT}/repeat-context</url>
     </service>
 </topology>


[3/3] knox git commit: Revert "[KNOX-678] - Malformed UTF-8 characters in JSON Response"

Posted by km...@apache.org.
Revert "[KNOX-678] - Malformed UTF-8 characters in JSON Response"

This reverts commit 7806a411a847442723dbe4b064aacdce896d1d61.


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

Branch: refs/heads/master
Commit: 3d37f7b274a324a2c34041b0c209ebcb4f954a68
Parents: 5f27642
Author: Kevin Minder <km...@apache.org>
Authored: Sat Mar 5 16:24:21 2016 -0500
Committer: Kevin Minder <km...@apache.org>
Committed: Sat Mar 5 16:24:21 2016 -0500

----------------------------------------------------------------------
 CHANGES                                         |   1 -
 .../gateway/dispatch/DefaultDispatch.java       |  43 +---
 .../hadoop/gateway/GatewayBasicFuncTest.java    |   2 +-
 .../hadoop/gateway/GatewayMultiFuncTest.java    | 229 -------------------
 .../applications/readme.txt                     |  18 --
 .../GatewayMultiFuncTest/services/readme.txt    |  18 --
 .../services/repeat/0.0.0/rewrite.xml           |  28 ---
 .../services/repeat/0.0.0/service.xml           |  23 --
 .../test-knox678-utf8-chars-topology.xml        |  54 -----
 .../gateway/GatewayMultiFuncTest/users.ldif     |  42 ----
 10 files changed, 6 insertions(+), 452 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 2877e83..daed19b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,7 +7,6 @@ Release Notes - Apache Knox - Version 0.9.0
 ** Improvement
     * [KNOX-677] - Upgrade to latest Groovy
     * [KNOX-675] - Upgrade Knox's Jetty dependency to latest 9.x
-    * [KNOX-678] - Malformed UTF-8 characters in JSON Response
 ** Bug
 
 ------------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
index 2c9b950..85ecb08 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
@@ -48,9 +48,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 
 /**
@@ -67,7 +65,6 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
       AuditConstants.KNOX_SERVICE_NAME, AuditConstants.KNOX_COMPONENT_NAME);
 
   private Set<String> outboundResponseExcludeHeaders;
-  private Map<String,String> outboundResponseCharsetDefaults;
 
   private int replayBufferSize = -1;
 
@@ -76,13 +73,6 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
     outboundResponseExcludeHeaders = new HashSet<>();
     outboundResponseExcludeHeaders.add(SET_COOKIE);
     outboundResponseExcludeHeaders.add(WWW_AUTHENTICATE);
-
-    String utf8 = "UTF-8";
-    outboundResponseCharsetDefaults = new HashMap<>();
-    outboundResponseCharsetDefaults.put( "text/xml", utf8 );
-    outboundResponseCharsetDefaults.put( "text/json", utf8 );
-    outboundResponseCharsetDefaults.put( "application/xml", utf8 );
-    outboundResponseCharsetDefaults.put( "application/json", utf8 );
   }
 
   @Override
@@ -160,8 +150,11 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
     }
 
     HttpEntity entity = inboundResponse.getEntity();
-    if( entity != null ) {
-      outboundResponse.setContentType( getResponseContentType( entity ) );
+    if ( entity != null ) {
+      Header contentType = entity.getContentType();
+      if ( contentType != null ) {
+        outboundResponse.setContentType(contentType.getValue());
+      }
       //KM[ If this is set here it ends up setting the content length to the content returned from the server.
       // This length might not match if the the content is rewritten.
       //      long contentLength = entity.getContentLength();
@@ -178,23 +171,6 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
     }
   }
 
-  private String getResponseContentType( HttpEntity entity ) {
-    String name = null;
-    if( entity != null ) {
-      ContentType type = ContentType.get( entity );
-      if( type != null ) {
-        if( type.getCharset() == null ) {
-          String charset = getOutboundResponseCharacterEncoding( type.getMimeType() );
-          if( charset != null ) {
-            type = type.withCharset( charset );
-          }
-        }
-        name = type.toString();
-      }
-    }
-    return name;
-  }
-
   protected void closeInboundResponse( HttpResponse response, InputStream stream ) throws IOException {
     try {
       stream.close();
@@ -296,13 +272,4 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
   public Set<String> getOutboundResponseExcludeHeaders() {
     return outboundResponseExcludeHeaders;
   }
-
-  protected String getOutboundResponseCharacterEncoding( String mimeType ) {
-    String charset = null;
-    if( mimeType != null ) {
-      charset = outboundResponseCharsetDefaults.get( mimeType.trim().toLowerCase() );
-    }
-    return charset;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
index 27e4b72..5dff1f8 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
@@ -2274,7 +2274,7 @@ public class GatewayBasicFuncTest {
     LOG_EXIT();
   }
 
-  @Test//( timeout = MEDIUM_TIMEOUT )
+  @Test( timeout = MEDIUM_TIMEOUT )
   public void testYarnRmApplication() throws Exception {
     LOG_ENTER();
     getYarnRmApp( ContentType.JSON, true );

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
deleted file mode 100644
index 47fe9bd..0000000
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.gateway;
-
-import java.io.File;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.UUID;
-
-import com.jayway.restassured.RestAssured;
-import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.hadoop.gateway.security.ldap.SimpleLdapDirectoryServer;
-import org.apache.hadoop.gateway.services.DefaultGatewayServices;
-import org.apache.hadoop.gateway.services.GatewayServices;
-import org.apache.hadoop.gateway.services.ServiceLifecycleException;
-import org.apache.hadoop.gateway.services.topology.TopologyService;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
-import org.apache.hadoop.test.mock.MockServer;
-import org.apache.http.HttpStatus;
-import org.apache.log4j.Appender;
-import org.hamcrest.MatcherAssert;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.config.ConnectionConfig.connectionConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-@Category(ReleaseTest.class)
-public class GatewayMultiFuncTest {
-
-  private static Logger LOG = LoggerFactory.getLogger( GatewayMultiFuncTest.class );
-  private static Class DAT = GatewayMultiFuncTest.class;
-
-  private static Enumeration<Appender> appenders;
-  private static GatewayTestConfig config;
-  private static DefaultGatewayServices services;
-  private static GatewayServer gateway;
-  private static int gatewayPort;
-  private static String gatewayUrl;
-  private static String clusterUrl;
-  private static SimpleLdapDirectoryServer ldap;
-  private static TcpTransport ldapTransport;
-  private static int ldapPort;
-  private static Properties params;
-  private static TopologyService topos;
-  private static MockServer mockWebHdfs;
-
-  @BeforeClass
-  public static void setupSuite() throws Exception {
-    LOG_ENTER();
-    RestAssured.config = newConfig().connectionConfig(connectionConfig().closeIdleConnectionsAfterEachResponse());
-    //appenders = NoOpAppender.setUp();
-    setupLdap();
-    setupGateway();
-    LOG_EXIT();
-  }
-
-  @AfterClass
-  public static void cleanupSuite() throws Exception {
-    LOG_ENTER();
-    gateway.stop();
-    ldap.stop( true );
-    FileUtils.deleteQuietly( new File( config.getGatewayHomeDir() ) );
-    //NoOpAppender.tearDown( appenders );
-    LOG_EXIT();
-  }
-
-  @After
-  public void cleanupTest() throws Exception {
-    FileUtils.cleanDirectory( new File( config.getGatewayTopologyDir() ) );
-    FileUtils.cleanDirectory( new File( config.getGatewayDeploymentDir() ) );
-  }
-
-  public static void setupLdap() throws Exception {
-    URL usersUrl = TestUtils.getResourceUrl( DAT, "users.ldif" );
-    ldapPort = TestUtils.findFreePort();
-    ldapTransport = new TcpTransport( ldapPort );
-    ldap = new SimpleLdapDirectoryServer( "dc=hadoop,dc=apache,dc=org", new File( usersUrl.toURI() ), ldapTransport );
-    ldap.start();
-    LOG.info( "LDAP port = " + ldapTransport.getPort() );
-  }
-
-  public static void setupGateway() throws Exception {
-
-    File targetDir = new File( System.getProperty( "user.dir" ), "target" );
-    File gatewayDir = new File( targetDir, "gateway-home-" + UUID.randomUUID() );
-    gatewayDir.mkdirs();
-
-    config = new GatewayTestConfig();
-    config.setGatewayHomeDir( gatewayDir.getAbsolutePath() );
-
-    URL svcsFileUrl = TestUtils.getResourceUrl( DAT, "services/readme.txt" );
-    File svcsFile = new File( svcsFileUrl.getFile() );
-    File svcsDir = svcsFile.getParentFile();
-    config.setGatewayServicesDir( svcsDir.getAbsolutePath() );
-
-    URL appsFileUrl = TestUtils.getResourceUrl( DAT, "applications/readme.txt" );
-    File appsFile = new File( appsFileUrl.getFile() );
-    File appsDir = appsFile.getParentFile();
-    config.setGatewayApplicationsDir( appsDir.getAbsolutePath() );
-
-    File topoDir = new File( config.getGatewayTopologyDir() );
-    topoDir.mkdirs();
-
-    File deployDir = new File( config.getGatewayDeploymentDir() );
-    deployDir.mkdirs();
-
-    setupMockServers();
-    startGatewayServer();
-  }
-
-  public static void setupMockServers() throws Exception {
-    mockWebHdfs = new MockServer( "WEBHDFS", true );
-  }
-
-  public static void startGatewayServer() throws Exception {
-    services = new DefaultGatewayServices();
-    Map<String,String> options = new HashMap<String,String>();
-    options.put( "persist-master", "false" );
-    options.put( "master", "password" );
-    try {
-      services.init( config, options );
-    } catch ( ServiceLifecycleException e ) {
-      e.printStackTrace(); // I18N not required.
-    }
-    topos = services.getService(GatewayServices.TOPOLOGY_SERVICE);
-
-    gateway = GatewayServer.startGateway( config, services );
-    MatcherAssert.assertThat( "Failed to start gateway.", gateway, notNullValue() );
-
-    gatewayPort = gateway.getAddresses()[0].getPort();
-    gatewayUrl = "http://localhost:" + gatewayPort + "/" + config.getGatewayPath();
-    clusterUrl = gatewayUrl + "/test-topology";
-
-    LOG.info( "Gateway port = " + gateway.getAddresses()[ 0 ].getPort() );
-
-    params = new Properties();
-    params.put( "LDAP_URL", "ldap://localhost:" + ldapTransport.getPort() );
-    params.put( "WEBHDFS_URL", "http://localhost:" + mockWebHdfs.getPort() );
-  }
-
-  @Test( timeout = TestUtils.MEDIUM_TIMEOUT )
-  public void testDefaultJsonMimeTypeHandlingKnox678() throws Exception {
-    LOG_ENTER();
-
-    MockServer mock = new MockServer( "REPEAT", true );
-
-    params.put( "MOCK_SERVER_PORT", mock.getPort() );
-
-    String topoStr = TestUtils.merge( DAT, "topologies/test-knox678-utf8-chars-topology.xml", params );
-    File topoFile = new File( config.getGatewayTopologyDir(), "topology.xml" );
-    FileUtils.writeStringToFile( topoFile, topoStr );
-
-    topos.reloadTopologies();
-
-    String uname = "guest";
-    String pword = uname + "-password";
-
-    mock.expect().respond().contentType( "application/json" ).content( "{\"msg\":\"H\u00eallo\"}", Charset.forName( "UTF8" ) );
-    given()
-        //.log().all()
-        .auth().preemptive().basic( uname, pword )
-        .expect()
-        //.log().all()
-        .statusCode( HttpStatus.SC_OK )
-        .body( "msg", is( "H\u00eallo" ) )
-        .when().get( gatewayUrl + "/topology/repeat" );
-    assertThat( mock.isEmpty(), is(true) );
-
-    mock.expect().respond().contentType( "application/json" ).content( "{\"msg\":\"H\u00eallo\"}", Charset.forName( "UTF8" ) );
-    given()
-        //.log().all()
-        .auth().preemptive().basic( uname, pword )
-        .expect()
-        //.log().all()
-        .statusCode( HttpStatus.SC_OK )
-        .body( "msg", is( "H\u00eallo" ) )
-        .when().get( gatewayUrl + "/topology/repeat" );
-    assertThat( mock.isEmpty(), is(true) );
-
-    mock.expect().respond().contentType( "application/octet-stream" ).content( "H\u00eallo".getBytes() );
-    byte[] body = given()
-        //.log().all()
-        .auth().preemptive().basic( uname, pword )
-        .expect()
-        //.log().all()
-        .statusCode( HttpStatus.SC_OK )
-        //.contentType( "application/octet-stream" )
-        .when().get( gatewayUrl + "/topology/repeat" ).andReturn().asByteArray();
-    assertThat( body, is(equalTo("H\u00eallo".getBytes())) );
-    assertThat( mock.isEmpty(), is(true) );
-
-    LOG_EXIT();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/applications/readme.txt
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/applications/readme.txt b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/applications/readme.txt
deleted file mode 100644
index cd2eef8..0000000
--- a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/applications/readme.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-##########################################################################
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##########################################################################
-This file is here to help the tests find the parent directory.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/readme.txt
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/readme.txt b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/readme.txt
deleted file mode 100644
index cd2eef8..0000000
--- a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/readme.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-##########################################################################
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##########################################################################
-This file is here to help the tests find the parent directory.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/repeat/0.0.0/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/repeat/0.0.0/rewrite.xml b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/repeat/0.0.0/rewrite.xml
deleted file mode 100644
index 93c877a..0000000
--- a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/repeat/0.0.0/rewrite.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<rules>
-
-    <rule dir="IN" name="REPEAT/default/root/inbound" pattern="*://*:*/**/repeat/?{**}">
-      <rewrite template="{$serviceUrl[REPEAT]}/?{**}"/>
-    </rule>
-
-    <rule dir="IN" name="REPEAT/default/path/inbound" pattern="*://*:*/**/repeat/{path=**}?{**}">
-      <rewrite template="{$serviceUrl[REPEAT]}/{path=**}?{**}"/>
-    </rule>
-
-</rules>

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/repeat/0.0.0/service.xml
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/repeat/0.0.0/service.xml b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/repeat/0.0.0/service.xml
deleted file mode 100644
index 49daa4c..0000000
--- a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/services/repeat/0.0.0/service.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<service role="REPEAT" name="default" version="0.0.0">
-    <routes>
-        <route path="/repeat/?**"/>
-        <route path="/repeat/**?**"/>
-    </routes>
-</service>

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml
deleted file mode 100644
index fbbab48..0000000
--- a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/topologies/test-knox678-utf8-chars-topology.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<topology>
-    <gateway>
-        <provider>
-            <role>authentication</role>
-            <name>ShiroProvider</name>
-            <enabled>true</enabled>
-            <param>
-                <name>main.ldapRealm</name>
-                <value>org.apache.hadoop.gateway.shirorealm.KnoxLdapRealm</value>
-            </param>
-            <param>
-                <name>main.ldapRealm.userDnTemplate</name>
-                <value>uid={0},ou=people,dc=hadoop,dc=apache,dc=org</value>
-            </param>
-            <param>
-                <name>main.ldapRealm.contextFactory.url</name>
-                <value>$LDAP_URL</value>
-            </param>
-            <param>
-                <name>main.ldapRealm.contextFactory.authenticationMechanism</name>
-                <value>simple</value>
-            </param>
-            <param>
-                <name>urls./**</name>
-                <value>authcBasic</value>
-            </param>
-        </provider>
-        <provider>
-            <role>identity-assertion</role>
-            <name>Default</name>
-            <enabled>true</enabled>
-        </provider>
-    </gateway>
-    <service>
-        <role>REPEAT</role>
-        <url>http://localhost:${MOCK_SERVER_PORT}/repeat-context</url>
-    </service>
-</topology>

http://git-wip-us.apache.org/repos/asf/knox/blob/3d37f7b2/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/users.ldif
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/users.ldif b/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/users.ldif
deleted file mode 100644
index b982cb3..0000000
--- a/gateway-test/src/test/resources/org/apache/hadoop/gateway/GatewayMultiFuncTest/users.ldif
+++ /dev/null
@@ -1,42 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-version: 1
-
-dn: dc=hadoop,dc=apache,dc=org
-objectclass: organization
-objectclass: dcObject
-o: Hadoop
-dc: hadoop
-
-# entry for a sample people container
-# please replace with site specific values
-dn: ou=people,dc=hadoop,dc=apache,dc=org
-objectclass:top
-objectclass:organizationalUnit
-ou: people
-
-# entry for a sample end user
-# please replace with site specific values
-dn: uid=guest,ou=people,dc=hadoop,dc=apache,dc=org
-objectclass:top
-objectclass:person
-objectclass:organizationalPerson
-objectclass:inetOrgPerson
-cn: Guest
-sn: User
-uid: guest
-userPassword:guest-password
\ No newline at end of file


[2/3] knox git commit: Revert "[KNOX-680] - Update Knox's HttpClient dependency to latest version"

Posted by km...@apache.org.
Revert "[KNOX-680] - Update Knox's HttpClient dependency to latest version"

This reverts commit 5f0bfdf8791c28b8ed804bc81ad48c2e1223ea15.


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

Branch: refs/heads/master
Commit: 5f27642e98d9fbe101ddab13153319d4b94717aa
Parents: 8bee259
Author: Kevin Minder <km...@apache.org>
Authored: Sat Mar 5 16:11:35 2016 -0500
Committer: Kevin Minder <km...@apache.org>
Committed: Sat Mar 5 16:11:35 2016 -0500

----------------------------------------------------------------------
 CHANGES                                         |  1 -
 .../hadoop/gateway/GatewayMultiFuncTest.java    |  1 +
 .../hadoop/gateway/GatewaySslFuncTest.java      | 31 ++++++++++++++++++--
 pom.xml                                         |  2 +-
 4 files changed, 30 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/5f27642e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 06efd2d..2877e83 100644
--- a/CHANGES
+++ b/CHANGES
@@ -8,7 +8,6 @@ Release Notes - Apache Knox - Version 0.9.0
     * [KNOX-677] - Upgrade to latest Groovy
     * [KNOX-675] - Upgrade Knox's Jetty dependency to latest 9.x
     * [KNOX-678] - Malformed UTF-8 characters in JSON Response
-    * [KNOX-680] - Update Knox's HttpClient dependency to latest version
 ** Bug
 
 ------------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/knox/blob/5f27642e/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
index 8c29ce5..47fe9bd 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
@@ -81,6 +81,7 @@ public class GatewayMultiFuncTest {
   @BeforeClass
   public static void setupSuite() throws Exception {
     LOG_ENTER();
+    RestAssured.config = newConfig().connectionConfig(connectionConfig().closeIdleConnectionsAfterEachResponse());
     //appenders = NoOpAppender.setUp();
     setupLdap();
     setupGateway();

http://git-wip-us.apache.org/repos/asf/knox/blob/5f27642e/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
index 7032236..b419231 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.gateway;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URL;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
@@ -32,10 +33,11 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.ServiceLoader;
 import java.util.UUID;
-import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLHandshakeException;
 import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
 import javax.xml.transform.stream.StreamSource;
@@ -60,6 +62,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.X509HostnameVerifier;
 import org.apache.http.impl.auth.BasicScheme;
 import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.impl.client.BasicCredentialsProvider;
@@ -233,11 +236,14 @@ public class GatewaySslFuncTest {
     context.setAuthCache( authCache );
 
     CloseableHttpClient client = HttpClients.custom()
+        .setHostnameVerifier( new TrustAllHosts() )
+        .setSslcontext( createInsecureSslContext() )
         .setSSLSocketFactory(
             new SSLConnectionSocketFactory(
                 createInsecureSslContext(),
                 new String[]{"TLSv1.2"},
                 new String[]{"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"},
+
                 new TrustAllHosts() ) )
         .build();
     HttpGet request = new HttpGet( serviceUrl );
@@ -255,6 +261,8 @@ public class GatewaySslFuncTest {
 
     try {
       client = HttpClients.custom()
+          .setHostnameVerifier( new TrustAllHosts() )
+          .setSslcontext( createInsecureSslContext() )
           .setSSLSocketFactory(
               new SSLConnectionSocketFactory(
                   createInsecureSslContext(),
@@ -270,6 +278,8 @@ public class GatewaySslFuncTest {
     }
 
     client = HttpClients.custom()
+        .setHostnameVerifier( new TrustAllHosts() )
+        .setSslcontext( createInsecureSslContext() )
         .setSSLSocketFactory(
             new SSLConnectionSocketFactory(
                 createInsecureSslContext(),
@@ -285,11 +295,26 @@ public class GatewaySslFuncTest {
     LOG_EXIT();
   }
 
-  public static class TrustAllHosts implements HostnameVerifier {
+  public static class TrustAllHosts implements X509HostnameVerifier {
+    @Override
+    public void verify( String host, SSLSocket ssl ) throws IOException {
+      // Trust all hostnames.
+    }
+
+    @Override
+    public void verify( String host, X509Certificate cert ) throws SSLException {
+      // Trust all hostnames.
+    }
+
+    @Override
+    public void verify( String host, String[] cns, String[] subjectAlts ) throws SSLException {
+      // Trust all hostnames.
+    }
+
     @Override
     public boolean verify( String host, SSLSession sslSession ) {
       // Trust all hostnames.
-      return true;
+      return false;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f27642e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b1eb6c1..f185dac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -739,7 +739,7 @@
             <dependency>
                 <groupId>org.apache.httpcomponents</groupId>
                 <artifactId>httpclient</artifactId>
-                <version>4.5.2</version>
+                <version>4.3.6</version>
             </dependency>
             <dependency>
                 <groupId>joda-time</groupId>