public function AuthcacheVarnishTestCase::testVaryHeader in Authenticated User Page Caching (Authcache) 7.2
Test presence of X-Authcache-Key header on HTTP response.
File
- modules/
authcache_varnish/ authcache_varnish.test, line 73 - Test cases for authcache_varnish module.
Class
- AuthcacheVarnishTestCase
- Cover authcache_varnish module.
Code
public function testVaryHeader() {
// Disable request validation for this test.
variable_set('authcache_varnish_header', FALSE);
variable_set('authcache_varnish_validate_reverse_proxy_address', FALSE);
// Test whether Vary: X-Authcache-Key header is present, even when caching
// is not enabled.
$this
->drupalGet('<front>');
$this
->assertVary('X-Authcache-Key');
$this
->assertNoVary('X-Authcache-Key-CID');
$this
->assertCacheControl('must-revalidate');
$this
->assertCacheControl('no-cache');
$this
->assertNoCacheControl('public');
variable_set('authcache_roles', array(
DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID,
DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID,
));
variable_set('page_cache_maximum_age', 3600);
// Ensure that Vary: X-Authcache-Key header is present when caching is
// enabled.
$this
->drupalGet('<front>');
$this
->assertVary('X-Authcache-Key');
$this
->assertNoVary('X-Authcache-Key-CID');
$this
->assertCacheControl('max-age=3600');
$this
->assertCacheControl('public');
$this
->assertNoCacheControl('must-revalidate');
$this
->assertNoCacheControl('no-cache');
}