Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
130 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
charset = utf-8 | ||
|
||
indent_style = space | ||
indent_size = 2 |
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,22 +1,11 @@ | ||
{ | ||
"extends": "eslint", | ||
"extends": "airbnb-base", | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 8, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"indent": ["error", 4, {"SwitchCase": 1}], | ||
"quotes": ["error", "single"], | ||
"no-unused-expressions": 0, | ||
"no-underscore-dangle": 0, | ||
"func-style": [ | ||
"error", | ||
"declaration", { "allowArrowFunctions": true } | ||
] | ||
"no-param-reassign": 0 | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ coverage | |
npm-debug.log | ||
node_modules | ||
.DS_Store | ||
logs/app.error.log | ||
package-lock.json |
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,10 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "7.6" | ||
- "7.7" | ||
- "7.8" | ||
- "7.9" | ||
- "7" | ||
- "8" | ||
script: | ||
- npm run lint | ||
- npm run test | ||
- npm run report | ||
- npm run report |
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,13 +1,13 @@ | ||
environment: | ||
matrix: | ||
- nodejs_version: "7.7" | ||
- nodejs_version: "8" | ||
install: | ||
- ps: Install-Product node $env:nodejs_version | ||
- npm install | ||
test_script: | ||
- node --version | ||
- npm --version | ||
- npm run lint | ||
- npm run test:lint | ||
- npm run test:security | ||
- npm run test:code | ||
build: off | ||
build: off |
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,81 +1,86 @@ | ||
const App = require('yeps'); | ||
const chai = require('chai'); | ||
const chaiHttp = require('chai-http'); | ||
const http = require('http'); | ||
const srv = require('yeps-server'); | ||
const helmet = require('..'); | ||
const expect = chai.expect; | ||
|
||
const { expect } = chai; | ||
|
||
chai.use(chaiHttp); | ||
let app; | ||
let server; | ||
|
||
describe('YEPS helmet', async () => { | ||
beforeEach(() => { | ||
app = new App(); | ||
server = srv.createHttpServer(app); | ||
}); | ||
|
||
beforeEach(() => { | ||
app = new App(); | ||
}); | ||
afterEach(() => { | ||
server.close(); | ||
}); | ||
|
||
it('should test helmet', async () => { | ||
let isTestFinished1 = false; | ||
let isTestFinished2 = false; | ||
|
||
app.then(helmet()); | ||
|
||
app.then(async (ctx) => { | ||
isTestFinished1 = true; | ||
|
||
it('should test helmet', async () => { | ||
let isTestFinished1 = false; | ||
let isTestFinished2 = false; | ||
|
||
app.then(helmet()); | ||
|
||
app.then(async ctx => { | ||
isTestFinished1 = true; | ||
|
||
ctx.res.statusCode = 200; | ||
ctx.res.end(); | ||
}); | ||
|
||
await chai.request(http.createServer(app.resolve())) | ||
.get('/') | ||
.send() | ||
.then(res => { | ||
expect(res).to.have.status(200); | ||
expect(res.headers['x-dns-prefetch-control']).to.be.equal('off'); | ||
expect(res.headers['x-frame-options']).to.be.equal('SAMEORIGIN'); | ||
expect(res.headers['x-download-options']).to.be.equal('noopen'); | ||
expect(res.headers['x-content-type-options']).to.be.equal('nosniff'); | ||
expect(res.headers['x-xss-protection']).to.be.equal('1; mode=block'); | ||
isTestFinished2 = true; | ||
}); | ||
|
||
expect(isTestFinished1).is.true; | ||
expect(isTestFinished2).is.true; | ||
ctx.res.statusCode = 200; | ||
ctx.res.end(); | ||
}); | ||
|
||
it('should test helmet with options', async () => { | ||
let isTestFinished1 = false; | ||
let isTestFinished2 = false; | ||
|
||
app.then(helmet({ | ||
frameguard: { | ||
action: 'deny' | ||
} | ||
})); | ||
|
||
app.then(async ctx => { | ||
isTestFinished1 = true; | ||
|
||
ctx.res.statusCode = 200; | ||
ctx.res.end(); | ||
}); | ||
|
||
await chai.request(http.createServer(app.resolve())) | ||
.get('/') | ||
.send() | ||
.then(res => { | ||
expect(res).to.have.status(200); | ||
expect(res.headers['x-dns-prefetch-control']).to.be.equal('off'); | ||
expect(res.headers['x-frame-options']).to.be.equal('DENY'); | ||
expect(res.headers['x-download-options']).to.be.equal('noopen'); | ||
expect(res.headers['x-content-type-options']).to.be.equal('nosniff'); | ||
expect(res.headers['x-xss-protection']).to.be.equal('1; mode=block'); | ||
isTestFinished2 = true; | ||
}); | ||
|
||
expect(isTestFinished1).is.true; | ||
expect(isTestFinished2).is.true; | ||
await chai.request(server) | ||
.get('/') | ||
.send() | ||
.then((res) => { | ||
expect(res).to.have.status(200); | ||
expect(res.headers['x-dns-prefetch-control']).to.be.equal('off'); | ||
expect(res.headers['x-frame-options']).to.be.equal('SAMEORIGIN'); | ||
expect(res.headers['x-download-options']).to.be.equal('noopen'); | ||
expect(res.headers['x-content-type-options']).to.be.equal('nosniff'); | ||
expect(res.headers['x-xss-protection']).to.be.equal('1; mode=block'); | ||
isTestFinished2 = true; | ||
}); | ||
|
||
expect(isTestFinished1).is.true; | ||
expect(isTestFinished2).is.true; | ||
}); | ||
|
||
it('should test helmet with options', async () => { | ||
let isTestFinished1 = false; | ||
let isTestFinished2 = false; | ||
|
||
app.then(helmet({ | ||
frameguard: { | ||
action: 'deny', | ||
}, | ||
})); | ||
|
||
app.then(async (ctx) => { | ||
isTestFinished1 = true; | ||
|
||
ctx.res.statusCode = 200; | ||
ctx.res.end(); | ||
}); | ||
|
||
await chai.request(server) | ||
.get('/') | ||
.send() | ||
.then((res) => { | ||
expect(res).to.have.status(200); | ||
expect(res.headers['x-dns-prefetch-control']).to.be.equal('off'); | ||
expect(res.headers['x-frame-options']).to.be.equal('DENY'); | ||
expect(res.headers['x-download-options']).to.be.equal('noopen'); | ||
expect(res.headers['x-content-type-options']).to.be.equal('nosniff'); | ||
expect(res.headers['x-xss-protection']).to.be.equal('1; mode=block'); | ||
isTestFinished2 = true; | ||
}); | ||
|
||
expect(isTestFinished1).is.true; | ||
expect(isTestFinished2).is.true; | ||
}); | ||
}); |