mirror of
				https://github.com/node-ebics/node-ebics-client.git
				synced 2025-11-03 14:41:03 +00:00 
			
		
		
		
	fit(tests): use new Key in keys test
This commit is contained in:
		
							
								
								
									
										28
									
								
								test/keys.js
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								test/keys.js
									
									
									
									
									
								
							@@ -2,16 +2,16 @@
 | 
			
		||||
 | 
			
		||||
const { assert } = require('chai');
 | 
			
		||||
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, '');
 | 
			
		||||
 | 
			
		||||
describe('Keys management', () => {
 | 
			
		||||
	describe('generates brand new', () => {
 | 
			
		||||
		const keySize = 2048;
 | 
			
		||||
		const newKey = Key().generate(keySize);
 | 
			
		||||
 | 
			
		||||
		// newKey.key = Key().generate(keySize);
 | 
			
		||||
		// const newKey = Key().generate(keySize);
 | 
			
		||||
		const newKey = Key.generate();
 | 
			
		||||
 | 
			
		||||
		it('private key', () => {
 | 
			
		||||
			assert.isTrue(newKey.isPrivate());
 | 
			
		||||
@@ -29,14 +29,16 @@ describe('Keys management', () => {
 | 
			
		||||
		describe('that are strings', () => {
 | 
			
		||||
			const m = Buffer.from(mod.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,
 | 
			
		||||
			});
 | 
			
		||||
			}); */
 | 
			
		||||
			const newKey = new Key({ mod: m, exp: e });
 | 
			
		||||
 | 
			
		||||
			it('and is really public', () => {
 | 
			
		||||
				assert.isTrue(newKey.isPublic());
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			it('and has a propper mod in bytes', () => {
 | 
			
		||||
				assert.deepEqual([...newKey.n()], mod.bytes);
 | 
			
		||||
			});
 | 
			
		||||
@@ -49,9 +51,10 @@ describe('Keys management', () => {
 | 
			
		||||
		describe('that are bytes', () => {
 | 
			
		||||
			const m = Buffer.from(mod.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,
 | 
			
		||||
			});
 | 
			
		||||
			}); */
 | 
			
		||||
			const newKey = new Key({ mod: m, exp: e });
 | 
			
		||||
 | 
			
		||||
			it('and is really public', () => {
 | 
			
		||||
				assert.isTrue(newKey.isPublic());
 | 
			
		||||
@@ -68,18 +71,19 @@ describe('Keys management', () => {
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	describe('creates public key from pem string', () => {
 | 
			
		||||
		const { pem, mod, exp } = fixtures.pblc.big;
 | 
			
		||||
		const newKey = Key(pem);
 | 
			
		||||
		const { pem } = fixtures.pblc.big;
 | 
			
		||||
		// const newKey = Key(pem);
 | 
			
		||||
		const newKey = new Key({ pem });
 | 
			
		||||
 | 
			
		||||
		it('and is really public', () => {
 | 
			
		||||
			assert.isTrue(newKey.isPublic());
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		it('and has a propper(the same) pem string', () => {
 | 
			
		||||
			newKey.pempem = {
 | 
			
		||||
			/* newKey.pempem = {
 | 
			
		||||
				modulus: mod.string,
 | 
			
		||||
				exponent: exp.string,
 | 
			
		||||
			};
 | 
			
		||||
			}; */
 | 
			
		||||
			assert.equal(stripWhitespace(newKey.toPem()), stripWhitespace(pem));
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user