Skip to content

Instantly share code, notes, and snippets.

@zhangyuan
Created June 15, 2017 10:19
Show Gist options
  • Select an option

  • Save zhangyuan/196074f757518e24bc6ea46dc458a7a2 to your computer and use it in GitHub Desktop.

Select an option

Save zhangyuan/196074f757518e24bc6ea46dc458a7a2 to your computer and use it in GitHub Desktop.
A simple mock for passport saml (okta)
const SamlStrategy = require("passport-saml").Strategy;
const oldAuthenticate = SamlStrategy.prototype.authenticate;
export const mockAuthenticate = function (user) {
SamlStrategy.prototype.authenticate = function () {
this.success(user);
};
};
export const mockRedirectToOkta = function () {
SamlStrategy.prototype.authenticate = function (req) {
req.res.redirect("http://okta.local/login");
};
};
export const restoreAuthenticate = function () {
SamlStrategy.prototype.authenticate = oldAuthenticate;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment