add stryker, test for timeout valid signature

This commit is contained in:
Timo Hocker 2020-03-09 07:50:35 +01:00
parent 314b9ffb19
commit d47281149f
5 changed files with 26 additions and 3148 deletions

3
.gitignore vendored
View File

@ -2,3 +2,6 @@
/dist/ /dist/
/.nyc_output/ /.nyc_output/
/coverage/ /coverage/
# stryker temp files
.stryker-tmp

View File

@ -6,6 +6,8 @@
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@scode/eslint-config": "^1.2.25", "@scode/eslint-config": "^1.2.25",
"@stryker-mutator/core": "^2.5.0",
"@stryker-mutator/javascript-mutator": "^2.5.0",
"ava": "^3.5.0", "ava": "^3.5.0",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"nyc": "^15.0.0" "nyc": "^15.0.0"

11
stryker.conf.js Normal file
View File

@ -0,0 +1,11 @@
module.exports = function(config) {
config.set({
mutator: "javascript",
packageManager: "yarn",
reporters: ["clear-text"],
testRunner: "command",
transpilers: [],
coverageAnalysis: "all",
mutate: ["index.js"]
});
};

View File

@ -103,6 +103,16 @@ test ('reject old signatures', async (t) => {
t.is (dec, null); t.is (dec, null);
}); });
test ('do not reject valid signatures', async (t) => {
const obj = { foo: 'bar' };
const str = crypto.sign_object (obj, 'baz');
await new Promise ((res) => {
setTimeout (res, 10);
});
const dec = crypto.verify_signature (str, 'baz', 100);
t.deepEqual (obj, dec);
});
test ('decode problematic token', (t) => { test ('decode problematic token', (t) => {
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
const str = 'eyJpYXQiOjE1ODE0NDAwMTIyODgsIm9iaiI6eyJpZCI6MX19.24ZOsWrnfkNe%2FbM0r7DaVJMqE2bfn2aAM%2BZSzWeSf31OCTlXXNWD34RBL2X5v3UliYQ4IIsLNBFbaW9texPHug%3D%3D'; const str = 'eyJpYXQiOjE1ODE0NDAwMTIyODgsIm9iaiI6eyJpZCI6MX19.24ZOsWrnfkNe%2FbM0r7DaVJMqE2bfn2aAM%2BZSzWeSf31OCTlXXNWD34RBL2X5v3UliYQ4IIsLNBFbaW9texPHug%3D%3D';

3148
yarn.lock

File diff suppressed because it is too large Load Diff