-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add application level Cookie options (#4086)
* test: fix doctools path on windows
- Loading branch information
Showing
12 changed files
with
111 additions
and
5 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ node_js: | |
- '8' | ||
- '10' | ||
- '12' | ||
- '13' | ||
before_install: | ||
- npm install -g npminstall | ||
install: | ||
|
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
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
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,4 @@ | ||
module.exports = async ctx => { | ||
ctx.cookies.set('foo', 'bar'); | ||
ctx.body = 'hello'; | ||
}; |
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,3 @@ | ||
module.exports = app => { | ||
app.get('home', '/', 'home'); | ||
}; |
7 changes: 7 additions & 0 deletions
7
test/fixtures/apps/app-config-cookies/config/config.default.js
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,7 @@ | ||
'use strict'; | ||
|
||
exports.keys = 'test key'; | ||
|
||
exports.cookies = { | ||
sameSite: 'lax', | ||
}; |
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,3 @@ | ||
{ | ||
"name": "app-config-cookies" | ||
} |
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,28 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const mm = require('egg-mock'); | ||
const utils = require('../../../utils'); | ||
|
||
describe('test/lib/core/config/config.cookies.test.js', () => { | ||
let app; | ||
before(() => { | ||
app = utils.app('apps/app-config-cookies'); | ||
return app.ready(); | ||
}); | ||
after(() => app.close()); | ||
|
||
afterEach(mm.restore); | ||
|
||
it('should auto set sameSite cookie', async () => { | ||
const res = await app.httpRequest() | ||
.get('/'); | ||
assert(res.status === 200); | ||
assert(res.text === 'hello'); | ||
const cookies = res.headers['set-cookie']; | ||
assert(cookies.length >= 1); | ||
for (const cookie of cookies) { | ||
assert(cookie.includes('; samesite=lax')); | ||
} | ||
}); | ||
}); |
那么session的配置呢?