From 3624d248aadc45fdb8d7125293932f22e3bd5170 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Tue, 19 May 2026 15:39:01 -0400 Subject: [PATCH 1/3] Add provider-supplied request authentication --- ...iderWithRequestAuthenticationInterface.php | 24 ++++++ src/Providers/ProviderRegistry.php | 47 +++++++----- tests/mocks/MockCustomAuthModel.php | 21 ++++++ tests/mocks/MockCustomAuthProvider.php | 73 +++++++++++++++++++ .../mocks/MockCustomRequestAuthentication.php | 30 ++++++++ tests/unit/Providers/ProviderRegistryTest.php | 40 ++++++++++ 6 files changed, 215 insertions(+), 20 deletions(-) create mode 100644 src/Providers/Contracts/ProviderWithRequestAuthenticationInterface.php create mode 100644 tests/mocks/MockCustomAuthModel.php create mode 100644 tests/mocks/MockCustomAuthProvider.php create mode 100644 tests/mocks/MockCustomRequestAuthentication.php diff --git a/src/Providers/Contracts/ProviderWithRequestAuthenticationInterface.php b/src/Providers/Contracts/ProviderWithRequestAuthenticationInterface.php new file mode 100644 index 00000000..07dd7a01 --- /dev/null +++ b/src/Providers/Contracts/ProviderWithRequestAuthenticationInterface.php @@ -0,0 +1,24 @@ +getAuthenticationMethod(); - if ($authenticationMethod === null) { - throw new InvalidArgumentException( - sprintf( - 'Provider %s does not expect any authentication, but got %s.', - $className, - get_class($requestAuthentication) - ) - ); - } + if (!is_subclass_of($className, ProviderWithRequestAuthenticationInterface::class)) { + $authenticationMethod = $className::metadata()->getAuthenticationMethod(); + if ($authenticationMethod === null) { + throw new InvalidArgumentException( + sprintf( + 'Provider %s does not expect any authentication, but got %s.', + $className, + get_class($requestAuthentication) + ) + ); + } - $expectedClass = $authenticationMethod->getImplementationClass(); - if (!$requestAuthentication instanceof $expectedClass) { - throw new InvalidArgumentException( - sprintf( - 'Provider %s expects authentication of type %s, but got %s.', - $className, - $expectedClass, - get_class($requestAuthentication) - ) - ); + $expectedClass = $authenticationMethod->getImplementationClass(); + if (!$requestAuthentication instanceof $expectedClass) { + throw new InvalidArgumentException( + sprintf( + 'Provider %s expects authentication of type %s, but got %s.', + $className, + $expectedClass, + get_class($requestAuthentication) + ) + ); + } } $availability = $className::availability(); @@ -521,6 +524,10 @@ private function createDefaultProviderRequestAuthentication( $providerId = $providerMetadata->getId(); $authenticationMethod = $providerMetadata->getAuthenticationMethod(); + if (is_subclass_of($className, ProviderWithRequestAuthenticationInterface::class)) { + return $className::requestAuthentication(); + } + if ($authenticationMethod === null) { return null; } diff --git a/tests/mocks/MockCustomAuthModel.php b/tests/mocks/MockCustomAuthModel.php new file mode 100644 index 00000000..37698b4b --- /dev/null +++ b/tests/mocks/MockCustomAuthModel.php @@ -0,0 +1,21 @@ +getModelMetadata($modelId); + $config = $modelConfig ?? new ModelConfig(); + + return new MockCustomAuthModel($modelMetadata, $config); + } + + /** + * Sets the request authentication for testing. + * + * @param RequestAuthenticationInterface|null $requestAuthentication The request authentication instance. + */ + public static function setRequestAuthentication(?RequestAuthenticationInterface $requestAuthentication): void + { + static::$requestAuthentication = $requestAuthentication; + } + + /** + * Resets static state for testing. + */ + public static function reset(): void + { + parent::reset(); + static::$requestAuthentication = null; + } +} diff --git a/tests/mocks/MockCustomRequestAuthentication.php b/tests/mocks/MockCustomRequestAuthentication.php new file mode 100644 index 00000000..8d82cdd3 --- /dev/null +++ b/tests/mocks/MockCustomRequestAuthentication.php @@ -0,0 +1,30 @@ +withHeader('X-Mock-Auth', 'custom'); + } + + /** + * {@inheritDoc} + */ + public static function getJsonSchema(): array + { + return []; + } +} diff --git a/tests/unit/Providers/ProviderRegistryTest.php b/tests/unit/Providers/ProviderRegistryTest.php index ff8197e6..672633f2 100644 --- a/tests/unit/Providers/ProviderRegistryTest.php +++ b/tests/unit/Providers/ProviderRegistryTest.php @@ -14,6 +14,8 @@ use WordPress\AiClient\Providers\Models\DTO\ModelRequirements; use WordPress\AiClient\Providers\Models\Enums\CapabilityEnum; use WordPress\AiClient\Providers\ProviderRegistry; +use WordPress\AiClient\Tests\mocks\MockCustomAuthProvider; +use WordPress\AiClient\Tests\mocks\MockCustomRequestAuthentication; use WordPress\AiClient\Tests\mocks\MockHttpTransporter; use WordPress\AiClient\Tests\mocks\MockModel; use WordPress\AiClient\Tests\mocks\MockModelMetadataDirectory; @@ -32,12 +34,14 @@ protected function setUp(): void { parent::setUp(); $this->registry = new ProviderRegistry(); + MockCustomAuthProvider::reset(); MockProvider::reset(); // Reset static state of mock provider before each test. } protected function tearDown(): void { MockProvider::reset(); // Reset static state of mock provider after each test. + MockCustomAuthProvider::reset(); parent::tearDown(); } @@ -376,6 +380,42 @@ public function testGetProviderRequestAuthenticationReturnsDefault(): void $this->assertNull($retrievedAuth); } + /** + * Tests that provider-supplied request authentication is used when available. + * + * @return void + */ + public function testRegisterProviderUsesProviderSuppliedRequestAuthentication(): void + { + $requestAuthentication = new MockCustomRequestAuthentication(); + MockCustomAuthProvider::setRequestAuthentication($requestAuthentication); + + $this->registry->registerProvider(MockCustomAuthProvider::class); + + $this->assertSame( + $requestAuthentication, + $this->registry->getProviderRequestAuthentication('mock-custom-auth') + ); + } + + /** + * Tests that provider-supplied request authentication is bound to models. + * + * @return void + */ + public function testRegisterProviderBindsProviderSuppliedRequestAuthenticationToModels(): void + { + $requestAuthentication = new MockCustomRequestAuthentication(); + MockCustomAuthProvider::setRequestAuthentication($requestAuthentication); + + $this->registry->registerProvider(MockCustomAuthProvider::class); + + $model = $this->registry->getProviderModel('mock-custom-auth', 'mock-text-model'); + + $this->assertInstanceOf(MockModel::class, $model); + $this->assertSame($requestAuthentication, $model->getRequestAuthentication()); + } + /** * Tests the internal getEnvVarName method using reflection. * From 7afce4c09f7e1fbcfc8781074b5dff1748df5bde Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sun, 31 May 2026 17:39:09 -0400 Subject: [PATCH 2/3] Add custom provider auth registry coverage --- tests/unit/Providers/ProviderRegistryTest.php | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/tests/unit/Providers/ProviderRegistryTest.php b/tests/unit/Providers/ProviderRegistryTest.php index 672633f2..af3b5a48 100644 --- a/tests/unit/Providers/ProviderRegistryTest.php +++ b/tests/unit/Providers/ProviderRegistryTest.php @@ -416,6 +416,29 @@ public function testRegisterProviderBindsProviderSuppliedRequestAuthenticationTo $this->assertSame($requestAuthentication, $model->getRequestAuthentication()); } + /** + * Tests that explicit request authentication overrides provider-supplied authentication. + * + * @return void + */ + public function testSetProviderRequestAuthenticationOverridesProviderSuppliedRequestAuthentication(): void + { + MockCustomAuthProvider::setRequestAuthentication(new MockCustomRequestAuthentication()); + + $this->registry->registerProvider(MockCustomAuthProvider::class); + + $requestAuthentication = new MockCustomRequestAuthentication(); + $this->registry->setProviderRequestAuthentication('mock-custom-auth', $requestAuthentication); + + $model = $this->registry->getProviderModel('mock-custom-auth', 'mock-text-model'); + + $this->assertSame( + $requestAuthentication, + $this->registry->getProviderRequestAuthentication('mock-custom-auth') + ); + $this->assertSame($requestAuthentication, $model->getRequestAuthentication()); + } + /** * Tests the internal getEnvVarName method using reflection. * @@ -428,7 +451,9 @@ public function testRegisterProviderBindsProviderSuppliedRequestAuthenticationTo public function testGetEnvVarName(string $providerId, string $field, string $expected): void { $method = new \ReflectionMethod(ProviderRegistry::class, 'getEnvVarName'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $result = $method->invoke($this->registry, $providerId, $field); // Invoke on instance @@ -464,7 +489,9 @@ public function testCreateDefaultProviderRequestAuthenticationWithEnvVar(): void $this->registry->registerProvider(MockProvider::class); $method = new \ReflectionMethod(ProviderRegistry::class, 'createDefaultProviderRequestAuthentication'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $auth = $method->invoke($this->registry, MockProvider::class); @@ -488,7 +515,9 @@ public function testCreateDefaultProviderRequestAuthenticationWithoutEnvVar(): v $this->registry->registerProvider(MockProvider::class); $method = new \ReflectionMethod(ProviderRegistry::class, 'createDefaultProviderRequestAuthentication'); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } $auth = $method->invoke($this->registry, MockProvider::class); From d3d210cdd3732866a4804a6b436eb4bb1898bb19 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Wed, 10 Jun 2026 19:29:01 -0400 Subject: [PATCH 3/3] Add bearer token request authentication --- ...iderWithRequestAuthenticationInterface.php | 24 ---- .../DTO/BearerTokenRequestAuthentication.php | 109 ++++++++++++++++++ .../Enums/RequestAuthenticationMethod.php | 16 ++- src/Providers/ProviderRegistry.php | 47 ++++---- tests/mocks/MockCustomAuthProvider.php | 35 +----- .../mocks/MockCustomRequestAuthentication.php | 14 +-- tests/unit/Providers/ProviderRegistryTest.php | 48 +++----- 7 files changed, 167 insertions(+), 126 deletions(-) delete mode 100644 src/Providers/Contracts/ProviderWithRequestAuthenticationInterface.php create mode 100644 src/Providers/Http/DTO/BearerTokenRequestAuthentication.php diff --git a/src/Providers/Contracts/ProviderWithRequestAuthenticationInterface.php b/src/Providers/Contracts/ProviderWithRequestAuthenticationInterface.php deleted file mode 100644 index 07dd7a01..00000000 --- a/src/Providers/Contracts/ProviderWithRequestAuthenticationInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - + */ +class BearerTokenRequestAuthentication extends AbstractDataTransferObject implements RequestAuthenticationInterface +{ + public const KEY_BEARER_TOKEN = 'bearerToken'; + + /** + * @var string The bearer token used for authentication. + */ + protected string $bearerToken; + + /** + * Constructor. + * + * @since n.e.x.t + * + * @param string $bearerToken The bearer token used for authentication. + */ + public function __construct(string $bearerToken) + { + $this->bearerToken = $bearerToken; + } + + /** + * {@inheritDoc} + * + * @since n.e.x.t + */ + public function authenticateRequest(Request $request): Request + { + return $request->withHeader('Authorization', 'Bearer ' . $this->bearerToken); + } + + /** + * Gets the bearer token. + * + * @since n.e.x.t + * + * @return string The bearer token. + */ + public function getBearerToken(): string + { + return $this->bearerToken; + } + + /** + * {@inheritDoc} + * + * @since n.e.x.t + * + * @return BearerTokenRequestAuthenticationArrayShape + */ + public function toArray(): array + { + return [ + self::KEY_BEARER_TOKEN => $this->bearerToken, + ]; + } + + /** + * {@inheritDoc} + * + * @since n.e.x.t + */ + public static function fromArray(array $array): self + { + static::validateFromArrayData($array, [self::KEY_BEARER_TOKEN]); + + return new self($array[self::KEY_BEARER_TOKEN]); + } + + /** + * {@inheritDoc} + * + * @since n.e.x.t + */ + public static function getJsonSchema(): array + { + return [ + 'type' => 'object', + 'properties' => [ + self::KEY_BEARER_TOKEN => [ + 'type' => 'string', + 'title' => 'Bearer Token', + 'description' => 'The bearer token used for authentication.', + ], + ], + 'required' => [self::KEY_BEARER_TOKEN], + ]; + } +} diff --git a/src/Providers/Http/Enums/RequestAuthenticationMethod.php b/src/Providers/Http/Enums/RequestAuthenticationMethod.php index 1fb92dbc..fbd3141e 100644 --- a/src/Providers/Http/Enums/RequestAuthenticationMethod.php +++ b/src/Providers/Http/Enums/RequestAuthenticationMethod.php @@ -8,6 +8,7 @@ use WordPress\AiClient\Common\Contracts\WithArrayTransformationInterface; use WordPress\AiClient\Providers\Http\Contracts\RequestAuthenticationInterface; use WordPress\AiClient\Providers\Http\DTO\ApiKeyRequestAuthentication; +use WordPress\AiClient\Providers\Http\DTO\BearerTokenRequestAuthentication; /** * Enum for request authentication methods. @@ -15,7 +16,9 @@ * @since 0.4.0 * * @method static self apiKey() Creates an instance for API_KEY method. + * @method static self bearerToken() Creates an instance for BEARER_TOKEN method. * @method bool isApiKey() Checks if the method is API_KEY. + * @method bool isBearerToken() Checks if the method is BEARER_TOKEN. */ class RequestAuthenticationMethod extends AbstractEnum { @@ -24,6 +27,13 @@ class RequestAuthenticationMethod extends AbstractEnum */ public const API_KEY = 'api_key'; + /** + * Bearer token authentication. + * + * @since n.e.x.t + */ + public const BEARER_TOKEN = 'bearer_token'; + /** * Gets the implementation class for the authentication method. * @@ -35,8 +45,10 @@ class RequestAuthenticationMethod extends AbstractEnum */ public function getImplementationClass(): string { - // At the moment, this is the only supported method. - // Once more methods are available, add conditionals here for each method. + if ($this->isBearerToken()) { + return BearerTokenRequestAuthentication::class; + } + return ApiKeyRequestAuthentication::class; } } diff --git a/src/Providers/ProviderRegistry.php b/src/Providers/ProviderRegistry.php index 3aca3ad1..d5aa6e47 100644 --- a/src/Providers/ProviderRegistry.php +++ b/src/Providers/ProviderRegistry.php @@ -9,7 +9,6 @@ use WordPress\AiClient\Common\Exception\RuntimeException; use WordPress\AiClient\Providers\Contracts\ProviderInterface; use WordPress\AiClient\Providers\Contracts\ProviderWithOperationsHandlerInterface; -use WordPress\AiClient\Providers\Contracts\ProviderWithRequestAuthenticationInterface; use WordPress\AiClient\Providers\DTO\ProviderMetadata; use WordPress\AiClient\Providers\DTO\ProviderModelsMetadata; use WordPress\AiClient\Providers\Http\Contracts\HttpTransporterInterface; @@ -465,29 +464,27 @@ private function setRequestAuthenticationForProvider( string $className, RequestAuthenticationInterface $requestAuthentication ): void { - if (!is_subclass_of($className, ProviderWithRequestAuthenticationInterface::class)) { - $authenticationMethod = $className::metadata()->getAuthenticationMethod(); - if ($authenticationMethod === null) { - throw new InvalidArgumentException( - sprintf( - 'Provider %s does not expect any authentication, but got %s.', - $className, - get_class($requestAuthentication) - ) - ); - } + $authenticationMethod = $className::metadata()->getAuthenticationMethod(); + if ($authenticationMethod === null) { + throw new InvalidArgumentException( + sprintf( + 'Provider %s does not expect any authentication, but got %s.', + $className, + get_class($requestAuthentication) + ) + ); + } - $expectedClass = $authenticationMethod->getImplementationClass(); - if (!$requestAuthentication instanceof $expectedClass) { - throw new InvalidArgumentException( - sprintf( - 'Provider %s expects authentication of type %s, but got %s.', - $className, - $expectedClass, - get_class($requestAuthentication) - ) - ); - } + $expectedClass = $authenticationMethod->getImplementationClass(); + if (!$requestAuthentication instanceof $expectedClass) { + throw new InvalidArgumentException( + sprintf( + 'Provider %s expects authentication of type %s, but got %s.', + $className, + $expectedClass, + get_class($requestAuthentication) + ) + ); } $availability = $className::availability(); @@ -524,10 +521,6 @@ private function createDefaultProviderRequestAuthentication( $providerId = $providerMetadata->getId(); $authenticationMethod = $providerMetadata->getAuthenticationMethod(); - if (is_subclass_of($className, ProviderWithRequestAuthenticationInterface::class)) { - return $className::requestAuthentication(); - } - if ($authenticationMethod === null) { return null; } diff --git a/tests/mocks/MockCustomAuthProvider.php b/tests/mocks/MockCustomAuthProvider.php index ff298d3d..2034435a 100644 --- a/tests/mocks/MockCustomAuthProvider.php +++ b/tests/mocks/MockCustomAuthProvider.php @@ -4,23 +4,17 @@ namespace WordPress\AiClient\Tests\mocks; -use WordPress\AiClient\Providers\Contracts\ProviderWithRequestAuthenticationInterface; use WordPress\AiClient\Providers\DTO\ProviderMetadata; use WordPress\AiClient\Providers\Enums\ProviderTypeEnum; -use WordPress\AiClient\Providers\Http\Contracts\RequestAuthenticationInterface; +use WordPress\AiClient\Providers\Http\Enums\RequestAuthenticationMethod; use WordPress\AiClient\Providers\Models\Contracts\ModelInterface; use WordPress\AiClient\Providers\Models\DTO\ModelConfig; /** - * Mock provider with custom request authentication for testing purposes. + * Mock provider with bearer token authentication for testing purposes. */ -class MockCustomAuthProvider extends MockProvider implements ProviderWithRequestAuthenticationInterface +class MockCustomAuthProvider extends MockProvider { - /** - * @var RequestAuthenticationInterface|null Custom request authentication instance. - */ - private static ?RequestAuthenticationInterface $requestAuthentication = null; - /** * {@inheritDoc} */ @@ -29,18 +23,12 @@ public static function metadata(): ProviderMetadata return new ProviderMetadata( 'mock-custom-auth', 'Mock Custom Auth Provider', - ProviderTypeEnum::cloud() + ProviderTypeEnum::cloud(), + null, + RequestAuthenticationMethod::bearerToken() ); } - /** - * {@inheritDoc} - */ - public static function requestAuthentication(): ?RequestAuthenticationInterface - { - return static::$requestAuthentication; - } - /** * {@inheritDoc} */ @@ -52,22 +40,11 @@ public static function model(string $modelId, ?ModelConfig $modelConfig = null): return new MockCustomAuthModel($modelMetadata, $config); } - /** - * Sets the request authentication for testing. - * - * @param RequestAuthenticationInterface|null $requestAuthentication The request authentication instance. - */ - public static function setRequestAuthentication(?RequestAuthenticationInterface $requestAuthentication): void - { - static::$requestAuthentication = $requestAuthentication; - } - /** * Resets static state for testing. */ public static function reset(): void { parent::reset(); - static::$requestAuthentication = null; } } diff --git a/tests/mocks/MockCustomRequestAuthentication.php b/tests/mocks/MockCustomRequestAuthentication.php index 8d82cdd3..c851ee2f 100644 --- a/tests/mocks/MockCustomRequestAuthentication.php +++ b/tests/mocks/MockCustomRequestAuthentication.php @@ -4,27 +4,19 @@ namespace WordPress\AiClient\Tests\mocks; -use WordPress\AiClient\Providers\Http\Contracts\RequestAuthenticationInterface; +use WordPress\AiClient\Providers\Http\DTO\BearerTokenRequestAuthentication; use WordPress\AiClient\Providers\Http\DTO\Request; /** * Mock custom request authentication for testing purposes. */ -class MockCustomRequestAuthentication implements RequestAuthenticationInterface +class MockCustomRequestAuthentication extends BearerTokenRequestAuthentication { /** * {@inheritDoc} */ public function authenticateRequest(Request $request): Request { - return $request->withHeader('X-Mock-Auth', 'custom'); - } - - /** - * {@inheritDoc} - */ - public static function getJsonSchema(): array - { - return []; + return parent::authenticateRequest($request)->withHeader('X-Mock-Auth', 'custom'); } } diff --git a/tests/unit/Providers/ProviderRegistryTest.php b/tests/unit/Providers/ProviderRegistryTest.php index af3b5a48..f60d6a51 100644 --- a/tests/unit/Providers/ProviderRegistryTest.php +++ b/tests/unit/Providers/ProviderRegistryTest.php @@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase; use WordPress\AiClient\Providers\Http\Contracts\RequestAuthenticationInterface; use WordPress\AiClient\Providers\Http\DTO\ApiKeyRequestAuthentication; +use WordPress\AiClient\Providers\Http\DTO\BearerTokenRequestAuthentication; use WordPress\AiClient\Providers\Http\DTO\Request; use WordPress\AiClient\Providers\Models\DTO\ModelConfig; use WordPress\AiClient\Providers\Models\DTO\ModelMetadata; @@ -381,62 +382,43 @@ public function testGetProviderRequestAuthenticationReturnsDefault(): void } /** - * Tests that provider-supplied request authentication is used when available. + * Tests that explicit bearer token authentication is bound to models. * * @return void */ - public function testRegisterProviderUsesProviderSuppliedRequestAuthentication(): void + public function testSetProviderRequestAuthenticationBindsBearerTokenAuthenticationToModels(): void { - $requestAuthentication = new MockCustomRequestAuthentication(); - MockCustomAuthProvider::setRequestAuthentication($requestAuthentication); - $this->registry->registerProvider(MockCustomAuthProvider::class); + $requestAuthentication = new MockCustomRequestAuthentication('test-token'); + $this->registry->setProviderRequestAuthentication('mock-custom-auth', $requestAuthentication); + + $model = $this->registry->getProviderModel('mock-custom-auth', 'mock-text-model'); + $this->assertSame( $requestAuthentication, $this->registry->getProviderRequestAuthentication('mock-custom-auth') ); - } - - /** - * Tests that provider-supplied request authentication is bound to models. - * - * @return void - */ - public function testRegisterProviderBindsProviderSuppliedRequestAuthenticationToModels(): void - { - $requestAuthentication = new MockCustomRequestAuthentication(); - MockCustomAuthProvider::setRequestAuthentication($requestAuthentication); - - $this->registry->registerProvider(MockCustomAuthProvider::class); - - $model = $this->registry->getProviderModel('mock-custom-auth', 'mock-text-model'); - - $this->assertInstanceOf(MockModel::class, $model); $this->assertSame($requestAuthentication, $model->getRequestAuthentication()); } /** - * Tests that explicit request authentication overrides provider-supplied authentication. + * Tests default bearer token authentication creation from environment data. * * @return void */ - public function testSetProviderRequestAuthenticationOverridesProviderSuppliedRequestAuthentication(): void + public function testCreateDefaultProviderRequestAuthenticationWithBearerTokenEnvVar(): void { - MockCustomAuthProvider::setRequestAuthentication(new MockCustomRequestAuthentication()); + putenv('MOCK_CUSTOM_AUTH_BEARER_TOKEN=test_bearer_token'); $this->registry->registerProvider(MockCustomAuthProvider::class); - $requestAuthentication = new MockCustomRequestAuthentication(); - $this->registry->setProviderRequestAuthentication('mock-custom-auth', $requestAuthentication); + $auth = $this->registry->getProviderRequestAuthentication('mock-custom-auth'); - $model = $this->registry->getProviderModel('mock-custom-auth', 'mock-text-model'); + $this->assertInstanceOf(BearerTokenRequestAuthentication::class, $auth); + $this->assertSame('test_bearer_token', $auth->getBearerToken()); - $this->assertSame( - $requestAuthentication, - $this->registry->getProviderRequestAuthentication('mock-custom-auth') - ); - $this->assertSame($requestAuthentication, $model->getRequestAuthentication()); + putenv('MOCK_CUSTOM_AUTH_BEARER_TOKEN'); } /**