use of org.apache.knox.gateway.identityasserter.common.filter.IdentityAsserterHttpServletRequestWrapper in project knox by apache.
the class IdentityAssertionHttpServletRequestWrapperTest method testInsertUserNameInNullQueryString.
@Test
public void testInsertUserNameInNullQueryString() {
String input = null;
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"));
}
use of org.apache.knox.gateway.identityasserter.common.filter.IdentityAsserterHttpServletRequestWrapper in project knox by apache.
the class IdentityAssertionHttpServletRequestWrapperTest method testInsertUserNameInPostMethodWithIso88591Encoding.
@Test
public void testInsertUserNameInPostMethodWithIso88591Encoding() throws IOException {
String inputBody = "jar=%2Ftmp%2FGatewayWebHdfsFuncTest%2FtestJavaMapReduceViaWebHCat%2Fhadoop-examples.jar&class=org.apache.org.apache.hadoop.examples.WordCount&arg=%2Ftmp%2FGatewayWebHdfsFuncTest%2FtestJavaMapReduceViaTempleton%2Finput&arg=%2Ftmp%2FGatewayWebHdfsFuncTest%2FtestJavaMapReduceViaTempleton%2Foutput";
MockHttpServletRequest request = new MockHttpServletRequest();
request.setInputStream(new MockServletInputStream(new ByteArrayInputStream(inputBody.getBytes("UTF-8"))));
request.setContentType("application/x-www-form-urlencoded");
request.setCharacterEncoding("ISO-8859-1");
request.setMethod("POST");
IdentityAsserterHttpServletRequestWrapper wrapper = new IdentityAsserterHttpServletRequestWrapper(request, "output-user");
String outputBody = IOUtils.toString(wrapper.getInputStream(), wrapper.getCharacterEncoding());
String output = wrapper.getQueryString();
assertThat(output, containsString("user.name=output-user"));
}
Aggregations