From 49618db01cd180fd1267092d36754d83a6514182 Mon Sep 17 00:00:00 2001 From: Thomas Dvornik Date: Thu, 11 Feb 2021 10:45:23 -0800 Subject: [PATCH] fix: no throw on unknown config value --- src/config/config.ts | 2 +- test/unit/config/configTest.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/config/config.ts b/src/config/config.ts index c15ef74c15..caa8908f20 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -425,7 +425,7 @@ export class Config extends ConfigFile { */ private async cryptProperties(encrypt: boolean): Promise { const hasEncryptedProperties = this.entries().some(([key]) => { - return !!ensure(Config.propertyConfigMap[key]).encrypted; + return !!Config.propertyConfigMap[key]?.encrypted; }); if (hasEncryptedProperties) { diff --git a/test/unit/config/configTest.ts b/test/unit/config/configTest.ts index 00fcecad8c..3c2f69064a 100644 --- a/test/unit/config/configTest.ts +++ b/test/unit/config/configTest.ts @@ -268,6 +268,15 @@ describe('Config', () => { expect(writeStub.called).to.be.true; }); + + it('calls ConfigFile.read with unknown key and does not throw on crypt', async () => { + stubMethod($$.SANDBOX, ConfigFile.prototype, ConfigFile.prototype.read.name).callsFake(async function () { + this.setContentsFromObject({ unknown: 'unknown config key and value' }); + }); + + const config: Config = await Config.create(Config.getDefaultOptions(true)); + expect(config).to.exist; + }); }); describe('allowed properties', () => {