public function AuthcacheVarnishTestDefaultValidation::testValidateRemoteAddrInReverseProxyAddresses in Authenticated User Page Caching (Authcache) 7.2
Test reverse proxy validation.
File
- modules/
authcache_varnish/ authcache_varnish.test, line 400 - Test cases for authcache_varnish module.
Class
- AuthcacheVarnishTestDefaultValidation
- Unit tests for authcache_varnish_request_validate().
Code
public function testValidateRemoteAddrInReverseProxyAddresses() {
$this
->variableSet('authcache_varnish_header', FALSE);
$this
->variableSet('reverse_proxy', 1);
$this
->variableSet('reverse_proxy_addresses', array(
$this->proxyIp,
$this->proxy2Ip,
));
$_SERVER['HTTP_X_FORWARDED_FOR'] = $this->remoteIp;
$_SERVER['REMOTE_ADDR'] = $this->proxyIp;
$this
->assertIdentical(TRUE, authcache_varnish_request_validate(), 'Accept request when remote address is in list of trusted proxies');
$_SERVER['REMOTE_ADDR'] = $this->proxy2Ip;
$this
->assertIdentical(TRUE, authcache_varnish_request_validate(), 'Accept request when remote address is in list of trusted proxies');
$_SERVER['REMOTE_ADDR'] = $this->untrustedIp;
$this
->assertIdentical(FALSE, authcache_varnish_request_validate(), 'Reject request when remote address is not in list of trusted proxies');
}