X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Frest%2Ftests%2Fsrc%2FFunctional%2FBasicAuthResourceTestTrait.php;fp=web%2Fcore%2Fmodules%2Frest%2Ftests%2Fsrc%2FFunctional%2FBasicAuthResourceTestTrait.php;h=e4dcd70ff6d19e15b566a4a32e6882330ec0515c;hp=fbb870bd897ae12e1cbc5ace0f89406d4cf44cab;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/rest/tests/src/Functional/BasicAuthResourceTestTrait.php b/web/core/modules/rest/tests/src/Functional/BasicAuthResourceTestTrait.php index fbb870bd8..e4dcd70ff 100644 --- a/web/core/modules/rest/tests/src/Functional/BasicAuthResourceTestTrait.php +++ b/web/core/modules/rest/tests/src/Functional/BasicAuthResourceTestTrait.php @@ -14,6 +14,8 @@ use Psr\Http\Message\ResponseInterface; * authenticated, a 401 response must be sent. * - Because every request must send an authorization, there is no danger of * CSRF attacks. + * + * @see \Drupal\Tests\rest\Functional\BasicAuthResourceWithInterfaceTranslationTestTrait */ trait BasicAuthResourceTestTrait { @@ -31,8 +33,11 @@ trait BasicAuthResourceTestTrait { /** * {@inheritdoc} */ - protected function assertResponseWhenMissingAuthentication(ResponseInterface $response) { - $this->assertResourceErrorResponse(401, 'No authentication credentials provided.', $response); + protected function assertResponseWhenMissingAuthentication($method, ResponseInterface $response) { + $expected_page_cache_header_value = $method === 'GET' ? 'MISS' : FALSE; + // @see \Drupal\basic_auth\Authentication\Provider\BasicAuth::challengeException() + $expected_dynamic_page_cache_header_value = $expected_page_cache_header_value; + $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); } /**