Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "cobbler", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Passport mock for integration tests", | ||
@@ -20,2 +20,5 @@ "main": "index.js", | ||
"author": "Yung Hwa Kwon", | ||
"contributors": [ | ||
"Jeremy Buis <buis.jeremy@gmail.com> (https://github.com/jeremybuis)" | ||
], | ||
"license": "MIT", | ||
@@ -32,2 +35,4 @@ "bugs": { | ||
"passport-github": "^0.1.5", | ||
"passport-google-oauth": "^0.1.5", | ||
"passport-linkedin-oauth2": "^1.1.1", | ||
"middle-earth": "0.0.6", | ||
@@ -34,0 +39,0 @@ "express": "^4.3.1", |
@@ -111,2 +111,6 @@ # Cobbler.js | ||
## Contributors. Many Thanks! | ||
* Jeremy Buis [@jeremybuis](https://github.com/jeremybuis) | ||
## License | ||
@@ -113,0 +117,0 @@ |
@@ -5,2 +5,4 @@ /* jshint node: true */ | ||
var GithubStrategy = require('passport-github').Strategy; | ||
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; | ||
var LinkedInStrategy = require('passport-linkedin-oauth2').Strategy; | ||
@@ -24,2 +26,23 @@ /* | ||
/* | ||
* linkedin strategy | ||
*/ | ||
passport.use(new LinkedInStrategy({ | ||
clientID: 'clientID', | ||
clientSecret: 'clientSecret', | ||
callbackURL: '/auth/linkedin/callback', | ||
scope: ['r_fullprofile', 'r_emailaddress', 'r_network'] | ||
}, strategyCallback)); | ||
/* | ||
* google strategy | ||
*/ | ||
passport.use(new GoogleStrategy({ | ||
clientID: 'clientID', | ||
clientSecret: 'clientSecret', | ||
callbackURL: '/auth/google/callback' | ||
}, strategyCallback)); | ||
/* | ||
* github strategy callback | ||
@@ -38,3 +61,3 @@ * | ||
id: profile.id, | ||
name: profile.displayName | ||
name: profile.name || profile.displayName | ||
}); | ||
@@ -41,0 +64,0 @@ }); |
@@ -25,5 +25,7 @@ /* jshint node: true */ | ||
var html = "<html>" + | ||
"<head><title>Login</title></head>" + | ||
"<body><a href=\"/auth/github\" rel=\"login-with-github\">Login with github</a></body>" + | ||
"</html>"; | ||
"<head><title>Login</title></head><body>" + | ||
"<a href=\"/auth/github\" rel=\"login-with-github\">Login with github</a>" + | ||
"<a href=\"/auth/linkedin\" rel=\"login-with-linkedin\">Login with linkedin</a>" + | ||
"<a href=\"/auth/google\" rel=\"login-with-google\">Login with google</a>" + | ||
"</body></html>"; | ||
res.send(html); | ||
@@ -62,2 +64,26 @@ }); | ||
}); | ||
app.get("/auth/linkedin", | ||
passport.authenticate('linkedin', {state: 'SOME STATE'}), | ||
function(req, res, next) { | ||
// | ||
}); | ||
app.get("/auth/linkedin/callback", | ||
passport.authenticate("linkedin", {failureRedirect: "/auth/failure"}), | ||
function(req, res, next) { | ||
res.redirect("/"); | ||
}); | ||
app.get("/auth/google", | ||
passport.authenticate('google', {scope: 'profile email'}), | ||
function(req, res, next) { | ||
// | ||
}); | ||
app.get("/auth/google/callback", | ||
passport.authenticate("google", {failureRedirect: "/auth/failure"}), | ||
function(req, res, next) { | ||
res.redirect("/"); | ||
}); | ||
}; | ||
@@ -64,0 +90,0 @@ |
@@ -17,3 +17,16 @@ /* jshint node: true */ | ||
}; | ||
var linkedinProfile = { | ||
provider: 'linkedin', | ||
id: 54321, | ||
displayName: 'John Doe', | ||
emailAddress: 'john@doe.com' | ||
}; | ||
var googleProfile = { | ||
provider: 'google', | ||
id: 'abcdef', | ||
displayName: 'John Doe', | ||
email: 'john@doe.com' | ||
}; | ||
var app; | ||
@@ -32,3 +45,3 @@ beforeEach(function() { | ||
it("success w/ the supplied profile", function(done) { | ||
it("success w/ the supplied profile and github strategy", function(done) { | ||
passport = cobbler('passport-github', profile); | ||
@@ -43,2 +56,12 @@ server = app.listen(7331, function() { | ||
it("success w/ the supplied profile and linkedin strategy", function(done) { | ||
passport = cobbler('passport-linkedin-oauth2', linkedinProfile); | ||
server = app.listen(7331, function() { | ||
new WalkingDead(url).zombify(zopts) | ||
.when(loginWithLinkedin) | ||
.then(assertSuccessfullogin) | ||
.end(done); | ||
}); | ||
}); | ||
it("defines a custom callbackURL", function(done) { | ||
@@ -71,3 +94,3 @@ passport = cobbler('passport-github', profile, { | ||
it("can be passed the Strategy", function(done) { | ||
it("can be passed the Github Strategy", function(done) { | ||
var strategy = require('passport-github').Strategy; | ||
@@ -83,2 +106,13 @@ passport = cobbler(strategy, profile); | ||
it("can be passed the Google Strategy", function(done) { | ||
var strategy = require('passport-google-oauth').OAuth2Strategy; | ||
passport = cobbler(strategy, profile); | ||
server = app.listen(7331, function() { | ||
new WalkingDead(url).zombify(zopts) | ||
.when(loginWithGoogle) | ||
.then(assertSuccessfullogin) | ||
.end(done); | ||
}); | ||
}); | ||
it("can be passed the prototype object of the strategy", function(done) { | ||
@@ -138,2 +172,18 @@ var proto = require('passport-github').Strategy.prototype; | ||
/* | ||
* click linkedin login | ||
*/ | ||
function loginWithLinkedin(browser, next) { | ||
browser.clickLink('[rel="login-with-linkedin"]', next); | ||
} | ||
/* | ||
* click google login | ||
*/ | ||
function loginWithGoogle(browser, next) { | ||
browser.clickLink('[rel="login-with-google"]', next); | ||
} | ||
/* | ||
* assert successful login | ||
@@ -140,0 +190,0 @@ */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20413
11
537
119
12