public function AuthcacheVarnishTestDefaultValidation::testValidateCustomClientIPHeader in Authenticated User Page Caching (Authcache) 7.2
Test reverse proxy validation when reverse_proxy_header variable is set.
File
- modules/
authcache_varnish/ authcache_varnish.test, line 418 - Test cases for authcache_varnish module.
Class
- AuthcacheVarnishTestDefaultValidation
- Unit tests for authcache_varnish_request_validate().
Code
public function testValidateCustomClientIPHeader() {
$this
->variableSet('authcache_varnish_header', FALSE);
$this
->variableSet('reverse_proxy', 1);
$this
->variableSet('reverse_proxy_header', 'HTTP_X_CLUSTER_CLIENT_IP');
$this
->variableSet('reverse_proxy_addresses', array(
$this->proxyIp,
$this->proxy2Ip,
));
$_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] = $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');
}