Skip to content

Commit

Permalink
Merge pull request #4 from koriym/attribute3
Browse files Browse the repository at this point in the history
Add missing Extractors attribute
  • Loading branch information
kuma-guy authored Dec 21, 2022
2 parents 3e53236 + 8a2573f commit b97bf55
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/Extractor/TokenExtractorResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TokenExtractorResolver
*
* @var array
*/
#[Extractors]
public function __construct(array $extractors)
{
$this->extractors = $extractors;
Expand Down
4 changes: 3 additions & 1 deletion tests/Auth0ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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',
Expand All @@ -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));
}
}
41 changes: 41 additions & 0 deletions tests/Fake/Provider/FakeManagementClientProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace Ray\Auth0Module\Provider;

use Auth0\SDK\API\Management;
use Ray\Auth0Module\Annotation\Auth0Config;
use Ray\Di\ProviderInterface;

class FakeManagementClientProvider implements ProviderInterface
{
use AuthenticationClientInject;

/** @var array */
private $config;

/**
* @Auth0Config("config")
*
* @param array $config
*/
#[Auth0Config('config')]
public function __construct($config)
{
$this->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']);
}
}

0 comments on commit b97bf55

Please sign in to comment.