Skip to content

Commit

Permalink
test: node 8 (#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored and dead-horse committed Jun 10, 2017
1 parent 1b108a7 commit 13b7c19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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');
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

0 comments on commit 13b7c19

Please sign in to comment.