Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12870954
ProxyTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
ProxyTest.php
View Options
<?php
/**
* Tests the bug described in T492: when using a front-end server
* with SSL termination, back-end should serve http:// links.
*/
class
ProxyTest
extends
TestCase
{
public
function
testProxiesAndHttpsLinksInteraction
()
{
// These cases should be in one test: if split in several tests,
// the application configuration isn't reset correctly and we lost.
// CASE I
//
// By default, we don't trust proxies, and we don't receive proxy
// information, so links are HTTP.
App
::
make
(
'config'
)->
set
(
'app.proxy'
,
[]);
$this
->
visit
(
'/'
)
->
see
(
'http://localhost/'
);
// This header, if trusted, means we serve HTTPS links.
$server
=
[
'X-Forwarded-Proto'
=>
'https'
];
// CASE II
// When we don't trust proxies
// and reverse proxy tell us it's for HTTPS
// we serve HTTP links, ignoring X-Forwarded-Proto.
App
::
make
(
'config'
)->
set
(
'app.proxy'
,
[]);
$this
->
get
(
'/'
,
$server
);
$this
->
see
(
'http://localhost'
);
// CASE III
// When we trust all proxies
// and reverse proxy tell us it's for HTTPS
// we serve HTTP links, according X-Forwarded-Proto.
App
::
make
(
'config'
)->
set
(
'app.proxy'
,
[
'*'
]);
$this
->
get
(
'/'
,
$server
);
$this
->
see
(
'https://localhost/'
);
// CASE IV
// When we don't trust the current proxy
// and reverse proxy tell us it's for HTTPS
// we serve HTTP links, ignoring X-Forwarded-Proto.
App
::
make
(
'config'
)->
set
(
'app.proxy'
,
[
'1.2.3.4'
]);
$this
->
get
(
'/'
,
$server
);
$this
->
see
(
'http://localhost'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Nov 17, 16:03 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3171055
Default Alt Text
ProxyTest.php (1 KB)
Attached To
Mode
rGROVE Auth Grove
Attached
Detach File
Event Timeline
Log In to Comment