From 2039103f4e9e3e353ea4b312aafa4d468ad9a742 Mon Sep 17 00:00:00 2001 From: "Lucas P. Pons" Date: Tue, 11 May 2021 11:25:57 -0300 Subject: [PATCH 1/6] Update requirements for Laravel 8 --- composer.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index c8ea94b..44e73a2 100644 --- a/composer.json +++ b/composer.json @@ -17,19 +17,19 @@ ], "minimum-stability": "stable", "require": { - "php": ">=7.2", - "guzzlehttp/guzzle": "^6.2", - "illuminate/http": "^7.0", - "illuminate/support": "^7.0", - "nesbot/carbon": "^2.0", - "ramsey/uuid": "^3.6" + "php": "^7.3 || ^8.0", + "guzzlehttp/guzzle": "^7.2", + "illuminate/http": "^8.12", + "illuminate/support": "^8.12", + "nesbot/carbon": "^2.13", + "ramsey/uuid": "^4.0" }, "require-dev": { - "jshayes/fake-requests": "dev-master", - "mockery/mockery": "^1.0", - "orchestra/testbench": "^5.0", - "phpunit/phpunit": "^8.0", - "php-coveralls/php-coveralls": "^2.0" + "jshayes/fake-requests": "dev-change/update-to-laravel-8", + "mockery/mockery": "^1.4", + "orchestra/testbench": "^6.3", + "phpunit/phpunit": "^9.3", + "php-coveralls/php-coveralls": "^2.4" }, "autoload": { "psr-4": { From 3f8d8f31297d11e7563b67d682c80fdf1a1ff0bf Mon Sep 17 00:00:00 2001 From: "Lucas P. Pons" Date: Tue, 11 May 2021 12:00:00 -0300 Subject: [PATCH 2/6] Change fake-requests branch --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 44e73a2..9a218f1 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ramsey/uuid": "^4.0" }, "require-dev": { - "jshayes/fake-requests": "dev-change/update-to-laravel-8", + "jshayes/fake-requests": "dev-master", "mockery/mockery": "^1.4", "orchestra/testbench": "^6.3", "phpunit/phpunit": "^9.3", From 2ac91f594b3e504b5ca340b34f1cc51b8f27544e Mon Sep 17 00:00:00 2001 From: "Lucas P. Pons" Date: Tue, 11 May 2021 13:49:09 -0300 Subject: [PATCH 3/6] Fix Uuid errors (Uuid v4 changes) --- tests/ClientTest.php | 53 ++++++++++++---------------------- tests/Requests/PayloadTest.php | 6 ++-- 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 294750d..1784ee4 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -4,8 +4,9 @@ use Carbon\Carbon; use Ramsey\Uuid\Uuid; +use Ramsey\Uuid\UuidFactory; +use Ramsey\Uuid\UuidInterface; use JSHayes\FakeRequests\MockHandler; -use Ramsey\Uuid\UuidFactoryInterface; use JSHayes\FakeRequests\ClientFactory; use SoapBox\SignedRequests\Configurations\CustomConfiguration; use SoapBox\SignedRequests\Middlewares\Guzzle\GenerateSignature; @@ -14,45 +15,27 @@ class ClientTest extends TestCase { private function expectUuid4(string $uuid): void { - Uuid::setFactory(new class($uuid) implements UuidFactoryInterface { - public function __construct(string $uuid) + Uuid::setFactory(new class($uuid) extends UuidFactory { + public function __construct($uuid) { - $this->uuid = $uuid; - } + $this->customUuid = $uuid; - public function uuid1($node = null, $clockSeq = null) - { - return null; - } - - public function uuid3($ns, $name) - { - return null; - } - - public function uuid4() - { - return $this->uuid; - } - - public function uuid5($ns, $name) - { - return null; - } - - public function fromBytes($bytes) - { - return null; - } - - public function fromString($uuid) - { - return null; + parent::__construct(); } - public function fromInteger($integer) + public function uuid4(): UuidInterface { - return null; + return new class($this->customUuid) extends Uuid { + public function __construct($uuid) + { + $this->customUuid = $uuid; + } + + public function toString(): string + { + return $this->customUuid; + } + }; } }); } diff --git a/tests/Requests/PayloadTest.php b/tests/Requests/PayloadTest.php index e8b4761..7ed25ea 100644 --- a/tests/Requests/PayloadTest.php +++ b/tests/Requests/PayloadTest.php @@ -20,7 +20,7 @@ public function it_translates_a_guzzle_request_to_a_json_encoded_string() $method = 'GET'; $uri = 'https://localhost'; - $id = Uuid::uuid4(); + $id = (string) Uuid::uuid4(); $request = (new GuzzleRequest('GET', 'https://localhost')) ->withHeader('X-SIGNED-ID', $id) @@ -46,7 +46,7 @@ public function it_translates_a_guzzle_request_with_content_to_a_json_encoded_st $method = 'GET'; $uri = 'https://localhost'; - $id = Uuid::uuid4(); + $id = (string) Uuid::uuid4(); $request = (new GuzzleRequest('GET', 'https://localhost', [], 'content')) ->withHeader('X-SIGNED-ID', $id) @@ -152,7 +152,7 @@ public function it_upper_cases_the_guzzle_request_method() $now = (string)Carbon::now(); $uri = 'https://localhost'; - $id = Uuid::uuid4(); + $id = (string)Uuid::uuid4(); $request = (new GuzzleRequest('get', 'https://localhost', [], 'content')) ->withHeader('X-SIGNED-ID', $id) From a5ae41a4235c62233465ea9b80b365607f81add5 Mon Sep 17 00:00:00 2001 From: "Lucas P. Pons" Date: Tue, 11 May 2021 14:01:44 -0300 Subject: [PATCH 4/6] Fix typos and method visibility --- src/Requests/Payload.php | 2 +- src/Requests/Verifier.php | 2 +- tests/Configurations/CustomConfigurationTest.php | 2 +- tests/Configurations/RepositoryConfigurationTest.php | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Requests/Payload.php b/src/Requests/Payload.php index 9fdb9a5..ed4d0c0 100644 --- a/src/Requests/Payload.php +++ b/src/Requests/Payload.php @@ -95,7 +95,7 @@ protected function generateFromPsr7Request(Psr7Request $request) : string } /** - * Retruns the payload from an illuminate request. + * Returns the payload from an illuminate request. * * @param \Illuminate\Http\Request $request * An instance of the illuminate request to extract the payload from. diff --git a/src/Requests/Verifier.php b/src/Requests/Verifier.php index 7539205..06af24f 100644 --- a/src/Requests/Verifier.php +++ b/src/Requests/Verifier.php @@ -26,7 +26,7 @@ class Verifier /** * The underlying request that has the signature to validate. * - * @var \Illluminate\Http\Request + * @var \Illuminate\Http\Request */ protected $request; diff --git a/tests/Configurations/CustomConfigurationTest.php b/tests/Configurations/CustomConfigurationTest.php index f858c95..181460b 100644 --- a/tests/Configurations/CustomConfigurationTest.php +++ b/tests/Configurations/CustomConfigurationTest.php @@ -10,7 +10,7 @@ class CustomConfigurationTest extends TestCase /** * @test */ - function it_returns_the_set_values_when_requested() + public function it_returns_the_set_values_when_requested() { $algorithmHeader = 'a'; $signatureHeader = 's'; diff --git a/tests/Configurations/RepositoryConfigurationTest.php b/tests/Configurations/RepositoryConfigurationTest.php index 4e65413..7baae58 100644 --- a/tests/Configurations/RepositoryConfigurationTest.php +++ b/tests/Configurations/RepositoryConfigurationTest.php @@ -15,7 +15,7 @@ class RepositoryConfigurationTest extends TestCase /** * @before */ - function setup_repository() + public function setup_repository() { $this->repository = Mockery::mock(Repository::class); $this->configuration = new RepositoryConfiguration($this->repository); @@ -24,7 +24,7 @@ function setup_repository() /** * @test */ - function get_algorithm_header_returns_the_algorithm_header_value_from_the_configuration_repository() + public function get_algorithm_header_returns_the_algorithm_header_value_from_the_configuration_repository() { $this->repository->shouldReceive('get') ->with('signed-requests.headers.algorithm') @@ -36,7 +36,7 @@ function get_algorithm_header_returns_the_algorithm_header_value_from_the_config /** * @test */ - function get_signature_header_returns_the_signature_header_value_from_the_configuration_repository() + public function get_signature_header_returns_the_signature_header_value_from_the_configuration_repository() { $this->repository->shouldReceive('get') ->with('signed-requests.headers.signature') @@ -48,7 +48,7 @@ function get_signature_header_returns_the_signature_header_value_from_the_config /** * @test */ - function get_signing_algorithm_returns_the_signing_algorithm_to_use_from_the_configuration_repository() + public function get_signing_algorithm_returns_the_signing_algorithm_to_use_from_the_configuration_repository() { $this->repository->shouldReceive('get') ->with('signed-requests.algorithm') @@ -60,7 +60,7 @@ function get_signing_algorithm_returns_the_signing_algorithm_to_use_from_the_con /** * @test */ - function get_signing_key_returns_the_key_used_for_signing_the_request_from_the_configuration_repository() + public function get_signing_key_returns_the_key_used_for_signing_the_request_from_the_configuration_repository() { $this->repository->shouldReceive('get') ->with('signed-requests.key') From 9a07389db881ce313334cbacc1cb5b45cca4a5bb Mon Sep 17 00:00:00 2001 From: "Lucas P. Pons" Date: Tue, 11 May 2021 14:05:41 -0300 Subject: [PATCH 5/6] Migrate PHPUnit configuration --- phpunit.xml | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 4a037a5..830050f 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,21 +1,13 @@ - - - - ./tests/ - - - - - ./src/ - - + + + + ./src/ + + + + + ./tests/ + + From d0a7740dd377d73476f5b94d174b3a4085ba310e Mon Sep 17 00:00:00 2001 From: "Lucas P. Pons" Date: Tue, 11 May 2021 14:10:01 -0300 Subject: [PATCH 6/6] Remove PHP 7.2 from travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a7642e2..00b5425 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 7.2.27 - 7.3 - 7.4