Extend req/res mock to include send()
TigerC10 opened this issue ยท 4 comments
Some of the passport strategies out there use req.res.send()
to achieve a redirect via automatic post (for example: passport-saml).
In order to support this, koa-passport
should mock out the send()
function as well as make the res
mock available on the req
mock.
Hi, do you now whether req.res
is set by those strategies or whether it is part of Express? Totally agree on the send()
function.
req.res
is definitely not set by those strategies. I've inadvertently used it in express projects myself in non-passport projects before I learned how res
should more properly be accessed. While learning express, console.dir(req)
showed me that I had a req.res
and I used it instead of just adding res
to the middleware function's parameters. Thankfully I've learned not to do that anymore!
Passport kind of forces these strategies to go through req
in this non-ideal way:
Passport doesn't expose res
to strategies separately. ๐
Thanks for elaborating! It should definitely be added to koa-passport ๐
Thanks for merging and releasing the new version so quickly! ๐