angular-fullstack/generator-angular-fullstack

Question: API Testing with Passport

Open

#494 建立於 2014年8月27日

在 GitHub 查看
 (26 留言) (0 反應) (0 負責人)JavaScript (6,134 star) (1,268 fork)batch import
Help Wantedquestion

描述

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!

貢獻者指南