Skip to content
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

test: node 8 #976

Merged
merged 6 commits into from Jun 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions .travis.yml
Expand Up @@ -3,13 +3,7 @@ language: node_js
node_js:
- '6'
- '7'
matrix:
include:
- node_js: '8'
env: 'NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly'
allow_failures:
# Allow the nightly installs to fail
- env: 'NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly'
- '8'
install:
- npm i npminstall && npminstall
script:
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Expand Up @@ -2,6 +2,7 @@ environment:
matrix:
- nodejs_version: '6'
- nodejs_version: '7'
- nodejs_version: '8'

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
18 changes: 11 additions & 7 deletions test/lib/plugins/security.test.js
@@ -1,9 +1,11 @@
'use strict';

const request = require('supertest');
const mm = require('egg-mock');
const utils = require('../../utils');

describe('test/lib/plugins/security.test.js', () => {
afterEach(mm.restore);

describe('security.csrf = false', () => {
let app;
before(() => {
Expand All @@ -13,7 +15,7 @@ describe('test/lib/plugins/security.test.js', () => {
after(() => app.close());

it('should not check csrf', () => {
return request(app.callback())
return app.httpRequest()
.post('/api/user')
.send({ name: 'fengmk2' })
.expect(200)
Expand All @@ -33,7 +35,7 @@ describe('test/lib/plugins/security.test.js', () => {
after(() => app.close());

it('should check csrf', () => {
return request(app.callback())
return app.httpRequest()
.post('/api/user')
.send({ name: 'fengmk2' })
.expect(403)
Expand All @@ -50,7 +52,7 @@ describe('test/lib/plugins/security.test.js', () => {
after(() => app.close());

it('should not check csrf on /api/*', () => {
return request(app.callback())
return app.httpRequest()
.post('/api/user')
.send({ name: 'fengmk2' })
.expect(200)
Expand All @@ -61,7 +63,7 @@ describe('test/lib/plugins/security.test.js', () => {
});

it('should not check csrf on /api/*.json', () => {
return request(app.callback())
return app.httpRequest()
.post('/api/user.json')
.send({ name: 'fengmk2' })
.expect(200)
Expand All @@ -72,7 +74,9 @@ describe('test/lib/plugins/security.test.js', () => {
});

it('should check csrf on other.json', () => {
return request(app.callback())
// use prod env to ignore extends properties like frames
mm(app.config, 'env', 'prod');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dead-horse 还是让 egg-onerror 保留那些信息吧,开发阶段有用

return app.httpRequest()
.post('/apiuser.json')
.set('accept', 'application/json')
.send({ name: 'fengmk2' })
Expand All @@ -83,7 +87,7 @@ describe('test/lib/plugins/security.test.js', () => {
});

it('should check csrf on other', () => {
return request(app.callback())
return app.httpRequest()
.post('/apiuser')
.send({ name: 'fengmk2' })
.expect(/missing csrf token/)
Expand Down