Open Overdrivr opened 8 years ago
A potential solution:
nock
endpoints that passport will try to call during passport's authentication transactionapi/repositories/me/github
(with api.github.com
also nock
ed). It should return a fake list of repositories, validating the middlewareAlso, if nocking external oauth provider endpoints works, then it means we could test the entire oauth flow in unit tests, which would be great. To investigate
A quick idea for a simpler solution:
auth/login
endpointapi/Repositories/me/github
This has the advantage to validate everything from passport authenticating the user to the acl system, through the middleware we want to test in this ticket
This middleware is located in
./server/server.js
, registered right afterpassport.session()
. It was added by f2e71a606fb6aea8e97aa70faa52cebb533c722bTo test it, it is necessary to inject manually a fake access token in a request, inside
req.passport.user.accessToken
Initially wrote the following test but it doesn't work, the injected data is removed before it reaches the middleware to test.
Opened a question on SO, because I don't know for now how to test that.