[ 
https://issues.apache.org/jira/browse/KNOX-2710?focusedWorklogId=738842&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-738842
 ]

ASF GitHub Bot logged work on KNOX-2710:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Mar/22 15:32
            Start Date: 09/Mar/22 15:32
    Worklog Time Spent: 10m 
      Work Description: moresandeep commented on a change in pull request #544:
URL: https://github.com/apache/knox/pull/544#discussion_r822777101



##########
File path: 
gateway-provider-identity-assertion-no-doas/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionNoDoAsHttpServletRequestWrapperTest.java
##########
@@ -0,0 +1,167 @@
+/*
+ * 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.knox.gateway.identityasserter.filter;
+
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.test.mock.MockHttpServletRequest;
+import org.apache.knox.test.mock.MockServletInputStream;
+import org.junit.After;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+
+public class IdentityAssertionNoDoAsHttpServletRequestWrapperTest {
+  @After
+  public void resetSystemProps() {
+    System.setProperty(GatewayConfig.HADOOP_KERBEROS_SECURED, "false");
+  }
+
+  @Test
+  public void testNoUserNameInPostMethod() 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( StandardCharsets.UTF_8 ) ) ) );
+    request.setCharacterEncoding( StandardCharsets.UTF_8.name() );
+    request.setContentType( "application/x-www-form-urlencoded" );
+    request.setMethod("POST");
+
+    IdentityAsserterNoDoAsHttpServletRequestWrapper wrapper
+        = new IdentityAsserterNoDoAsHttpServletRequestWrapper( request, 
"output-user" );
+
+    String output = wrapper.getQueryString();
+    assertThat( output, containsString( "" ) );
+  }
+
+  @Test
+  public void testNoUserNameInPostMethodWithoutEncoding() 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( StandardCharsets.UTF_8 ) ) ) );
+    request.setContentType( "application/x-www-form-urlencoded" );
+    request.setMethod("POST");
+
+    IdentityAsserterNoDoAsHttpServletRequestWrapper wrapper
+        = new IdentityAsserterNoDoAsHttpServletRequestWrapper( request, 
"output-user" );
+
+    String output = wrapper.getQueryString();
+    // make sure principal is not added
+    assertThat( output, containsString( "" ) );

Review comment:
       yeah. looks funny, i'll change it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 738842)
    Time Spent: 1h 10m  (was: 1h)

> Identity assertion provider for services without doAs support
> -------------------------------------------------------------
>
>                 Key: KNOX-2710
>                 URL: https://issues.apache.org/jira/browse/KNOX-2710
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: Server
>            Reporter: Sandeep More
>            Assignee: Sandeep More
>            Priority: Major
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> There might be services (e.g. RStudio) which do not support trusted proxy and 
> that might break with the doAs parameter at the end of the URL. We need to be 
> able to implement an identity assertion provider that can skip doAs and which 
> is configurable.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to