diff --git a/changelog/27094.txt b/changelog/27094.txt new file mode 100644 index 000000000000..9cd743f55f94 --- /dev/null +++ b/changelog/27094.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fix KVv2 json editor to allow null values. +``` \ No newline at end of file diff --git a/ui/lib/core/addon/utils/advanced-secret.js b/ui/lib/core/addon/utils/advanced-secret.js index d17ba71e762e..267ab22c75ef 100644 --- a/ui/lib/core/addon/utils/advanced-secret.js +++ b/ui/lib/core/addon/utils/advanced-secret.js @@ -30,6 +30,11 @@ export function obfuscateData(obj) { for (const key of Object.keys(obj)) { if (Array.isArray(obj[key])) { newObj[key] = obj[key].map(() => '********'); + } else if (obj[key] === null) { + // unfortunately in javascript typeof null returns object + // this is due to a "historical js bug that will never be fixed" + // we handle this situation here + newObj[key] = '********'; } else if (typeof obj[key] === 'object') { newObj[key] = obfuscateData(obj[key]); } else { diff --git a/ui/tests/unit/utils/advanced-secret-test.js b/ui/tests/unit/utils/advanced-secret-test.js index 1a58b38e68e7..d2065dbe732d 100644 --- a/ui/tests/unit/utils/advanced-secret-test.js +++ b/ui/tests/unit/utils/advanced-secret-test.js @@ -108,7 +108,40 @@ module('Unit | Utility | advanced-secret', function () { }, ].forEach((test) => { const result = obfuscateData(test.data); - assert.deepEqual(result, test.obscured, `obfuscates values of ${test.name}`); + assert.deepEqual(result, test.obscured, `obfuscates object values of ${test.name}`); + }); + }); + + test('it obfuscates null values', function (assert) { + assert.expect(2); + [ + { + name: 'null value', + data: { + one: 'fish', + two: 'fish', + three: 'fish', + blue: null, + }, + obscured: { + blue: '********', + one: '********', + three: '********', + two: '********', + }, + }, + { + name: 'null value nested-object', + data: { + one: { two: null }, + }, + obscured: { + one: { two: '********' }, + }, + }, + ].forEach((test) => { + const result = obfuscateData(test.data); + assert.deepEqual(result, test.obscured, `obfuscates null values of ${test.name}`); }); });