KNOX-673 Ambari UI proxy support with related REST API support changes
Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/ff8c1e25
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/ff8c1e25
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/ff8c1e25
Branch: refs/heads/master
Commit: ff8c1e250d0dec9e274bed548186af22d66af71a
Parents: 8cb451d
Author: Sumit Gupta <sumit@apache.org>
Authored: Tue Mar 22 16:25:30 2016 -0400
Committer: Sumit Gupta <sumit@apache.org>
Committed: Tue Mar 22 16:25:43 2016 -0400
----------------------------------------------------------------------
.../filter/rewrite/i18n/UrlRewriteMessages.java | 2 +
.../filter/rewrite/impl/UrlRewriteRequest.java | 16 +-
.../resources/services/ambari/2.2.0/rewrite.xml | 4 +
.../resources/services/ambari/2.2.0/service.xml | 6 +-
.../services/ambariui/2.2.0/rewrite.xml | 55 +++
.../services/ambariui/2.2.0/service.xml | 34 ++
.../dispatch/PassAllHeadersDispatch.java | 12 +-
.../hadoop/test/mock/MockRequestMatcher.java | 31 +-
.../gateway/AmbariServiceDefinitionTest.java | 88 +++-
.../encrypted-response.txt | 1 +
.../post-data-wrong-type.json | 421 +++++++++++++++++++
.../unwise-character-response.json | 410 ++++++++++++++++++
.../gateway/util/urltemplate/Expander.java | 22 +-
.../gateway/util/urltemplate/ExpanderTest.java | 7 +-
14 files changed, 1073 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
index 1af7974..4f304bc 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
@@ -82,4 +82,6 @@ public interface UrlRewriteMessages {
@Message( level = MessageLevel.TRACE, text = "No rule matching URL: {0}, direction: {1}"
)
void noRuleMatchingUrl( Template inputUri, UrlRewriter.Direction direction );
+ @Message( level = MessageLevel.TRACE, text = "Failed to decode query string: {0}" )
+ void failedToDecodeQueryString( String queryString, @StackTrace(level = MessageLevel.TRACE)
Exception exception );
}
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/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..73ec5bb 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
@@ -28,6 +28,7 @@ import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteStreamFilterFactor
import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
+import org.apache.hadoop.gateway.util.MimeTypes;
import org.apache.hadoop.gateway.util.urltemplate.Parser;
import org.apache.hadoop.gateway.util.urltemplate.Resolver;
import org.apache.hadoop.gateway.util.urltemplate.Template;
@@ -40,7 +41,9 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
+import java.net.URLDecoder;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
@@ -150,7 +153,12 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements
Resolver
public String getQueryString() {
String[] split = splitTargetUrl( getTargetUrl() );
if( split.length > 1 ) {
- return split[1];
+ try {
+ return URLDecoder.decode(split[1], "UTF-8");
+ } catch ( UnsupportedEncodingException e ) {
+ LOG.failedToDecodeQueryString(split[1], e);
+ return split[1];
+ }
} else {
return null;
}
@@ -215,6 +223,12 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements
Resolver
if( getContentLength() != 0 ) {
MimeType mimeType = getMimeType();
UrlRewriteFilterContentDescriptor filterContentConfig = getRewriteFilterConfig( bodyFilterName,
mimeType );
+ if (filterContentConfig != null) {
+ String asType = filterContentConfig.asType();
+ if ( asType != null && asType.trim().length() > 0 ) {
+ mimeType = MimeTypes.create(asType, getCharacterEncoding());
+ }
+ }
InputStream stream = UrlRewriteStreamFilterFactory.create( mimeType, null, input, rewriter,
this, UrlRewriter.Direction.IN, filterContentConfig );
input = new UrlRewriteRequestStream( stream );
}
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml
b/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml
index 68f2791..7c2a825 100644
--- a/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml
+++ b/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml
@@ -27,4 +27,8 @@
<apply path="$.**.href" rule="AMBARI/ambari/href/outbound"/>
</content>
</filter>
+ <filter name="AMBARI/ambari/api/inbound">
+ <content type="application/x-www-form-urlencoded" asType="application/octet-stream">
+ </content>
+ </filter>
</rules>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/service.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/service.xml
b/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/service.xml
index 0bd2150..bc670f2 100644
--- a/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/service.xml
+++ b/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/service.xml
@@ -14,10 +14,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<service role="AMBARI" name="ambari" version="2.7.0">
+<service role="AMBARI" name="ambari" version="2.2.0">
<routes>
<route path="/ambari/api/v1/**">
<rewrite apply="AMBARI/ambari/api/outbound" to="response.body"/>
+ <rewrite apply="AMBARI/ambari/api/inbound" to="request.body"/>
+ </route>
+ <route path="/ambari/api/v1/persist/*?*">
+ <rewrite apply="AMBARI/ambari/api/inbound" to="request.body"/>
</route>
</routes>
<dispatch classname="org.apache.hadoop.gateway.dispatch.PassAllHeadersDispatch"/>
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/gateway-service-definitions/src/main/resources/services/ambariui/2.2.0/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/ambariui/2.2.0/rewrite.xml
b/gateway-service-definitions/src/main/resources/services/ambariui/2.2.0/rewrite.xml
new file mode 100644
index 0000000..484c36b
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/ambariui/2.2.0/rewrite.xml
@@ -0,0 +1,55 @@
+<!--
+ 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="AMBARIUI/ambari/inbound/root" pattern="*://*:*/**/ambari/">
+ <rewrite template="{$serviceUrl[AMBARIUI]}/"/>
+ </rule>
+ <rule dir="IN" name="AMBARIUI/ambari/inbound/path" pattern="*://*:*/**/ambari/{**}">
+ <rewrite template="{$serviceUrl[AMBARIUI]}/{**}"/>
+ </rule>
+ <rule dir="IN" name="AMBARIUI/ambari/inbound/query" pattern="*://*:*/**/ambari/{**}?{**}">
+ <rewrite template="{$serviceUrl[AMBARIUI]}/{**}?{**}"/>
+ </rule>
+
+ <rule dir="OUT" name="AMBARIUI/ambari/outbound/extrapath">
+ <rewrite template="{$frontend[path]}/ambari/api/v1"/>
+ </rule>
+
+ <rule dir="OUT" name="AMBARIUI/ambari/outbound/whitelogo">
+ <rewrite template="img/logo-white.png"/>
+ </rule>
+ <rule dir="OUT" name="AMBARIUI/ambari/outbound/logohref">
+ <rewrite template="#/main/dashboard"/>
+ </rule>
+ <rule dir="OUT" name="AMBARIUI/ambari/outbound/ambariview">
+ <rewrite template="img/ambari-view-default.png"/>
+ </rule>
+ <rule dir="OUT" name="AMBARIUI/ambari/outbound/img" pattern="/img/{**}">
+ <rewrite template="{$frontend[url]}/ambari/img/{**}"/>
+ </rule>
+
+ <filter name="AMBARIUI/ambari/outbound/links">
+ <content type="*/x-javascript">
+ <apply path="/api/v1" rule="AMBARIUI/ambari/outbound/extrapath"/>
+ <apply path="/img/logo-white.png" rule="AMBARIUI/ambari/outbound/whitelogo"/>
+ <apply path="/#/main/dashboard" rule="AMBARIUI/ambari/outbound/logohref"/>
+ <apply path="/img/ambari-view-default.png" rule="AMBARIUI/ambari/outbound/ambariview"/>
+ </content>
+ <content type="*/html">
+ </content>
+ </filter>
+</rules>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/gateway-service-definitions/src/main/resources/services/ambariui/2.2.0/service.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/ambariui/2.2.0/service.xml
b/gateway-service-definitions/src/main/resources/services/ambariui/2.2.0/service.xml
new file mode 100644
index 0000000..786b197
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/ambariui/2.2.0/service.xml
@@ -0,0 +1,34 @@
+<!--
+ 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="AMBARIUI" name="ambariui" version="2.2.0">
+ <routes>
+ <route path="/ambari">
+ <rewrite apply="AMBARIUI/ambari/inbound/root" to="request.url"/>
+ </route>
+ <route path="/ambari/**">
+ <rewrite apply="AMBARIUI/ambari/inbound/path" to="request.url"/>
+ </route>
+ <route path="/ambari/**?**">
+ <rewrite apply="AMBARIUI/ambari/inbound/query" to="request.url"/>
+ </route>
+ <route path="/ambari/**/app.js">
+ <rewrite apply="AMBARIUI/ambari/outbound/links" to="response.body"/>
+ </route>
+ </routes>
+ <dispatch classname="org.apache.hadoop.gateway.dispatch.PassAllHeadersDispatch"/>
+</service>
+
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java
index 7b8260d..92f9ed7 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/PassAllHeadersDispatch.java
@@ -18,10 +18,20 @@
package org.apache.hadoop.gateway.dispatch;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
public class PassAllHeadersDispatch extends DefaultDispatch {
+ private static Set<String> REQUEST_EXCLUDE_HEADERS;
+
+ @Override
+ public void init() {
+ super.init();
+ REQUEST_EXCLUDE_HEADERS = new HashSet<>();
+ REQUEST_EXCLUDE_HEADERS.add("Content-Length");
+ }
+
@Override
public Set<String> getOutboundResponseExcludeHeaders() {
return Collections.EMPTY_SET;
@@ -29,6 +39,6 @@ public class PassAllHeadersDispatch extends DefaultDispatch {
@Override
public Set<String> getOutboundRequestExcludeHeaders() {
- return Collections.EMPTY_SET;
+ return REQUEST_EXCLUDE_HEADERS;
}
}
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
index 3ff8ff9..378f02f 100644
--- a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
+++ b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
@@ -19,6 +19,9 @@ package org.apache.hadoop.test.mock;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.message.BasicNameValuePair;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
@@ -35,9 +38,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalToIgnoringCase;
import static org.xmlmatchers.XmlMatchers.isEquivalentTo;
@@ -264,34 +265,24 @@ public class MockRequestMatcher {
// body and we don't want that to happen.
if( queryParams != null ) {
String queryString = request.getQueryString();
- Map<String,String[]> requestParams = parseQueryString( queryString == null ?
"" : queryString );
+ List<NameValuePair> requestParams = parseQueryString( queryString == null ? ""
: queryString );
for( String name: queryParams.keySet() ) {
- String[] values = requestParams.get( name );
assertThat(
"Request " + request.getMethod() + " " + request.getRequestURL() +
" query string " + queryString + " is missing parameter '" + name + "'",
- values, notNullValue() );
- assertThat(
- "Request " + request.getMethod() + " " + request.getRequestURL() +
- " query string " + queryString + " is missing a value for parameter '" +
name + "'",
- Arrays.asList( values ), hasItem( queryParams.get( name ) ) );
+ requestParams, hasItem( new BasicNameValuePair(name, queryParams.get(name)))
);
}
}
if( formParams != null ) {
String paramString = IOUtils.toString( request.getInputStream(), request.getCharacterEncoding()
);
- Map<String,String[]> requestParams = parseQueryString( paramString == null ?
"" : paramString );
+ List<NameValuePair> requestParams = parseQueryString( paramString == null ? ""
: paramString );
for( String name: formParams.keySet() ) {
- String[] actualValues = requestParams.get( name );
- assertThat(
- "Request " + request.getMethod() + " " + request.getRequestURL() +
- " form params " + paramString + " is missing parameter '" + name + "'",
- actualValues, notNullValue() );
String[] expectedValues = formParams.get( name );
for( String expectedValue : expectedValues ) {
assertThat(
"Request " + request.getMethod() + " " + request.getRequestURL() +
" form params " + paramString + " is missing a value " + expectedValue
+ " for parameter '" + name + "'",
- Arrays.asList( actualValues ), hasItem( expectedValue ) );
+ requestParams, hasItem( new BasicNameValuePair(name, expectedValue ) ));
}
}
}
@@ -331,10 +322,8 @@ public class MockRequestMatcher {
return "from=" + from + ", pathInfo=" + pathInfo;
}
- // Separate method to minimally scope the depreciation suppression.
- @SuppressWarnings("deprecation")
- private static Map<String,String[]> parseQueryString( String queryString ) {
- return javax.servlet.http.HttpUtils.parseQueryString( queryString );
+ private static List<NameValuePair> parseQueryString( String queryString ) {
+ return URLEncodedUtils.parse(queryString, Charset.defaultCharset());
}
}
http://git-wip-us.apache.org/repos/asf/knox/blob/ff8c1e25/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
index 11563d1..b9f19b7 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.gateway;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.hadoop.gateway.services.DefaultGatewayServices;
import org.apache.hadoop.gateway.services.GatewayServices;
import org.apache.hadoop.gateway.services.ServiceLifecycleException;
@@ -33,6 +34,7 @@ import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
@@ -49,7 +51,7 @@ import java.util.UUID;
import static com.jayway.restassured.RestAssured.given;
import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.notNullValue;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
public class AmbariServiceDefinitionTest {
@@ -236,4 +238,88 @@ public class AmbariServiceDefinitionTest {
LOG_EXIT();
}
+ @Test( timeout = TestUtils.MEDIUM_TIMEOUT )
+ public void unwiseCharacterRequest() throws Exception {
+ String username = "guest";
+ String password = "guest-password";
+ String serviceUrl = clusterUrl + "/ambari/api/v1/clusters/test/components";
+
+ mockAmbari.expect()
+ .method( "GET" )
+ .pathInfo( "/api/v1/clusters/test/components" )
+ .queryParam("ServiceComponentInfo/component_name", "APP_TIMELINE_SERVER|ServiceComponentInfo/category=MASTER")
+ .respond()
+ .status( HttpStatus.SC_OK )
+ .content( TestUtils.getResourceStream( DAT, "unwise-character-response.json" ) )
+ .contentType( "text/plain" );
+ //only assertion here is to make sure the request can be made successfully with the unwise
characters present
+ //in the request url
+ given()
+ .auth().preemptive().basic( username, password )
+ .queryParam("ServiceComponentInfo/component_name", "APP_TIMELINE_SERVER|ServiceComponentInfo/category=MASTER")
+ .expect()
+ .statusCode( HttpStatus.SC_OK )
+ .contentType( "text/plain" )
+ .when().get( serviceUrl ).asString();
+
+ LOG_EXIT();
+ }
+
+ @Test( timeout = TestUtils.MEDIUM_TIMEOUT )
+ public void encryptedResponse() throws Exception {
+ LOG_ENTER();
+
+ String username = "guest";
+ String password = "guest-password";
+ String serviceUrl = clusterUrl + "/ambari/api/v1/persist/CLUSTER_CURRENT_STATUS?_=1457977721091";
+
+ mockAmbari.expect()
+ .method( "GET" )
+ .pathInfo( "/api/v1/persist/CLUSTER_CURRENT_STATUS" )
+ .queryParam("_","1457977721091")
+ .respond()
+ .status( HttpStatus.SC_OK )
+ .content( TestUtils.getResourceStream( DAT, "encrypted-response.txt" ) )
+ .contentType( "text/plain" );
+
+ String body = given()
+ .auth().preemptive().basic( username, password )
+ .expect()
+ .statusCode( HttpStatus.SC_OK )
+ .contentType( "text/plain" )
+ .when().get( serviceUrl ).asString();
+
+ Assert.assertNotNull(body);
+ LOG_EXIT();
+ }
+
+ @Test( timeout = TestUtils.MEDIUM_TIMEOUT )
+ public void postDataWithWrongContentType() throws Exception {
+ LOG_ENTER();
+
+ String username = "guest";
+ String password = "guest-password";
+ String serviceUrl = clusterUrl + "/ambari/api/v1/stacks/HDP/versions/2.3/recommendations";
+
+ mockAmbari.expect()
+ .method( "POST" )
+ .pathInfo( "/api/v1/stacks/HDP/versions/2.3/recommendations" )
+ .content( TestUtils.getResourceStream( DAT, "post-data-wrong-type.json" ) )
+ .respond()
+ .status( HttpStatus.SC_OK )
+ .contentType( "application/x-www-form-urlencoded" );
+
+
+ String body = given()
+ .auth().preemptive().basic( username, password )
+ .content(IOUtils.toByteArray(TestUtils.getResourceStream( DAT, "post-data-wrong-type.json")))
+ .expect()
+ .statusCode( HttpStatus.SC_OK )
+ .contentType( "application/x-www-form-urlencoded" )
+ .when().post( serviceUrl ).asString();
+
+ Assert.assertNotNull(body);
+ LOG_EXIT();
+ }
+
}
|