Upstream spiral/testing state of the touched files before e812c3d094

This commit is contained in:
upstream committed 2026-09-21 16:30:28 +02:00
1 parent 4bb906a5d6
commit fdcc6b7728
3 files changed
+3 -108

No files matched your search

+3 -27
View File
@@ -421,7 +421,9 @@ class FakeHttp
$bindings[ActorProviderInterface::class] = new FakeActorProvider($this->actor);
$bindings[TokenStorageInterface::class] = new FakeTokenStorage();
$bindings[TransportRegistry::class] = $this->createFakeTransportRegistry();
$transport = new TransportRegistry();
$transport->setTransport('testing', new HeaderTransport(static::AUTH_TOKEN_HEADER_KEY));
$bindings[TransportRegistry::class] = $transport;
}
if ($this->session) {
@@ -459,30 +461,4 @@ class FakeHttp
throw new \InvalidArgumentException('$data should be an array or an object.');
}
}
/**
* The fake token travels in the {@see self::AUTH_TOKEN_HEADER_KEY} header, so every transport the
* application has configured is replaced by one that reads it. The configured names are kept because
* {@see \Spiral\Auth\Middleware\AuthTransportMiddleware} resolves a transport by name.
*/
private function createFakeTransportRegistry(): TransportRegistry
{
$registry = new TransportRegistry();
$transport = new HeaderTransport(static::AUTH_TOKEN_HEADER_KEY);
try {
/** @var TransportRegistry $configured */
$configured = $this->container->get(TransportRegistry::class);
foreach (\array_keys($configured->getTransports()) as $name) {
$registry->setTransport((string) $name, $transport);
}
} catch (\Throwable) {
// Nothing to copy the names from; the fake transport is all there is.
}
$registry->setTransport('testing', $transport);
$registry->setDefaultTransport('testing');
return $registry;
}
}