Skip to content

Commit

Permalink
Merge pull request #53 from hapijs/lint
Browse files Browse the repository at this point in the history
correct linting issues
  • Loading branch information
stongo committed Jun 12, 2015
2 parents 6376ca8 + de80374 commit 806877d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ exports.register = function (server, options, next) {

var header = request.headers['x-csrf-token'];

if (!header) {
if (!header) {
return reply(Boom.forbidden());
}

Expand Down
40 changes: 25 additions & 15 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ describe('Crumb', function () {

var TestStream = function (opt) {

Stream.Readable.call(this, opt);
this._max = 2;
this._index = 1;
Stream.Readable.call(this, opt);
this._max = 2;
this._index = 1;
};

Hoek.inherits(TestStream, Stream.Readable);
Expand All @@ -145,7 +145,7 @@ describe('Crumb', function () {

expect(res.statusCode).to.equal(403);

server.inject({method: 'GET', url: '/6'}, function(res) {
server.inject({ method: 'GET', url: '/6' }, function (res) {

var header = res.headers['set-cookie'];
expect(header.length).to.equal(1);
Expand All @@ -154,15 +154,15 @@ describe('Crumb', function () {
var cookie = header[0].match(/crumb=([^\x00-\x20\"\,\;\\\x7F]*)/);
expect(res.result).to.equal('<!DOCTYPE html><html><head><title></title></head><body><div><h1></h1><h2>' + cookie[1] + '</h2></div></body></html>');

server.inject({method: 'GET', url: '/7'}, function(res) {
server.inject({ method: 'GET', url: '/7' }, function (res) {

var cookie = res.headers['set-cookie'].toString();
expect(cookie).to.contain('crumb');

var headers = {};
headers.origin = 'http://127.0.0.1';

server.inject({method: 'GET', url: '/1', headers: headers}, function(res) {
server.inject({ method: 'GET', url: '/1', headers: headers }, function (res) {

var cookie = res.headers['set-cookie'].toString();
expect(cookie).to.contain('crumb');
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('Crumb', function () {
options: {
foo: 'bar'
}
}, function(err) {
}, function (err) {

expect(err).to.exist();
expect(err.name).to.equal('ValidationError');
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('Crumb', function () {
}
},
{
method: 'GET', path: '/2', config: { plugins: { crumb: true } }, handler: function(request, reply) {
method: 'GET', path: '/2', config: { plugins: { crumb: true } }, handler: function (request, reply) {

var crumb = request.plugins.crumb;

Expand All @@ -316,7 +316,7 @@ describe('Crumb', function () {

server.inject({ method: 'GET', url: '/1' }, function (res) {

server.inject({ method: 'GET', url: '/2'}, function (res) {
server.inject({ method: 'GET', url: '/2' }, function (res) {

var header = res.headers['set-cookie'];
expect(header.length).to.equal(1);
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('Crumb', function () {
return request.headers['x-api-token'] === 'test';
};

server.register({ register: Crumb, options: { skip: skip }}, function (err) {
server.register({ register: Crumb, options: { skip: skip } }, function (err) {

expect(err).to.not.exist();
var headers = {};
Expand Down Expand Up @@ -376,7 +376,8 @@ describe('Crumb', function () {

var skip = true;

server.register({ register: Crumb, options: { skip: skip }}, function (err) {
server.register({ register: Crumb, options: { skip: skip } }, function (err) {

expect(err).to.not.exist();
var headers = {};
headers['X-API-Token'] = 'not-test';
Expand All @@ -395,6 +396,7 @@ describe('Crumb', function () {
server.connection();

server.register({ register: Crumb, options: { allowOrigins: ['*'] } }, function (err) {

expect(err).to.exist();
expect(err.name).to.equal('ValidationError');
expect(err.message).to.equal('child "allowOrigins" fails because ["allowOrigins" at position 0 contains an excluded value]');
Expand All @@ -406,7 +408,10 @@ describe('Crumb', function () {

var server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80, routes: { cors: true } });
server.route({ method: 'GET', path: '/1', handler: function (request, reply) { return reply('test'); } });
server.route({ method: 'GET', path: '/1', handler: function (request, reply) {

return reply('test');
} });

server.register({ register: Crumb, options: null }, function (err) {

Expand Down Expand Up @@ -489,7 +494,8 @@ describe('Crumb', function () {
}
}
]);
server.register({ register: Crumb, options: { allowOrigins: ['http://127.0.0.1']} }, function (err) {
server.register({ register: Crumb, options: { allowOrigins: ['http://127.0.0.1'] } }, function (err) {

expect(err).to.not.exist();
var headers = {};
headers.origin = 'http://127.0.0.1';
Expand Down Expand Up @@ -540,6 +546,7 @@ describe('Crumb', function () {
}
]);
server.register({ register: Crumb, options: null }, function (err) {

expect(err).to.not.exist();
var headers = {};
headers.origin = 'http://127.0.0.1';
Expand Down Expand Up @@ -591,6 +598,7 @@ describe('Crumb', function () {
]);

server.register({ register: Crumb, options: null }, function (err) {

expect(err).to.not.exist();
var headers = {};
headers.origin = 'http://127.0.0.1';
Expand All @@ -616,7 +624,8 @@ describe('Crumb', function () {
}
}
]);
server.register({ register: Crumb, options: { allowOrigins: ['http://127.0.0.1:2000']} }, function (err) {
server.register({ register: Crumb, options: { allowOrigins: ['http://127.0.0.1:2000'] } }, function (err) {

expect(err).to.not.exist();
var headers = {};
headers.origin = 'http://127.0.0.1:2000';
Expand Down Expand Up @@ -656,7 +665,8 @@ describe('Crumb', function () {
}
}
]);
server.register({ register: Crumb, options: { allowOrigins: ['http://127.0.0.1:*', 'http://*.test.com']} }, function (err) {
server.register({ register: Crumb, options: { allowOrigins: ['http://127.0.0.1:*', 'http://*.test.com'] } }, function (err) {

expect(err).to.not.exist();
var headers = {};
headers.origin = 'http://127.0.0.1:2000';
Expand Down

0 comments on commit 806877d

Please sign in to comment.