fix(tests): More reliable generation of RSA keys for tests
This commit is contained in:
Родитель
47f4f176c3
Коммит
981d0b7c0a
|
@ -2,3 +2,5 @@ npm-debug.log
|
|||
node_modules
|
||||
Thumbs.db
|
||||
/coverage.html
|
||||
config/key.json
|
||||
config/oldKey.json
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -54,7 +54,6 @@
|
|||
"load-grunt-tasks": "^3.1.0",
|
||||
"mocha-text-cov": "^0.1.0",
|
||||
"nock": "^1.2.1",
|
||||
"node-rsa": "^0.2.30",
|
||||
"proxyquire": "^1.6.0",
|
||||
"read": "^1.0.5",
|
||||
"sinon": "^1.15.4",
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
|
||||
const NodeRSA = require('node-rsa');
|
||||
const generateRSAKeypair = require('generate-rsa-keypair');
|
||||
const JwTool = require('fxa-jwtool');
|
||||
|
||||
const keyPath = './config/key.json';
|
||||
const oldKeyPath = './config/oldKey.json';
|
||||
|
@ -35,27 +35,16 @@ try {
|
|||
}
|
||||
|
||||
function main(cb) {
|
||||
var key = new NodeRSA({b: 2048});
|
||||
|
||||
var genKey = {
|
||||
kty: 'RSA',
|
||||
kid: '2015.12.16-1',
|
||||
n: key.keyPair.n.toString(),
|
||||
e: key.keyPair.e.toString(),
|
||||
d: key.keyPair.d.toString()
|
||||
};
|
||||
|
||||
var genOldKey = {
|
||||
kty: 'RSA',
|
||||
kid: '2015.12.16-2',
|
||||
n: key.keyPair.n.toString(),
|
||||
e: key.keyPair.e.toString()
|
||||
};
|
||||
|
||||
fs.writeFileSync(keyPath, JSON.stringify(genKey));
|
||||
var privKey = JwTool.JWK.fromPEM(generateRSAKeypair().private, {
|
||||
kid: '2015.12.16-1'
|
||||
});
|
||||
fs.writeFileSync(keyPath, JSON.stringify(privKey.toJSON(), undefined, 2));
|
||||
console.log('Key saved:', keyPath); //eslint-disable-line no-console
|
||||
|
||||
fs.writeFileSync(oldKeyPath, JSON.stringify(genOldKey));
|
||||
var pubKey = JwTool.JWK.fromPEM(generateRSAKeypair().public, {
|
||||
kid: '2015.12.16-2'
|
||||
});
|
||||
fs.writeFileSync(oldKeyPath, JSON.stringify(pubKey.toJSON(), undefined, 2));
|
||||
console.log('OldKey saved:', oldKeyPath); //eslint-disable-line no-console
|
||||
cb();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче