Mercurial > hg > isophonics-drupal-site
comparison core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
97 // Hence, effectively, this is just the 403 response that one gets as the | 97 // Hence, effectively, this is just the 403 response that one gets as the |
98 // anonymous user trying to access a certain REST resource. | 98 // anonymous user trying to access a certain REST resource. |
99 // @see \Drupal\user\Authentication\Provider\Cookie | 99 // @see \Drupal\user\Authentication\Provider\Cookie |
100 // @todo https://www.drupal.org/node/2847623 | 100 // @todo https://www.drupal.org/node/2847623 |
101 if ($method === 'GET') { | 101 if ($method === 'GET') { |
102 $expected_cookie_403_cacheability = $this->getExpectedUnauthorizedAccessCacheability(); | 102 $expected_cookie_403_cacheability = $this->getExpectedUnauthorizedAccessCacheability() |
103 // @see \Drupal\Core\EventSubscriber\AnonymousUserResponseSubscriber::onRespond() | |
104 ->addCacheableDependency($this->getExpectedUnauthorizedEntityAccessCacheability(FALSE)); | |
103 // - \Drupal\Core\EventSubscriber\AnonymousUserResponseSubscriber applies | 105 // - \Drupal\Core\EventSubscriber\AnonymousUserResponseSubscriber applies |
104 // to cacheable anonymous responses: it updates their cacheability. | 106 // to cacheable anonymous responses: it updates their cacheability. |
105 // - A 403 response to a GET request is cacheable. | 107 // - A 403 response to a GET request is cacheable. |
106 // Therefore we must update our cacheability expectations accordingly. | 108 // Therefore we must update our cacheability expectations accordingly. |
107 if (in_array('user.permissions', $expected_cookie_403_cacheability->getCacheContexts(), TRUE)) { | 109 if (in_array('user.permissions', $expected_cookie_403_cacheability->getCacheContexts(), TRUE)) { |
109 } | 111 } |
110 // @todo Fix \Drupal\block\BlockAccessControlHandler::mergeCacheabilityFromConditions() in https://www.drupal.org/node/2867881 | 112 // @todo Fix \Drupal\block\BlockAccessControlHandler::mergeCacheabilityFromConditions() in https://www.drupal.org/node/2867881 |
111 if (static::$entityTypeId === 'block') { | 113 if (static::$entityTypeId === 'block') { |
112 $expected_cookie_403_cacheability->setCacheTags(str_replace('user:2', 'user:0', $expected_cookie_403_cacheability->getCacheTags())); | 114 $expected_cookie_403_cacheability->setCacheTags(str_replace('user:2', 'user:0', $expected_cookie_403_cacheability->getCacheTags())); |
113 } | 115 } |
114 $this->assertResourceErrorResponse(403, FALSE, $response, $expected_cookie_403_cacheability->getCacheTags(), $expected_cookie_403_cacheability->getCacheContexts(), 'MISS', 'MISS'); | 116 $this->assertResourceErrorResponse(403, FALSE, $response, $expected_cookie_403_cacheability->getCacheTags(), $expected_cookie_403_cacheability->getCacheContexts(), 'MISS', FALSE); |
115 } | 117 } |
116 else { | 118 else { |
117 $this->assertResourceErrorResponse(403, FALSE, $response); | 119 $this->assertResourceErrorResponse(403, FALSE, $response); |
118 } | 120 } |
119 } | 121 } |