Skip to content

Commit

Permalink
deps: egg-cookies@2 (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse authored and fengmk2 committed Nov 22, 2016
1 parent 4062648 commit 912fd2a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 157 deletions.
5 changes: 2 additions & 3 deletions app/extend/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const http = require('http');
const assert = require('assert');
const Keygrip = require('../../lib/core/keygrip');
const Service = require('../../lib/core/base_service');
const view = require('../../lib/core/view');
const AppWorkerClient = require('../../lib/core/app_worker_client');
Expand Down Expand Up @@ -127,8 +126,8 @@ module.exports = {
throw new Error('Please set config.keys first');
}
}
const keyConfig = this.config.keys.split(',').map(s => s.trim());
this[KEYS] = new Keygrip(keyConfig);

this[KEYS] = this.config.keys.split(',').map(s => s.trim());
}
return this[KEYS];
},
Expand Down
2 changes: 1 addition & 1 deletion examples/cookie/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ describe('example cookie test', () => {
.get('/forget')
.expect(302)
.expect('Location', '/')
.expect('Set-Cookie', /^remember=; path=\/; expires=[^;]+; httponly$/);
.expect('Set-Cookie', /^remember=; path=\/; expires=[^;]+; httponly,remember\.sig=; path=\/; expires=[^;]+; httponly$/);
});
});
147 changes: 0 additions & 147 deletions lib/core/keygrip.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"debug": "^2.3.0",
"delegates": "^1.0.0",
"egg-cluster": "^1.0.0",
"egg-cookies": "^1.0.0",
"egg-cookies": "^2.1.0",
"egg-core": "^1.1.0",
"egg-cors": "^1.0.0",
"egg-development": "^1.0.2",
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/apps/encrypt-cookies/app/controller/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module.exports = function* () {
var encrypt = this.getCookie('foo', {
encrypt: true
});
var encryptWrong = this.getCookie('foo');
var plain = this.getCookie('plain');
var encryptWrong = this.getCookie('foo', { signed: false });
var plain = this.getCookie('plain', { signed: false });
this.setCookie('foo', 'bar 中文', {
encrypt: true
});
this.setCookie('plain', 'text ok');
this.setCookie('plain', 'text ok', { signed: false });
this.body = {
set: 'bar 中文',
encrypt: encrypt,
Expand Down
5 changes: 3 additions & 2 deletions test/lib/core/cookies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('test/lib/core/cookies.test.js', () => {
ctx.response.get('set-cookie').should.eql([
'foo=bar',
'foo1=bar1; path=/; httponly',
'foo1.sig=Fqo9DaOWFOs3Gxsv0OHgyhhnJrjuY8jItBdSO-5WRgM; path=/; httponly',
]);
});

Expand All @@ -40,7 +41,7 @@ describe('test/lib/core/cookies.test.js', () => {
ctx.setCookie('foo', 'bar', {
encrypt: true,
});
}).should.throw('.keys required for encrypt cookies');
}).should.throw('.keys required for encrypt/sign cookies');
});

it('should throw TypeError when get encrypt on keys not exists', () => {
Expand All @@ -51,7 +52,7 @@ describe('test/lib/core/cookies.test.js', () => {
ctx.getCookie('foo', {
encrypt: true,
});
}).should.throw('.keys required for encrypt cookies');
}).should.throw('.keys required for encrypt/sign cookies');
});

it('should not set secure when request protocol is http', done => {
Expand Down

0 comments on commit 912fd2a

Please sign in to comment.