Skip to content

Keep configured auth transports when faking an actor - #91

Merged
roxblnfk merged 4 commits into
spiral:3.xfrom
dualfroz:fix-fakehttp-custom-auth-transport
Sep 21, 2026
Merged

roxblnfk merged 4 commits into
spiral:3.xfrom
dualfroz:fix-fakehttp-custom-auth-transport

Conversation

@dualfroz

Copy link
Copy Markdown
Contributor

withActor() replaced the whole TransportRegistry with a single "testing" transport, so AuthTransportMiddleware failed with "Undefined auth transport header".
The fake registry now keeps the app's transport names, each mapped to the fake header transport.

Refs spiral/framework#1231

withActor() replaced the whole TransportRegistry with a fresh one holding a
single transport named "testing". AuthTransportMiddleware, which is how
HttpAuthBootloader wires auth into an application, asks the registry for a
transport by name, so a request through it died with

    Spiral\Auth\Exception\TransportException: Undefined auth transport header

AuthMiddleware kept working because it iterates over every transport, which is
why the failure looked like it only happened with a custom transport.

The fake registry is now built from the names the application has configured,
each mapped to the same fake HeaderTransport that reads X-Test-Token, so
whichever name the middleware asks for it gets a transport that finds the test
token. "testing" stays and becomes the default. An application with no registry
bound behaves as before.

The test app had no withActor() coverage at all, so the three tests come with
two middleware stubs: one that runs AuthTransportMiddleware('header') resolved
from the http scope, one that reports the actor into the response body.

For spiral/framework#1231
@dualfroz

Copy link
Copy Markdown
Contributor Author

added a type for psalm, it didn't know what the container returns. the other psalm errors aren't from this pr i believe

… the fake one

Catching \Throwable hid real failures: a custom transport whose constructor or Autowire throws was silently dropped, and the request then failed with the misleading "Undefined auth transport" message. Only the absence of a registry binding is an expected condition.

Assisted-By: Claude Fable 5.1
… stub

The named-transport test used the built-in "header" transport, while the reported problem was about transports the application adds itself. A test bootloader registers a "custom" transport through HttpAuthBootloader::addTransport(); without the fix both named-transport tests fail with "Undefined auth transport <name>".

AuthTransportMiddleware is resolved by the container from an Autowire bound under an alias in the http scope, the same way an application registers it in a middleware group, so the hand-built HeaderAuthMiddleware stub is no longer needed.

Assisted-By: Claude Fable 5.1
@roxblnfk
roxblnfk force-pushed the fix-fakehttp-custom-auth-transport branch from 5291459 to 21d47dc Compare September 21, 2026 14:27
@roxblnfk
roxblnfk merged commit e812c3d into spiral:3.x Sep 21, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants