comparison core/modules/rest/tests/src/Functional/BasicAuthResourceTestTrait.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 7a779792577d
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
12 * - Every request must send an Authorization header. 12 * - Every request must send an Authorization header.
13 * - When accessing a URI that requires authentication without being 13 * - When accessing a URI that requires authentication without being
14 * authenticated, a 401 response must be sent. 14 * authenticated, a 401 response must be sent.
15 * - Because every request must send an authorization, there is no danger of 15 * - Because every request must send an authorization, there is no danger of
16 * CSRF attacks. 16 * CSRF attacks.
17 *
18 * @see \Drupal\Tests\rest\Functional\BasicAuthResourceWithInterfaceTranslationTestTrait
17 */ 19 */
18 trait BasicAuthResourceTestTrait { 20 trait BasicAuthResourceTestTrait {
19 21
20 /** 22 /**
21 * {@inheritdoc} 23 * {@inheritdoc}
29 } 31 }
30 32
31 /** 33 /**
32 * {@inheritdoc} 34 * {@inheritdoc}
33 */ 35 */
34 protected function assertResponseWhenMissingAuthentication(ResponseInterface $response) { 36 protected function assertResponseWhenMissingAuthentication($method, ResponseInterface $response) {
35 $this->assertResourceErrorResponse(401, 'No authentication credentials provided.', $response); 37 $expected_page_cache_header_value = $method === 'GET' ? 'MISS' : FALSE;
38 // @see \Drupal\basic_auth\Authentication\Provider\BasicAuth::challengeException()
39 $expected_dynamic_page_cache_header_value = $expected_page_cache_header_value;
40 $this->assertResourceErrorResponse(401, 'No authentication credentials provided.', $response, ['4xx-response', 'config:system.site', 'config:user.role.anonymous', 'http_response'], ['user.roles:anonymous'], $expected_page_cache_header_value, $expected_dynamic_page_cache_header_value);
36 } 41 }
37 42
38 /** 43 /**
39 * {@inheritdoc} 44 * {@inheritdoc}
40 */ 45 */