@tsmx/secure-config-tool
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -31,3 +31,3 @@ const fs = require('fs'); | ||
processValue: (key, value, level, path, isObjectRoot, isArrayElement, cbSetValue) => { | ||
if (patternMatch(key, patternArray)) { | ||
if (typeof value !== 'object' && patternMatch(key, patternArray)) { | ||
cbSetValue(cryptUtils.encrypt(value, configKey.toString())); | ||
@@ -34,0 +34,0 @@ } |
{ | ||
"name": "@tsmx/secure-config-tool", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Command-line tool for @tsmx/secure-config.", | ||
@@ -5,0 +5,0 @@ "main": "secure-config-tool.js", |
@@ -12,2 +12,3 @@ const { verifyEncryptedJson, verifyUnencryptedJson, verifyEncryptedValue } = require('./test-utils'); | ||
const unencryptedPassword = 'SecretDbPassword'; | ||
const unencryptedDatabase = 'MyDB'; | ||
@@ -73,2 +74,25 @@ const TEST_KEY = 'iC771qNLe+OGVcduw8fqpDIIK7lK0T5p'; | ||
it('tests a successful command line file encryption with a hex key and custom patterns and an ambiguous property name', () => { | ||
process.env['CONFIG_ENCRYPTION_KEY'] = TEST_KEY_HEX; | ||
const oh = require('@tsmx/object-hmac'); | ||
const originalConfig = require('./testfiles/config-ambiguous-prop.json'); | ||
const expectedHmac = oh.calculateHmac(originalConfig, TEST_KEY_HEX); | ||
const createFile = require('../functions/create-file'); | ||
createFile('./test/testfiles/config-ambiguous-prop.json', { patterns: 'host,pass,database'}); | ||
expect(testOutput.length).toBe(1); | ||
let encryptedJson = JSON.parse(testOutput[0]); | ||
expect(encryptedJson).toBeDefined(); | ||
expect(encryptedJson.database).toBeDefined(); | ||
expect(encryptedJson.database.host).toBeDefined(); | ||
verifyEncryptedValue(encryptedJson.database.host, unencryptedHost); | ||
expect(encryptedJson.database.username).toBeDefined(); | ||
expect(encryptedJson.database.username).toBe(unencryptedUsername); | ||
expect(encryptedJson.database.password).toBeDefined(); | ||
verifyEncryptedValue(encryptedJson.database.password, unencryptedPassword); | ||
expect(encryptedJson.database.database).toBeDefined(); | ||
verifyEncryptedValue(encryptedJson.database.database, unencryptedDatabase); | ||
expect(encryptedJson['__hmac']).toBeDefined(); | ||
expect(encryptedJson['__hmac']).toStrictEqual(expectedHmac); | ||
}); | ||
it('tests a successful command line file encryption without HMAC generation', () => { | ||
@@ -75,0 +99,0 @@ process.env['CONFIG_ENCRYPTION_KEY'] = TEST_KEY_HEX; |
Sorry, the diff of this file is not supported yet
55500
30
1001
44