@@ -12,35 +12,35 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | trait Fetcher |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Configuration for the Guzzle client |
|
| 17 | - * |
|
| 18 | - * @var array |
|
| 19 | - */ |
|
| 20 | - protected $clientConfig = []; |
|
| 15 | + /** |
|
| 16 | + * Configuration for the Guzzle client |
|
| 17 | + * |
|
| 18 | + * @var array |
|
| 19 | + */ |
|
| 20 | + protected $clientConfig = []; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Merges configuration arrays and returns the result |
|
| 24 | - * |
|
| 25 | - * @param array $extraConfig |
|
| 26 | - * @return array |
|
| 27 | - */ |
|
| 28 | - private function getClientConfig(array $extraConfig = []) |
|
| 29 | - { |
|
| 30 | - return array_merge($this->clientConfig, $extraConfig); |
|
| 31 | - } |
|
| 22 | + /** |
|
| 23 | + * Merges configuration arrays and returns the result |
|
| 24 | + * |
|
| 25 | + * @param array $extraConfig |
|
| 26 | + * @return array |
|
| 27 | + */ |
|
| 28 | + private function getClientConfig(array $extraConfig = []) |
|
| 29 | + { |
|
| 30 | + return array_merge($this->clientConfig, $extraConfig); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Fetch a response for a URL using Guzzle client. |
|
| 35 | - * |
|
| 36 | - * @param string $url |
|
| 37 | - * @param array|null $extraConfig Extra configuration |
|
| 38 | - * @return ResponseInterface |
|
| 39 | - */ |
|
| 40 | - public function fetchResponse(string $url, array $extraConfig = []) |
|
| 41 | - { |
|
| 42 | - $config = $this->getClientConfig($extraConfig); |
|
| 43 | - $client = new Client($config); |
|
| 44 | - return $client->get($url); |
|
| 45 | - } |
|
| 33 | + /** |
|
| 34 | + * Fetch a response for a URL using Guzzle client. |
|
| 35 | + * |
|
| 36 | + * @param string $url |
|
| 37 | + * @param array|null $extraConfig Extra configuration |
|
| 38 | + * @return ResponseInterface |
|
| 39 | + */ |
|
| 40 | + public function fetchResponse(string $url, array $extraConfig = []) |
|
| 41 | + { |
|
| 42 | + $config = $this->getClientConfig($extraConfig); |
|
| 43 | + $client = new Client($config); |
|
| 44 | + return $client->get($url); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -17,70 +17,70 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class SessionCheck implements EnvironmentCheck |
| 19 | 19 | { |
| 20 | - use Configurable; |
|
| 21 | - use Fetcher; |
|
| 20 | + use Configurable; |
|
| 21 | + use Fetcher; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * URL to check |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - protected $url; |
|
| 23 | + /** |
|
| 24 | + * URL to check |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + protected $url; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Set up check with URL |
|
| 32 | - * |
|
| 33 | - * @param string $url The route, excluding the domain |
|
| 34 | - * @inheritdoc |
|
| 35 | - */ |
|
| 36 | - public function __construct($url = '') |
|
| 37 | - { |
|
| 38 | - $this->url = $url; |
|
| 39 | - $this->clientConfig = [ |
|
| 40 | - 'base_uri' => Director::absoluteBaseURL(), |
|
| 41 | - 'timeout' => 10.0, |
|
| 42 | - ]; |
|
| 43 | - } |
|
| 30 | + /** |
|
| 31 | + * Set up check with URL |
|
| 32 | + * |
|
| 33 | + * @param string $url The route, excluding the domain |
|
| 34 | + * @inheritdoc |
|
| 35 | + */ |
|
| 36 | + public function __construct($url = '') |
|
| 37 | + { |
|
| 38 | + $this->url = $url; |
|
| 39 | + $this->clientConfig = [ |
|
| 40 | + 'base_uri' => Director::absoluteBaseURL(), |
|
| 41 | + 'timeout' => 10.0, |
|
| 42 | + ]; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Check that the response for URL does not create a session |
|
| 47 | - * |
|
| 48 | - * @return array |
|
| 49 | - */ |
|
| 50 | - public function check() |
|
| 51 | - { |
|
| 52 | - $response = $this->fetchResponse($this->url); |
|
| 53 | - $cookie = $this->getCookie($response); |
|
| 54 | - $fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url); |
|
| 45 | + /** |
|
| 46 | + * Check that the response for URL does not create a session |
|
| 47 | + * |
|
| 48 | + * @return array |
|
| 49 | + */ |
|
| 50 | + public function check() |
|
| 51 | + { |
|
| 52 | + $response = $this->fetchResponse($this->url); |
|
| 53 | + $cookie = $this->getCookie($response); |
|
| 54 | + $fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url); |
|
| 55 | 55 | |
| 56 | - if ($cookie) { |
|
| 57 | - return [ |
|
| 58 | - EnvironmentCheck::ERROR, |
|
| 59 | - "Sessions are being set for {$fullURL} : Set-Cookie => " . $cookie, |
|
| 60 | - ]; |
|
| 61 | - } |
|
| 62 | - return [ |
|
| 63 | - EnvironmentCheck::OK, |
|
| 64 | - "Sessions are not being created for {$fullURL} |
|