@@ -43,6 +43,11 @@ |
||
| 43 | 43 | return json_decode($systems->getBody(), true); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | + /** |
|
| 47 | + * @param string $url |
|
| 48 | + * |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 46 | 51 | private function prepareUrl($url) |
| 47 | 52 | { |
| 48 | 53 | $preparedUrl = str_replace('#project#', $this->project, $url); |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | { |
| 24 | 24 | if (array_key_exists('issuer', $certInfo) and array_key_exists('CN', $certInfo['issuer'])) { |
| 25 | 25 | if ($certInfo['issuer']['CN'] !== $this->authorityName) { |
| 26 | - throw new ValidationFailedException('Expected authority was "' . $this->authorityName . '", "' . $certInfo['issuer']['CN'] . '" found.'); |
|
| 26 | + throw new ValidationFailedException('Expected authority was "'.$this->authorityName.'", "'.$certInfo['issuer']['CN'].'" found.'); |
|
| 27 | 27 | } |
| 28 | 28 | } else { |
| 29 | - throw new ValidationFailedException('Expected authority was "' . $this->authorityName . '". No authority found.'); |
|
| 29 | + throw new ValidationFailedException('Expected authority was "'.$this->authorityName.'". No authority found.'); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | |
| 13 | 13 | foreach ($matches[1] as $varName) { |
| 14 | 14 | if (!getenv($varName)) { |
| 15 | - throw new \RuntimeException('The mandatory env variable (' . $varName . ') from the config file was not set.'); |
|
| 15 | + throw new \RuntimeException('The mandatory env variable ('.$varName.') from the config file was not set.'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - $fileContent = str_replace('${' . $varName . '}', getenv($varName), $fileContent); |
|
| 18 | + $fileContent = str_replace('${'.$varName.'}', getenv($varName), $fileContent); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | return Yaml::parse($fileContent); |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | if (count($results) > 0) { |
| 23 | 23 | ++$this->urlCount; |
| 24 | 24 | $firstResult = array_pop($results); |
| 25 | - $this->output->writeln(' ' . (string) $firstResult->getResponse()->getUri()); |
|
| 25 | + $this->output->writeln(' '.(string) $firstResult->getResponse()->getUri()); |
|
| 26 | 26 | $this->output->writeln(''); |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function finish() |
| 31 | 31 | { |
| 32 | - $this->output->writeln(' <comment>Warm up finished. ' . $this->urlCount . ' urls visited.</comment>'); |
|
| 32 | + $this->output->writeln(' <comment>Warm up finished. '.$this->urlCount.' urls visited.</comment>'); |
|
| 33 | 33 | $this->output->writeln(''); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | } catch (ValidationFailedException $e) { |
| 97 | 97 | $result = new CheckResult(CheckResult::STATUS_FAILURE, $e->getMessage()); |
| 98 | 98 | } catch (\Exception $e) { |
| 99 | - $result = new CheckResult(CheckResult::STATUS_FAILURE, 'An error occured: ' . $e->getMessage()); |
|
| 99 | + $result = new CheckResult(CheckResult::STATUS_FAILURE, 'An error occured: '.$e->getMessage()); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $result->setResponse($response); |
@@ -198,12 +198,12 @@ |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | - * @param $identifier |
|
| 201 | + * @param string $identifier |
|
| 202 | 202 | * @param $system |
| 203 | - * @param $message |
|
| 203 | + * @param string $message |
|
| 204 | 204 | * @param $status |
| 205 | 205 | * @param $value |
| 206 | - * @param $tool |
|
| 206 | + * @param string $tool |
|
| 207 | 207 | * @param $component |
| 208 | 208 | * @param Attribute[] $attributes |
| 209 | 209 | */ |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | foreach ($this->results as $results) { |
| 121 | 121 | foreach ($results as $result) { |
| 122 | 122 | /* @var CheckResult $result */ |
| 123 | - $tool = 'Smoke' . $result->getRuleName(); |
|
| 123 | + $tool = 'Smoke'.$result->getRuleName(); |
|
| 124 | 124 | $checks[$tool][] = $result; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -132,19 +132,19 @@ discard block |
||
| 132 | 132 | continue; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $message = 'The smoke test for #system_name# failed (Rule: ' . $toolName . ').<ul>'; |
|
| 135 | + $message = 'The smoke test for #system_name# failed (Rule: '.$toolName.').<ul>'; |
|
| 136 | 136 | $status = Event::STATUS_SUCCESS; |
| 137 | 137 | $failureCount = 0; |
| 138 | - $identifier = $toolName . '_' . $this->system; |
|
| 138 | + $identifier = $toolName.'_'.$this->system; |
|
| 139 | 139 | |
| 140 | 140 | foreach ($results as $result) { |
| 141 | 141 | /** @var CheckResult $result */ |
| 142 | 142 | if ($result->getStatus() === CheckResult::STATUS_FAILURE) { |
| 143 | 143 | $comingFrom = ''; |
| 144 | 144 | if ($this->addComingFrom && $this->retriever->getComingFrom($result->getResponse()->getUri())) { |
| 145 | - $comingFrom = ', coming from: ' . $this->retriever->getComingFrom($result->getResponse()->getUri()); |
|
| 145 | + $comingFrom = ', coming from: '.$this->retriever->getComingFrom($result->getResponse()->getUri()); |
|
| 146 | 146 | } |
| 147 | - $message .= '<li>' . $result->getMessage() . ' (url: ' . (string)$result->getResponse()->getUri() . $comingFrom . ')</li>'; |
|
| 147 | + $message .= '<li>'.$result->getMessage().' (url: '.(string) $result->getResponse()->getUri().$comingFrom.')</li>'; |
|
| 148 | 148 | ++$failureCount; |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | $status = Event::STATUS_FAILURE; |
| 153 | 153 | $message .= '</ul>'; |
| 154 | 154 | $firstResult = array_pop($results); |
| 155 | - $attributes[] = new Attribute('html-content', (string)$firstResult->getResponse()->getBody(), true); |
|
| 155 | + $attributes[] = new Attribute('html-content', (string) $firstResult->getResponse()->getBody(), true); |
|
| 156 | 156 | } else { |
| 157 | - $message = 'All checks for system "#system_name#" succeeded [SmokeBasic:' . $toolName . '].'; |
|
| 157 | + $message = 'All checks for system "#system_name#" succeeded [SmokeBasic:'.$toolName.'].'; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $this->send($identifier, $this->system, $message, $status, $failureCount, $this->tool, $this->system, $attributes); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | foreach ($results as $result) { |
| 168 | 168 | /* @var CheckResult $result */ |
| 169 | 169 | |
| 170 | - $identifier = '_' . $this->getIdentifier($result); |
|
| 170 | + $identifier = '_'.$this->getIdentifier($result); |
|
| 171 | 171 | $tool = $this->getPrefix($result->getRuleName()); |
| 172 | 172 | |
| 173 | 173 | $component = $this->getComponent($result->getRuleName()); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | $attributes = array(); |
| 177 | 177 | if ($result->getStatus() == CheckResult::STATUS_FAILURE) { |
| 178 | - $attributes[] = new Attribute('html content', (string)$result->getResponse()->getBody(), true); |
|
| 178 | + $attributes[] = new Attribute('html content', (string) $result->getResponse()->getBody(), true); |
|
| 179 | 179 | $attributes[] = new Attribute('http header', json_encode($result->getResponse()->getHeaders()), true); |
| 180 | 180 | $attributes[] = new Attribute('http status code', $result->getResponse()->getStatusCode()); |
| 181 | 181 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $this->send( |
| 195 | 195 | $identifier, |
| 196 | 196 | $currentSystem, |
| 197 | - $result->getMessage() . ' (url: ' . (string)$result->getResponse()->getUri() . ')', |
|
| 197 | + $result->getMessage().' (url: '.(string) $result->getResponse()->getUri().')', |
|
| 198 | 198 | $result->getStatus(), |
| 199 | 199 | $result->getValue(), |
| 200 | 200 | $tool, |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | private function getIdentifier(CheckResult $result) |
| 209 | 209 | { |
| 210 | - return $this->tool . '_' . $result->getRuleName(); |
|
| 210 | + return $this->tool.'_'.$result->getRuleName(); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | private function getPrefix($string) |
@@ -24,13 +24,13 @@ |
||
| 24 | 24 | |
| 25 | 25 | foreach ($this->checkedHeaders as $headerConfig) { |
| 26 | 26 | if (!$response->hasHeader($headerConfig['key'])) { |
| 27 | - throw new ValidationFailedException('Header not found (' . $headerConfig['key'] . ')'); |
|
| 27 | + throw new ValidationFailedException('Header not found ('.$headerConfig['key'].')'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $currentValue = $response->getHeader($headerConfig['key'])[0]; |
| 31 | 31 | |
| 32 | - if (!preg_match('%' . $headerConfig['value'] . '%', $currentValue, $matches)) { |
|
| 33 | - throw new ValidationFailedException('Header "' . $headerConfig['key'] . '" does not match "' . $headerConfig['value'] . '". Current value is "' . $currentValue . '"'); |
|
| 32 | + if (!preg_match('%'.$headerConfig['value'].'%', $currentValue, $matches)) { |
|
| 33 | + throw new ValidationFailedException('Header "'.$headerConfig['key'].'" does not match "'.$headerConfig['value'].'". Current value is "'.$currentValue.'"'); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Psr\Http\Message\ResponseInterface; |
| 6 | 6 | use whm\Html\Document; |
| 7 | -use whm\Smoke\Http\Response; |
|
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * This rules counts the css files that are included in a document. If the number is higher |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Psr\Http\Message\ResponseInterface; |
| 6 | 6 | use whm\Html\Document; |
| 7 | -use whm\Smoke\Http\Response; |
|
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * This rules counts the js files that are included in a document. If the number is higher |