-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Include new mocking system for overriding auths during test. * Update version and include better mocking scenario for tests. Fix issues with matches being cancelled. Update deps. Update types for compiling.
- Loading branch information
1 parent
6ee1d26
commit 5c8c5c0
Showing
7 changed files
with
1,846 additions
and
2,144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
import { Strategy as _Strategy } from "passport-strategy"; | ||
import { inherits } from "util"; // The reply from Github OAuth2 | ||
/** | ||
* Author: Michael Weibel <[email protected]> | ||
* License: MIT | ||
*/ | ||
"use strict"; | ||
|
||
import {Strategy as OpenIDStrategy} from '@passport-next/passport-openid'; | ||
import { inherits } from 'util'; | ||
import user from "./mockProfile.js"; | ||
class MockStrategy extends _Strategy{ | ||
constructor(name, strategyCallback) { | ||
super(name); | ||
|
||
|
||
if (!name || !name.length) { | ||
throw new TypeError("DevStrategy requires a Strategy name"); | ||
} | ||
|
||
_Strategy.call(this); | ||
this.name = name; | ||
this._identifier = user; | ||
// Callback supplied to OAuth2 strategies handling verification | ||
this._cb = strategyCallback; | ||
} | ||
authenticate() { | ||
this._cb(null, this._identifier, (error, user) => { | ||
this.success(user); | ||
}); | ||
} | ||
|
||
function MockStrategy(options, verify) { | ||
this.name = options.name; | ||
this.passAuthentication = options.passAuthentication ? true : false; | ||
this.userId = options.userId || 1; | ||
this.verify = verify; | ||
this.user = new user(); | ||
} | ||
export { | ||
MockStrategy as default | ||
}; | ||
|
||
inherits(MockStrategy, OpenIDStrategy); | ||
|
||
MockStrategy.prototype.authenticate = function authenticate(req) { | ||
if (this.passAuthentication) { | ||
var self = this; | ||
this.verify(this.user.id, this.user, function(identifier, profile, done) { | ||
self.success(profile); | ||
}); | ||
} else { | ||
this.fail('Unauthorized'); | ||
} | ||
} | ||
|
||
export default MockStrategy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.