-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added cookie security #44
Conversation
Can one of the admins verify this patch? |
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
objects would not have been parsed
handle the case where the header for set-cookie is a string and not an array
@slnode ok to test |
constructor(cookie, options) { | ||
super(options); | ||
|
||
cookie = _.get(cookie, 'set-cookie', cookie) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing semi-colon
super(options); | ||
|
||
cookie = _.get(cookie, 'set-cookie', cookie) | ||
var cookies = _.map(_.isArray(cookie) ? cookie : [cookie], function (c) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this would be better I think. Less dependency on lodash
this.cookie = (Array.isArray(cookie) ? cookie : [cookie])
.map(c => c.split(';')[0])
.join('; ');
|
||
describe('CookieSecurity', function() { | ||
var CookieSecurity = require('../../').CookieSecurity; | ||
var cookie = "cookie-value"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single quotes
var instance2 = new CookieSecurity(headers); | ||
|
||
it('is accepted with cookie string', function () { | ||
instance1.should.have.property("cookie", cookie); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single quotes
|
||
describe('defaultOption param', function() { | ||
it('is accepted as the second param', function() { | ||
new CookieSecurity(cookie, {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like it is missing the test part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied and modified the existing BearerSecurity test. I'm not sure what is missing since nether bearer or cookie security tests look any different.
var defaultOptions = { foo: 2 }; | ||
var instance = new CookieSecurity(cookie, defaultOptions); | ||
instance.addOptions(options); | ||
options.should.have.property("foo", 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single quote
changed double to single quotes in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was fast!
var Security = require('./security'); | ||
|
||
function hasCookieHeader (cookie) { | ||
return typeof cookie === 'object' && cookie.hasOwnProperty('set-cookie') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing semi-colon
constructor(cookie, options) { | ||
super(options); | ||
|
||
cookie = hasCookieHeader(cookie) ? cookie['set-cookie'] : cookie |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing semi-colon
@bhoriuchi Please sign the CLA. |
Can one of the admins verify this patch? |
Signed |
Issue #38