Skip to content

Commit

Permalink
test: add chips test case
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 26, 2023
1 parent 374f6e2 commit d6ba359
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 26 deletions.
21 changes: 0 additions & 21 deletions .autod.conf.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules/
coverage/
test/fixtures/**/run
dump.rdb
package-lock.json
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_js:
- '10'
- '12'
before_install:
- npm i npminstall -g
- npm i npminstall@5 -g
install:
- npminstall
script:
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"koa-session": "^6.0.0"
},
"devDependencies": {
"autod": "^2.10.1",
"egg": "next",
"egg": "^3.17.5",
"egg-bin": "^4.3.5",
"egg-ci": "^1.8.0",
"egg-mock": "^3.13.1",
Expand All @@ -44,8 +43,7 @@
"test": "npm run lint -- --fix && egg-bin test",
"test-local": "egg-bin test",
"cov": "egg-bin cov",
"ci": "npm run lint && npm run cov",
"autod": "autod"
"ci": "npm run lint && npm run cov"
},
"ci": {
"version": "8, 10, 12",
Expand Down
24 changes: 24 additions & 0 deletions test/app/middleware/session.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,30 @@ describe('test/app/middlewares/session.test.js', () => {
});
});

describe('chips', () => {
before(() => {
app = mm.app({ baseDir: 'chips' });
return app.ready();
});
beforeEach(() => {
agent = request.agent(app.callback());
});
after(() => app.close());

it('should work with chips', async () => {
await agent
.get('/set?foo=bar')
.set('user-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.4044.138 Safari/537.36')
.set('x-forwarded-proto', 'https')
.expect(200)
.expect({ foo: 'bar' })
.expect(res => {
const cookie = res.headers['set-cookie'].join('|');
assert(cookie.includes('; secure; httponly; partitioned'));
});
});
});

describe('logValue', () => {
before(() => {
app = mm.app({ baseDir: 'logValue-false-session' });
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/chips/app/controller/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

exports.get = async ctx => {
ctx.body = ctx.session;
};

exports.set = async ctx => {
ctx.session = ctx.query;
ctx.body = ctx.session;
};
6 changes: 6 additions & 0 deletions test/fixtures/chips/app/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = app => {
app.get('/get', 'home.get');
app.get('/set', 'home.set');
};
8 changes: 8 additions & 0 deletions test/fixtures/chips/config/config.default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

exports.keys = 'keys';
exports.session = {
partitioned: true,
};

exports.proxy = true;
3 changes: 3 additions & 0 deletions test/fixtures/chips/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "chips-session"
}

0 comments on commit d6ba359

Please sign in to comment.