You are here

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

Request has correct custom passphrase header.

File

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

Class

AuthcacheVarnishTestDefaultValidation
Unit tests for authcache_varnish_request_validate().

Code

public function testValidateCustomPassphraseHeader() {
  $this
    ->variableSet('authcache_varnish_passphrase', 'sEcr3t!');
  $this
    ->variableSet('authcache_varnish_passphrase_header', 'HTTP_X_CUSTOM_PASSPHRASE_HEADER');
  $_SERVER['REMOTE_ADDR'] = $this->proxyIp;
  $_SERVER['HTTP_X_CUSTOM_PASSPHRASE_HEADER'] = 'sEcr3t!';
  $this
    ->assertIdentical(TRUE, authcache_varnish_request_validate(), 'Accept request when proxy passphrase matches');
  $_SERVER['REMOTE_ADDR'] = $this->untrustedIp;
  $_SERVER['HTTP_X_CUSTOM_PASSPHRASE_HEADER'] = 'sEcr3t!';
  $this
    ->assertIdentical(TRUE, authcache_varnish_request_validate(), 'Accept request when proxy passphrase matches, even from untrusted ip');
}