]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/http/HttpUtils/ServerUrlTest.php
6 namespace Shaarli\Http
;
8 require_once 'application/http/HttpUtils.php';
11 * Unitary tests for server_url()
13 class ServerUrlTest
extends \Shaarli\TestCase
16 * Detect if the server uses SSL
18 public function testHttpsScheme()
25 'SERVER_NAME' => 'host.tld',
26 'SERVER_PORT' => '443'
32 'https://host.tld:8080',
36 'SERVER_NAME' => 'host.tld',
37 'SERVER_PORT' => '8080'
44 * Detect a Proxy that sets Forwarded-Host
46 public function testHttpsProxyForwardedHost()
49 'https://host.tld:8080',
52 'HTTP_X_FORWARDED_PROTO' => 'https',
53 'HTTP_X_FORWARDED_PORT' => '8080',
54 'HTTP_X_FORWARDED_HOST' => 'host.tld'
60 'https://host.tld:4974',
63 'HTTP_X_FORWARDED_PROTO' => 'https, https',
64 'HTTP_X_FORWARDED_PORT' => '4974, 80',
65 'HTTP_X_FORWARDED_HOST' => 'host.tld, example.com'
72 * Detect a Proxy with SSL enabled
74 public function testHttpsProxyForward()
77 'https://host.tld:8080',
81 'SERVER_NAME' => 'host.tld',
82 'SERVER_PORT' => '80',
83 'HTTP_X_FORWARDED_PROTO' => 'https',
84 'HTTP_X_FORWARDED_PORT' => '8080'
94 'SERVER_NAME' => 'host.tld',
95 'SERVER_PORT' => '80',
96 'HTTP_X_FORWARDED_PROTO' => 'https'
106 'SERVER_NAME' => 'host.tld',
107 'SERVER_PORT' => '80',
108 'HTTP_X_FORWARDED_PROTO' => 'https',
109 'HTTP_X_FORWARDED_PORT' => '443'
115 'https://host.tld:4974',
119 'SERVER_NAME' => 'host.tld',
120 'SERVER_PORT' => '80',
121 'HTTP_X_FORWARDED_PROTO' => 'https, https',
122 'HTTP_X_FORWARDED_PORT' => '4974, 80'
129 * Detect if the server uses a specific port (!= 80)
131 public function testPort()
135 'http://host.tld:8080',
139 'SERVER_NAME' => 'host.tld',
140 'SERVER_PORT' => '8080'
147 'https://host.tld:8080',
151 'SERVER_NAME' => 'host.tld',
152 'SERVER_PORT' => '8080'
159 * HTTP server on port 80
161 public function testStandardHttpPort()
168 'SERVER_NAME' => 'host.tld',
169 'SERVER_PORT' => '80'
176 * HTTPS server on port 443
178 public function testStandardHttpsPort()
185 'SERVER_NAME' => 'host.tld',
186 'SERVER_PORT' => '443'
193 * Misconfigured server (see #1022): Proxy HTTP but 443
195 public function testHttpWithPort433()
202 'SERVER_NAME' => 'host.tld',
203 'SERVER_PORT' => '80',
204 'HTTP_X_FORWARDED_PROTO' => 'http',
205 'HTTP_X_FORWARDED_PORT' => '443'
215 'SERVER_NAME' => 'host.tld',
216 'SERVER_PORT' => '80',
217 'HTTP_X_FORWARDED_PROTO' => 'https, http',
218 'HTTP_X_FORWARDED_PORT' => '443, 80'