You are here

public function AuthcacheVarnishTestDefaultValidation::testRejectIfForwardedForEmpty in Authenticated User Page Caching (Authcache) 7.2

Request is not comming through varnish if X-Forwarded-For is empty.

File

modules/authcache_varnish/authcache_varnish.test, line 455
Test cases for authcache_varnish module.

Class

AuthcacheVarnishTestDefaultValidation
Unit tests for authcache_varnish_request_validate().

Code

public function testRejectIfForwardedForEmpty() {
  $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'] = "";
  $_SERVER['REMOTE_ADDR'] = $this->proxyIp;
  $this
    ->assertIdentical(FALSE, authcache_varnish_request_validate(), 'Reject request when X-Forwarded-For is empty');
  $_SERVER['REMOTE_ADDR'] = $this->proxy2Ip;
  $this
    ->assertIdentical(FALSE, authcache_varnish_request_validate(), 'Reject request when X-Forwarded-For is empty');
  $_SERVER['REMOTE_ADDR'] = $this->untrustedIp;
  $this
    ->assertIdentical(FALSE, authcache_varnish_request_validate(), 'Reject request when X-Forwarded-For is empty');
}