mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2024-11-21 21:52:07 +00:00
fit(tests): use new Key in keys test
This commit is contained in:
parent
59a281c895
commit
836ec0ebf3
28
test/keys.js
28
test/keys.js
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
const { assert } = require('chai');
|
const { assert } = require('chai');
|
||||||
const fixtures = require('./fixtures/keys');
|
const fixtures = require('./fixtures/keys');
|
||||||
const Key = require('../lib/keymanagers/keyRSA');
|
// const Key = require('../lib/keymanagers/keyRSA');
|
||||||
|
const Key = require('../lib/keymanagers/Key');
|
||||||
|
|
||||||
const stripWhitespace = str => str.replace(/\s+/g, '');
|
const stripWhitespace = str => str.replace(/\s+/g, '');
|
||||||
|
|
||||||
describe('Keys management', () => {
|
describe('Keys management', () => {
|
||||||
describe('generates brand new', () => {
|
describe('generates brand new', () => {
|
||||||
const keySize = 2048;
|
const keySize = 2048;
|
||||||
const newKey = Key().generate(keySize);
|
// const newKey = Key().generate(keySize);
|
||||||
|
const newKey = Key.generate();
|
||||||
// newKey.key = Key().generate(keySize);
|
|
||||||
|
|
||||||
it('private key', () => {
|
it('private key', () => {
|
||||||
assert.isTrue(newKey.isPrivate());
|
assert.isTrue(newKey.isPrivate());
|
||||||
@ -29,14 +29,16 @@ describe('Keys management', () => {
|
|||||||
describe('that are strings', () => {
|
describe('that are strings', () => {
|
||||||
const m = Buffer.from(mod.string, 'base64');
|
const m = Buffer.from(mod.string, 'base64');
|
||||||
const e = Buffer.from(exp.string, 'base64');
|
const e = Buffer.from(exp.string, 'base64');
|
||||||
const newKey = Key().importKey({
|
/* const newKey = Key().importKey({
|
||||||
mod: m, exp: e, modulus: mod.string, exponent: exp.string,
|
mod: m, exp: e, modulus: mod.string, exponent: exp.string,
|
||||||
});
|
}); */
|
||||||
|
const newKey = new Key({ mod: m, exp: e });
|
||||||
|
|
||||||
it('and is really public', () => {
|
it('and is really public', () => {
|
||||||
assert.isTrue(newKey.isPublic());
|
assert.isTrue(newKey.isPublic());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('and has a propper mod in bytes', () => {
|
it('and has a propper mod in bytes', () => {
|
||||||
assert.deepEqual([...newKey.n()], mod.bytes);
|
assert.deepEqual([...newKey.n()], mod.bytes);
|
||||||
});
|
});
|
||||||
@ -49,9 +51,10 @@ describe('Keys management', () => {
|
|||||||
describe('that are bytes', () => {
|
describe('that are bytes', () => {
|
||||||
const m = Buffer.from(mod.bytes);
|
const m = Buffer.from(mod.bytes);
|
||||||
const e = Buffer.from(exp.bytes);
|
const e = Buffer.from(exp.bytes);
|
||||||
const newKey = Key().importKey({
|
/* const newKey = Key().importKey({
|
||||||
mod: m, exp: e, modulus: mod.string, exponent: exp.string,
|
mod: m, exp: e, modulus: mod.string, exponent: exp.string,
|
||||||
});
|
}); */
|
||||||
|
const newKey = new Key({ mod: m, exp: e });
|
||||||
|
|
||||||
it('and is really public', () => {
|
it('and is really public', () => {
|
||||||
assert.isTrue(newKey.isPublic());
|
assert.isTrue(newKey.isPublic());
|
||||||
@ -68,18 +71,19 @@ describe('Keys management', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('creates public key from pem string', () => {
|
describe('creates public key from pem string', () => {
|
||||||
const { pem, mod, exp } = fixtures.pblc.big;
|
const { pem } = fixtures.pblc.big;
|
||||||
const newKey = Key(pem);
|
// const newKey = Key(pem);
|
||||||
|
const newKey = new Key({ pem });
|
||||||
|
|
||||||
it('and is really public', () => {
|
it('and is really public', () => {
|
||||||
assert.isTrue(newKey.isPublic());
|
assert.isTrue(newKey.isPublic());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('and has a propper(the same) pem string', () => {
|
it('and has a propper(the same) pem string', () => {
|
||||||
newKey.pempem = {
|
/* newKey.pempem = {
|
||||||
modulus: mod.string,
|
modulus: mod.string,
|
||||||
exponent: exp.string,
|
exponent: exp.string,
|
||||||
};
|
}; */
|
||||||
assert.equal(stripWhitespace(newKey.toPem()), stripWhitespace(pem));
|
assert.equal(stripWhitespace(newKey.toPem()), stripWhitespace(pem));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user