mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-03 20:40:45 -05:00
UI fix KVv2 in json editor when value is null (#27094)
* fix issue for null value * add changelog * add test coverage * Update advanced-secret.js * flatten method by moving else if above instead of nested * changes * Delete changelog/278094.txt * add correct changelog * clean up * fix
This commit is contained in:
parent
fea81ab8bc
commit
0554cdaa71
3 changed files with 42 additions and 1 deletions
3
changelog/27094.txt
Normal file
3
changelog/27094.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
ui: Fix KVv2 json editor to allow null values.
|
||||
```
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue