From 38a7ef1d393ed6dcb713a4fd5e95030d72ca83eb Mon Sep 17 00:00:00 2001 From: chenlevy24 <65597962+chenlevy24@users.noreply.github.com> Date: Wed, 19 Aug 2020 09:10:30 +0000 Subject: [PATCH] KeyToolSpec now uses MockLog (#291) * KeyToolSpec now uses MockLog * Changed the initialization of the MockLogs into Keytoll's initialization. * Removed redundant import line --- packages/core/src/spec/lib/jdk/KeyToolSpec.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/core/src/spec/lib/jdk/KeyToolSpec.ts b/packages/core/src/spec/lib/jdk/KeyToolSpec.ts index 8225f915..39cbed9c 100644 --- a/packages/core/src/spec/lib/jdk/KeyToolSpec.ts +++ b/packages/core/src/spec/lib/jdk/KeyToolSpec.ts @@ -19,6 +19,7 @@ import {Config} from '../../../lib/Config'; import util = require('../../../lib/util'); import {JdkHelper} from '../../../lib/jdk/JdkHelper'; import * as fs from 'fs'; +import {MockLog} from '../../..'; const SHA1 = '38:03:D6:95:91:7C:9C:EE:4A:A0:58:43:A7:43:A5:D2:76:52:EF:9B'; const SHA256 = 'F5:08:9F:8A:D4:C8:4A:15:6D:0A:B1:3F:61:96:BE:C7:87:8C:DE:05:59:92:B2:A3:2D:05:' + @@ -64,7 +65,7 @@ describe('KeyTool', () => { } as CreateKeyOptions; it('Executes the correct command to create a key', async () => { - const keyTool = new KeyTool(jdkHelper); + const keyTool = new KeyTool(jdkHelper, new MockLog()); spyOn(fs, 'existsSync').and.returnValue(false); spyOn(util, 'execute').and.stub(); await keyTool.createSigningKey(keyOptions); @@ -83,7 +84,7 @@ describe('KeyTool', () => { }); it('Skips creation when a key already exists', async () => { - const keyTool = new KeyTool(jdkHelper); + const keyTool = new KeyTool(jdkHelper, new MockLog()); spyOn(fs, 'existsSync').and.returnValue(true); spyOn(util, 'execute').and.stub(); await keyTool.createSigningKey(keyOptions); @@ -91,7 +92,7 @@ describe('KeyTool', () => { }); it('Deletes and writes a new key when overwrite = true', async () => { - const keyTool = new KeyTool(jdkHelper); + const keyTool = new KeyTool(jdkHelper, new MockLog()); spyOn(fs, 'existsSync').and.returnValue(true); spyOn(fs.promises, 'unlink').and.resolveTo(); spyOn(util, 'execute').and.stub(); @@ -110,7 +111,7 @@ describe('KeyTool', () => { } as KeyOptions; it('Executes the correct command to list keys', async () => { - const keyTool = new KeyTool(jdkHelper); + const keyTool = new KeyTool(jdkHelper, new MockLog()); spyOn(fs, 'existsSync').and.returnValue(true); spyOn(util, 'execute').and.resolveTo({stdout: '', stderr: ''}); await keyTool.list(keyOptions); @@ -126,7 +127,7 @@ describe('KeyTool', () => { }); it('Throws error if keyOptions.path doesn\'t exist', async () => { - const keyTool = new KeyTool(jdkHelper); + const keyTool = new KeyTool(jdkHelper, new MockLog()); spyOn(fs, 'existsSync').and.returnValue(false); expectAsync(keyTool.list(keyOptions)).toBeRejectedWithError(); });