diff --git a/.github/workflows/mt.yml b/.github/workflows/mt.yml index ce8efd52..175bae1f 100644 --- a/.github/workflows/mt.yml +++ b/.github/workflows/mt.yml @@ -32,11 +32,11 @@ jobs: wget https://github.com/infection/infection/releases/download/0.28.1/infection.phar chmod +x infection.phar - - name: Run Infection for added files only + - name: Run Infection for touched lines only if: github.event_name == 'pull_request' run: | git fetch --depth=1 origin $GITHUB_BASE_REF - php infection.phar -j8 --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --logger-github --ignore-msi-with-no-mutations --only-covered + php infection.phar --threads=max --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --logger-github --ignore-msi-with-no-mutations --only-covered --min-covered-msi=100 - name: Run Infection for all files if: github.event_name == 'push' diff --git a/composer.lock b/composer.lock index d5210453..772000c4 100644 --- a/composer.lock +++ b/composer.lock @@ -1736,12 +1736,12 @@ "source": { "type": "git", "url": "https://github.com/eloquent/phony.git", - "reference": "3732bb22f780eb2f305a21d04b83c6f47f11aba3" + "reference": "3d093d78e83fa5066559854505f01b6ea19af12e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/eloquent/phony/zipball/3732bb22f780eb2f305a21d04b83c6f47f11aba3", - "reference": "3732bb22f780eb2f305a21d04b83c6f47f11aba3", + "url": "https://api.github.com/repos/eloquent/phony/zipball/3d093d78e83fa5066559854505f01b6ea19af12e", + "reference": "3d093d78e83fa5066559854505f01b6ea19af12e", "shasum": "" }, "require": { @@ -1802,7 +1802,8 @@ "issues": "https://github.com/eloquent/phony/issues", "source": "https://github.com/eloquent/phony/tree/main" }, - "time": "2023-03-11T04:36:34+00:00" + "abandoned": true, + "time": "2023-07-08T03:46:48+00:00" }, { "name": "eloquent/phony-phpunit", @@ -1875,6 +1876,7 @@ "issues": "https://github.com/eloquent/phony-phpunit/issues", "source": "https://github.com/eloquent/phony-phpunit/tree/7.1.0" }, + "abandoned": true, "time": "2020-12-21T09:36:47+00:00" }, { @@ -2282,16 +2284,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.26.0", + "version": "1.28.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227" + "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/231e3186624c03d7e7c890ec662b81e6b0405227", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", + "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", "shasum": "" }, "require": { @@ -2323,22 +2325,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.26.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.28.0" }, - "time": "2024-02-23T16:05:55+00:00" + "time": "2024-04-03T18:51:33+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.66", + "version": "1.10.67", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "94779c987e4ebd620025d9e5fdd23323903950bd" + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd", - "reference": "94779c987e4ebd620025d9e5fdd23323903950bd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", "shasum": "" }, "require": { @@ -2381,13 +2383,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2024-03-28T16:17:31+00:00" + "time": "2024-04-16T07:22:02+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -4023,16 +4021,16 @@ }, { "name": "symfony/config", - "version": "v5.4.31", + "version": "v5.4.38", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "dd5ea39de228813aba0c23c3a4153da2a4cf3cd9" + "reference": "3dcd47d4bbd9fea4d1210e7a7a0a5ca02d99df14" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/dd5ea39de228813aba0c23c3a4153da2a4cf3cd9", - "reference": "dd5ea39de228813aba0c23c3a4153da2a4cf3cd9", + "url": "https://api.github.com/repos/symfony/config/zipball/3dcd47d4bbd9fea4d1210e7a7a0a5ca02d99df14", + "reference": "3dcd47d4bbd9fea4d1210e7a7a0a5ca02d99df14", "shasum": "" }, "require": { @@ -4082,7 +4080,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v5.4.31" + "source": "https://github.com/symfony/config/tree/v5.4.38" }, "funding": [ { @@ -4098,20 +4096,20 @@ "type": "tidelift" } ], - "time": "2023-11-09T08:22:43+00:00" + "time": "2024-03-22T10:04:40+00:00" }, { "name": "symfony/console", - "version": "v5.4.35", + "version": "v5.4.36", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "dbdf6adcb88d5f83790e1efb57ef4074309d3931" + "reference": "39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/dbdf6adcb88d5f83790e1efb57ef4074309d3931", - "reference": "dbdf6adcb88d5f83790e1efb57ef4074309d3931", + "url": "https://api.github.com/repos/symfony/console/zipball/39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e", + "reference": "39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e", "shasum": "" }, "require": { @@ -4181,7 +4179,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.35" + "source": "https://github.com/symfony/console/tree/v5.4.36" }, "funding": [ { @@ -4197,7 +4195,7 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:28:09+00:00" + "time": "2024-02-20T16:33:57+00:00" }, { "name": "symfony/event-dispatcher", @@ -4286,16 +4284,16 @@ }, { "name": "symfony/event-dispatcher-contracts", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1" + "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/f98b54df6ad059855739db6fcbc2d36995283fe1", - "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/540f4c73e87fd0c71ca44a6aa305d024ac68cb73", + "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73", "shasum": "" }, "require": { @@ -4345,7 +4343,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.3" }, "funding": [ { @@ -4361,7 +4359,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/finder", @@ -4656,16 +4654,16 @@ }, { "name": "symfony/polyfill-php81", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b" + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/7581cd600fa9fd681b797d00b02f068e2f13263b", - "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/c565ad1e63f30e7477fc40738343c62b40bc672d", + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d", "shasum": "" }, "require": { @@ -4673,9 +4671,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -4715,7 +4710,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.29.0" }, "funding": [ { @@ -4731,20 +4726,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/process", - "version": "v5.4.35", + "version": "v5.4.36", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "cbc28e34015ad50166fc2f9c8962d28d0fe861eb" + "reference": "4fdf34004f149cc20b2f51d7d119aa500caad975" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/cbc28e34015ad50166fc2f9c8962d28d0fe861eb", - "reference": "cbc28e34015ad50166fc2f9c8962d28d0fe861eb", + "url": "https://api.github.com/repos/symfony/process/zipball/4fdf34004f149cc20b2f51d7d119aa500caad975", + "reference": "4fdf34004f149cc20b2f51d7d119aa500caad975", "shasum": "" }, "require": { @@ -4777,7 +4772,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.35" + "source": "https://github.com/symfony/process/tree/v5.4.36" }, "funding": [ { @@ -4793,20 +4788,20 @@ "type": "tidelift" } ], - "time": "2024-01-23T13:51:25+00:00" + "time": "2024-02-12T15:49:53+00:00" }, { "name": "symfony/stopwatch", - "version": "v5.4.21", + "version": "v5.4.35", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "f83692cd869a6f2391691d40a01e8acb89e76fee" + "reference": "887762aa99ff16f65dc8b48aafead415f942d407" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/f83692cd869a6f2391691d40a01e8acb89e76fee", - "reference": "f83692cd869a6f2391691d40a01e8acb89e76fee", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/887762aa99ff16f65dc8b48aafead415f942d407", + "reference": "887762aa99ff16f65dc8b48aafead415f942d407", "shasum": "" }, "require": { @@ -4839,7 +4834,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.21" + "source": "https://github.com/symfony/stopwatch/tree/v5.4.35" }, "funding": [ { @@ -4855,20 +4850,20 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/string", - "version": "v5.4.35", + "version": "v5.4.36", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "c209c4d0559acce1c9a2067612cfb5d35756edc2" + "reference": "4e232c83622bd8cd32b794216aa29d0d266d353b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/c209c4d0559acce1c9a2067612cfb5d35756edc2", - "reference": "c209c4d0559acce1c9a2067612cfb5d35756edc2", + "url": "https://api.github.com/repos/symfony/string/zipball/4e232c83622bd8cd32b794216aa29d0d266d353b", + "reference": "4e232c83622bd8cd32b794216aa29d0d266d353b", "shasum": "" }, "require": { @@ -4925,7 +4920,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.35" + "source": "https://github.com/symfony/string/tree/v5.4.36" }, "funding": [ { @@ -4941,7 +4936,7 @@ "type": "tidelift" } ], - "time": "2024-01-23T13:51:25+00:00" + "time": "2024-02-01T08:49:30+00:00" }, { "name": "symfony/yaml", diff --git a/src/Connector/Client.php b/src/Connector/Client.php index 719e5ea0..50ef95fc 100644 --- a/src/Connector/Client.php +++ b/src/Connector/Client.php @@ -2,11 +2,11 @@ namespace AcquiaCloudApi\Connector; -use http\Exception\RuntimeException; use Psr\Http\Message\ResponseInterface; use GuzzleHttp\Exception\BadResponseException; use AcquiaCloudApi\Exception\ApiErrorException; use Psr\Http\Message\StreamInterface; +use RuntimeException; /** * Class Client @@ -103,7 +103,7 @@ public function modifyOptions(): array */ public function request(string $verb, string $path, array $options = []): mixed { - // Put options sent with API calls into a property so they can be accessed + // Put options sent with API calls into a property, so they can be accessed // and therefore tested in tests. $this->requestOptions = $options; @@ -151,9 +151,18 @@ public function makeRequest(string $verb, string $path, array $options = []): Re */ public function processResponse(ResponseInterface $response): mixed { - + // Internal server errors return HTML instead of JSON, breaking our parsing. + if ($response->getStatusCode() === 500) { + throw new RuntimeException( + 'Cloud API internal server error. Status ' + . $response->getStatusCode() + . '. Request ID ' + . $response->getHeaderLine('X-Request-Id') + ); + } $body_json = $response->getBody(); $body = json_decode($body_json, null, 512, JSON_THROW_ON_ERROR); + // Internal server errors may also return a 200 response and empty body. if (is_null($body)) { throw new RuntimeException( 'Response contained an empty body. Status ' diff --git a/tests/Connector/ClientTest.php b/tests/Connector/ClientTest.php index 34ce5030..3b80e5ec 100644 --- a/tests/Connector/ClientTest.php +++ b/tests/Connector/ClientTest.php @@ -6,6 +6,8 @@ use AcquiaCloudApi\Connector\Client; use AcquiaCloudApi\Connector\Connector; use AcquiaCloudApi\Endpoints\Code; +use GuzzleHttp\Psr7\Response; +use RuntimeException; class ClientTest extends CloudApiTestCase { @@ -42,6 +44,20 @@ public function testFilteredQuery(): void } } + public function testServerError(): void + { + $response = new Response(500, ['X-Request-Id' => 'v-918d0182-f8f6-11ee-ac5b-9f3072a91621']); + $client = $this->getMockClient($response); + + $code = new Code($client); + $this->expectException(RuntimeException::class); + $message = <<expectExceptionMessage($message); + $code->getAll('8ff6c046-ec64-4ce4-bea6-27845ec18600'); + } + public function testClearQuery(): void { $client = $this->getMockClient();