]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Add tests to cover new server_url behavior 899/head
authorStephen Muth <smuth4@gmail.com>
Wed, 12 Jul 2017 17:57:47 +0000 (17:57 +0000)
committerStephen Muth <smuth4@gmail.com>
Wed, 12 Jul 2017 17:57:47 +0000 (17:57 +0000)
tests/HttpUtils/ServerUrlTest.php

index 7fdad6594961e5995d40f050fc3f90fbeded7f3d..dac02b3e77cab58cdf05a57fbecfa3cabae1247b 100644 (file)
@@ -38,6 +38,34 @@ class ServerUrlTest extends PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Detect a Proxy that sets Forwarded-Host
+     */
+    public function testHttpsProxyForwardedHost()
+    {
+        $this->assertEquals(
+            'https://host.tld:8080',
+            server_url(
+                array(
+                    'HTTP_X_FORWARDED_PROTO' => 'https',
+                    'HTTP_X_FORWARDED_PORT' => '8080',
+                    'HTTP_X_FORWARDED_HOST' => 'host.tld'
+                )
+            )
+        );
+
+        $this->assertEquals(
+            'https://host.tld:4974',
+            server_url(
+                array(
+                    'HTTP_X_FORWARDED_PROTO' => 'https, https',
+                    'HTTP_X_FORWARDED_PORT' => '4974, 80',
+                    'HTTP_X_FORWARDED_HOST' => 'host.tld, example.com'
+                )
+            )
+        );
+    }
+
     /**
      * Detect a Proxy with SSL enabled
      */