Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI fix KVv2 in json editor when value is null #27094

Merged
merged 10 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/27094.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fix KVv2 json editor to allow null values.
```
5 changes: 5 additions & 0 deletions ui/lib/core/addon/utils/advanced-secret.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
35 changes: 34 additions & 1 deletion ui/tests/unit/utils/advanced-secret-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
});

Expand Down
Loading