From 9fa0ffc6c5840c27e54c65f512649da85444b518 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Wed, 21 Dec 2022 15:37:11 +0900 Subject: [PATCH 1/2] Add missing attribute --- src/Extractor/TokenExtractorResolver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Extractor/TokenExtractorResolver.php b/src/Extractor/TokenExtractorResolver.php index 1730f8a..07c15bd 100644 --- a/src/Extractor/TokenExtractorResolver.php +++ b/src/Extractor/TokenExtractorResolver.php @@ -20,6 +20,7 @@ class TokenExtractorResolver * * @var array */ + #[Extractors] public function __construct(array $extractors) { $this->extractors = $extractors; From 8a2573ff2c4160fc3e3e5ba5529f4af8b64fb125 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Wed, 21 Dec 2022 15:38:18 +0900 Subject: [PATCH 2/2] Add Management get-instance test --- composer.json | 2 +- tests/Auth0ModuleTest.php | 4 +- .../Provider/FakeManagementClientProvider.php | 41 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/Fake/Provider/FakeManagementClientProvider.php diff --git a/composer.json b/composer.json index 8b5dca1..587d1c2 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "ray/di": "^2.15" }, "require-dev": { - "phpunit/phpunit": "^8.5", + "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3.2", "friendsofphp/php-cs-fixer": "^2.11", "phpmd/phpmd": "^2.6", diff --git a/tests/Auth0ModuleTest.php b/tests/Auth0ModuleTest.php index b951b53..112b091 100644 --- a/tests/Auth0ModuleTest.php +++ b/tests/Auth0ModuleTest.php @@ -15,7 +15,7 @@ use Ray\Auth0Module\Extractor\AuthorizationHeaderTokenExtractor; use Ray\Auth0Module\Extractor\TokenExtractorResolver; use Ray\Auth0Module\Provider\AuthenticationClientProvider; -use Ray\Auth0Module\Provider\ManagementClientProvider; +use Ray\Auth0Module\Provider\FakeManagementClientProvider; use Ray\Di\AbstractModule; use Ray\Di\Injector; use Ray\Di\Scope; @@ -27,6 +27,7 @@ public function testModule() : void $this->module = new class extends AbstractModule { protected function configure() : void { + $this->bind(Management::class)->toProvider(FakeManagementClientProvider::class); $this->install(new Auth0Module([ 'domain' => 'AUTH0_DOMAIN', 'client_id' => 'AUTH0_CLIENT_ID', @@ -36,5 +37,6 @@ protected function configure() : void }; $injector = (new Injector($this->module, dirname(__DIR__) . '/tmp')); $this->assertInstanceOf(Authentication::class, $injector->getInstance(Authentication::class)); + $this->assertInstanceOf(Management::class, $injector->getInstance(Management::class)); } } diff --git a/tests/Fake/Provider/FakeManagementClientProvider.php b/tests/Fake/Provider/FakeManagementClientProvider.php new file mode 100644 index 0000000..95c39ad --- /dev/null +++ b/tests/Fake/Provider/FakeManagementClientProvider.php @@ -0,0 +1,41 @@ +config = $config; + } + + public function get() : Management + { +// $response = $this->authClient->client_credentials([ +// 'audience' => 'https://' . $this->config['domain'] . '/api/v2/', +// ]); + + $response = [ + 'access_token' => 'access_token', + 'domain' => 'domain' + ]; + return new Management($response['access_token'], $this->config['domain']); + } +}