Closed f-fuchs closed 8 months ago
you can try switch auto_error to false
My problem was that I could not override the original security dependency. I guess setting auto_error always to False and adding a new dependency, which I can then override, atop of this library could work. 🤔
But I already choose to just reimplement the functionality as functions instead of classes, so that I can override them with FastAPIs
dependency_overrides
.
Thanks for the suggestion though 👍
Hey,
I am using your excellent library to add JWT based authorization to my FastAPI app. But now I am at a point where I would like to add unit test to my project to check my routes. And for this I would like to disable authorization.
Based on my research this should be doable with
app.dependency_overrides
, see https://fastapi.tiangolo.com/advanced/testing-dependencies/.But because we are not actually passing a method to
Security
I am not sure what to override. I tried passing the sameDepends(get_access_security())
code with which I created the dependency annotation into the override, but this does not work. Therefore I wanted to ask what exactly I should override or if there is another option to disable authorization for my testing purposes. Below are the relevant snippets from my source code.config.py
route
py test fixture