Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13950#discussion_r75185921
  
    --- Diff: core/src/test/scala/org/apache/spark/ui/UISuite.scala ---
    @@ -190,6 +193,42 @@ class UISuite extends SparkFunSuite {
         }
       }
     
    +  test("verify proxy rewrittenURI") {
    +    val prefix = "/proxy/worker-id"
    +    val target = "http://localhost:8081";
    +    val path = "/proxy/worker-id/json"
    +    var rewrittenURI = JettyUtils.createProxyURI(prefix, target, path, 
null)
    +    assert(rewrittenURI.toString().equals("http://localhost:8081/json";))
    +    rewrittenURI = JettyUtils.createProxyURI(prefix, target, path, 
"test=done")
    +    
assert(rewrittenURI.toString().equals("http://localhost:8081/json?test=done";))
    +    rewrittenURI = JettyUtils.createProxyURI(prefix, target, 
"/proxy/worker-id", null)
    +    assert(rewrittenURI.toString().equals("http://localhost:8081";))
    +    rewrittenURI = JettyUtils.createProxyURI(prefix, target, 
"/proxy/worker-noid/json", null)
    +    assert(rewrittenURI == null)
    +  }
    +
    +  test("verify rewriting location header for reverse proxy") {
    +    val clientRequest = mock(classOf[HttpServletRequest])
    +    var headerValue = "http://localhost:4040/jobs";
    +    val prefix = "/proxy/worker-id"
    +    val targetUri = URI.create("http://localhost:4040";)
    +    when(clientRequest.getScheme()).thenReturn("http")
    +    when(clientRequest.getHeader("host")).thenReturn("localhost:8080")
    +    var newHeader = JettyUtils.createProxyLocationHeader(
    +                                  prefix,
    +                                  headerValue,
    +                                  clientRequest,
    +                                  targetUri)
    +    
assert(newHeader.toString().equals("http://localhost:8080/proxy/worker-id/jobs";))
    +    headerValue = "http://localhost:4041/jobs";
    +    newHeader = JettyUtils.createProxyLocationHeader(
    +                                  prefix,
    --- End diff --
    
    indentation


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to