angular-fullstack/generator-angular-fullstack
View on GitHubQuestion: API Testing with Passport
Open
#494 opened on Aug 27, 2014
Help Wantedquestion
Description
Hi, I'm not sure if this is the right place to post this question but I'm not having any luck elsewhere. I'm new to testing and I'm not having any luck on SO etc. as they lack the context of whats already provided by this generator.
Most of my routes on the API are protected. What I'm trying to do is write test specs that:
- Test endpoints without authorization (that fail)
- Test endpoints with auth (pass)
- Then test specifics/contents on the data returned by each endpoint while authorized.
What I'm having trouble with, is how to write the tests such that:
- The test users are created (user.model.spec.js clears all users)
- Authenticating the user with passport.js (local strategy is used)
- Test endpoints with auth and without auth and the particulars of the endpoint whilst authorized.
Please help, i'm pulling my hair out!