{"id":14989734,"url":"https://github.com/jaredhanson/chai-passport-strategy","last_synced_at":"2025-06-26T02:36:47.395Z","repository":{"id":9840252,"uuid":"11831032","full_name":"jaredhanson/chai-passport-strategy","owner":"jaredhanson","description":"Helpers for testing Passport strategies with the Chai assertion library.","archived":false,"fork":false,"pushed_at":"2021-11-11T23:12:57.000Z","size":56,"stargazers_count":33,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-12T09:45:12.492Z","etag":null,"topics":["chai","passport"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jameswillweb/jekyll-for-designers","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredhanson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"jaredhanson","patreon":"jaredhanson","ko_fi":"jaredhanson"}},"created_at":"2013-08-02T00:28:28.000Z","updated_at":"2023-05-10T15:41:53.000Z","dependencies_parsed_at":"2022-08-30T09:11:20.609Z","dependency_job_id":null,"html_url":"https://github.com/jaredhanson/chai-passport-strategy","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/jaredhanson/chai-passport-strategy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fchai-passport-strategy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fchai-passport-strategy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fchai-passport-strategy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fchai-passport-strategy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredhanson","download_url":"https://codeload.github.com/jaredhanson/chai-passport-strategy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fchai-passport-strategy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259737455,"owners_count":22903839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chai","passport"],"created_at":"2024-09-24T14:18:50.636Z","updated_at":"2025-06-26T02:36:47.366Z","avatar_url":"https://github.com/jaredhanson.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jaredhanson","https://patreon.com/jaredhanson","https://ko-fi.com/jaredhanson"],"categories":[],"sub_categories":[],"readme":"# chai-passport-strategy\n\nHelpers for testing [Passport](https://www.passportjs.org/) strategies with the\n[Chai](https://www.chaijs.com/) assertion library.\n\n## Install\n\n    $ npm install chai-passport-strategy\n\n## Usage\n\n#### Use Plugin\n\nUse this plugin as you would all other Chai plugins:\n\n```javascript\nvar chai = require('chai');\n\nchai.use(require('chai-passport-strategy'));\n```\n\n#### Implement Test Cases\n\nOnce used, the `chai.passport.use` helper function will be available to set up\na test case which places a Passport strategy under test.\n\nThe helper returns a wrapper on which callbacks are registered to be executed\nwhen the strategy invokes its final action function.  The callbacks correspond\nto Passport's strategy API: `success()`, `fail()`, `redirect()`, `pass()`, and\n`error()`.  If the strategy invokes an action that doesn't have a registered\ncallback, the test helper will automatically throw an exception.\n\nFor example, a [Mocha](https://mochajs.org/) test case that tests a strategy\nwhich implements bearer token authentication:\n\n\n```javascript\nit('should authenticate request with token in header', function(done) {\n  chai.passport.use(new Strategy(function(token, cb) {\n      expect(token).to.equal('mF_9.B5f-4.1JqM');\n      return cb(null, { id: '248289761001' }, { scope: [ 'profile', 'email' ] });\n    }))\n    .request(function(req) {\n      req.headers['authorization'] = 'Bearer mF_9.B5f-4.1JqM';\n    })\n    .success(function(user, info) {\n      expect(user).to.deep.equal({ id: '248289761001' });\n      expect(info).to.deep.equal({ scope: [ 'profile', 'email' ] });\n      done();\n    })\n    .authenticate();\n});\n```\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2013-2021 Jared Hanson \u003c[https://www.jaredhanson.me/](https://www.jaredhanson.me/)\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fchai-passport-strategy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredhanson%2Fchai-passport-strategy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fchai-passport-strategy/lists"}