All Projects → jaredhanson → chai-passport-strategy

jaredhanson / chai-passport-strategy

Licence: MIT License
Helpers for testing Passport strategies with the Chai assertion library.

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to chai-passport-strategy

Laravel-Ecommerce-API
Lite E-Commerce API
Stars: ✭ 32 (+0%)
Mutual labels:  passport
generator-nude
A generator to scaffolding HTTP API's, with Express.js and es6
Stars: ✭ 16 (-50%)
Mutual labels:  chai
QKMRZScanner
Scan MRZ (Machine Readable Zone) from identity documents (passport, id, visa) using iPhone/iPad (iOS)
Stars: ✭ 81 (+153.13%)
Mutual labels:  passport
cucumber-steps
🥒 Quick start for testing with Cucumber.js
Stars: ✭ 15 (-53.12%)
Mutual labels:  chai
system information school
Build website using laravel as backend, vue js as front end and full request using api with middleware api passport.
Stars: ✭ 17 (-46.87%)
Mutual labels:  passport
passport-line-auth
Line authentication strategy for Passport and Node.js.
Stars: ✭ 31 (-3.12%)
Mutual labels:  passport
alexa-skill-boilerplate
An easy to use Amazon Alexa Skill Boilerplate for fast skill creation
Stars: ✭ 54 (+68.75%)
Mutual labels:  chai
TogetherStream
A social and synchronized streaming experience
Stars: ✭ 16 (-50%)
Mutual labels:  passport
spectron-typescript-starter
Spectron TypeScript Starter for e2e testing electron applications
Stars: ✭ 15 (-53.12%)
Mutual labels:  chai
express-mysql-rest
Building the simple api with sequelize, mysql and express js. this repository contains the code about how to use sequelize with mysql at express js. for example i have provide the crud operation to this repository. You can also testing the api with chai and mocha with chai-http by this repository
Stars: ✭ 25 (-21.87%)
Mutual labels:  chai
js-unit-testing-interview-questions
No description or website provided.
Stars: ✭ 29 (-9.37%)
Mutual labels:  chai
graphql-starter
Node, Express, GraphQL, Neo4j, Mocha and ES6
Stars: ✭ 17 (-46.87%)
Mutual labels:  chai
Clean-Laravel-Api
⭐️ Build APIs You Won't Hate In Laravel.
Stars: ✭ 85 (+165.63%)
Mutual labels:  passport
yelp-camp
A Node.js web application project from the Udemy course - The Web Developer Bootcamp by Colt Steele
Stars: ✭ 36 (+12.5%)
Mutual labels:  passport
laravel8-passport-fcm-api
Live streaming gigs mobile app RESTful API endpoints
Stars: ✭ 13 (-59.37%)
Mutual labels:  passport
jeesuite-passport
Jeesuite-passport是面向企业级单点登录、统一认证的一站式解决方案。支持微信、企业微信、主流开放平台OAuth、Oauth2.0,JWT、SAML2.0多种认证集成模式。
Stars: ✭ 108 (+237.5%)
Mutual labels:  passport
eslint-config-adjunct
A reasonable collection of plugins to use alongside your main esLint configuration
Stars: ✭ 39 (+21.88%)
Mutual labels:  chai
react-isomorphic-bundle
React Redux Universal (isomorphic) bundle
Stars: ✭ 53 (+65.63%)
Mutual labels:  passport
node-express-mongo-passport-jwt-typescript
A Node.js back end web application with REST API, user JWT authentication and MongoDB data storage using TypeScript
Stars: ✭ 51 (+59.38%)
Mutual labels:  passport
react-innertext
Returns the innerText of a React JSX object.
Stars: ✭ 37 (+15.63%)
Mutual labels:  chai

chai-passport-strategy

Helpers for testing Passport strategies with the Chai assertion library.

Install

$ npm install chai-passport-strategy

Usage

Use Plugin

Use this plugin as you would all other Chai plugins:

var chai = require('chai');

chai.use(require('chai-passport-strategy'));

Implement Test Cases

Once used, the chai.passport.use helper function will be available to set up a test case which places a Passport strategy under test.

The helper returns a wrapper on which callbacks are registered to be executed when the strategy invokes its final action function. The callbacks correspond to Passport's strategy API: success(), fail(), redirect(), pass(), and error(). If the strategy invokes an action that doesn't have a registered callback, the test helper will automatically throw an exception.

For example, a Mocha test case that tests a strategy which implements bearer token authentication:

it('should authenticate request with token in header', function(done) {
  chai.passport.use(new Strategy(function(token, cb) {
      expect(token).to.equal('mF_9.B5f-4.1JqM');
      return cb(null, { id: '248289761001' }, { scope: [ 'profile', 'email' ] });
    }))
    .request(function(req) {
      req.headers['authorization'] = 'Bearer mF_9.B5f-4.1JqM';
    })
    .success(function(user, info) {
      expect(user).to.deep.equal({ id: '248289761001' });
      expect(info).to.deep.equal({ scope: [ 'profile', 'email' ] });
      done();
    })
    .authenticate();
});

License

The MIT License

Copyright (c) 2013-2021 Jared Hanson <https://www.jaredhanson.me/>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].