Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@passport-next/chai-passport-strategy
Advanced tools
Helpers for testing Passport strategies with the Chai assertion library.
Helpers for testing Passport strategies with the Chai assertion library.
$ npm install @passport-next/chai-passport-strategy
Use this plugin as you would all other Chai plugins:
var chai = require('chai');
chai.use(require('chai-passport-strategy'));
Once used, the chai.passport.use
helper function will be available to set up
test cases for Passport strategies.
The helper function can be called from a hook to setup the test case. 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.
The following demonstrates a Mocha test case, taken from passport-http-bearer's test suite.
describe('token strategy', function() {
var strategy = new Strategy(function(token, done) {
if (token == 'vF9dft4qmT') {
return done(null, { id: '1234' }, { scope: 'read' });
}
return done(null, false);
});
describe('handling a request with valid credential in header', function() {
var user
, info;
before(function(done) {
chai.passport.use(strategy)
.success(function(u, i) {
user = u;
info = i;
done();
})
.req(function(req) {
req.headers.authorization = 'Bearer vF9dft4qmT';
})
.authenticate();
});
it('should supply user', function() {
expect(user).to.be.an.object;
expect(user.id).to.equal('1234');
});
it('should supply info', function() {
expect(info).to.be.an.object;
expect(info.scope).to.equal('read');
});
});
});
FAQs
Helpers for testing Passport strategies with the Chai assertion library.
The npm package @passport-next/chai-passport-strategy receives a total of 0 weekly downloads. As such, @passport-next/chai-passport-strategy popularity was classified as not popular.
We found that @passport-next/chai-passport-strategy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.