Skip to content

Commit 3cc123f

Browse files
authored
fix: masked value issue in data table (#3885)
1 parent c58ba23 commit 3cc123f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Diff for: lib/data/context.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = function (context) {
2323
.inject({ current: dataRow.data }));
2424
}
2525
});
26+
maskSecretInTitle(scenarios);
2627
return new DataScenarioConfig(scenarios);
2728
},
2829
only: {
@@ -42,6 +43,7 @@ module.exports = function (context) {
4243
.inject({ current: dataRow.data }));
4344
}
4445
});
46+
maskSecretInTitle(scenarios);
4547
return new DataScenarioConfig(scenarios);
4648
},
4749
},
@@ -71,12 +73,6 @@ function replaceTitle(title, dataRow) {
7173
// it should be printed
7274
if (Object.prototype.toString.call(dataRow.data) === (Object()).toString()
7375
&& dataRow.data.toString() !== (Object()).toString()) {
74-
Object.entries(dataRow.data).forEach(entry => {
75-
const [key, value] = entry;
76-
if (value instanceof Secret) {
77-
dataRow.data[key] = value.getMasked();
78-
}
79-
});
8076
return `${title} | ${dataRow.data}`;
8177
}
8278

@@ -119,3 +115,15 @@ function detectDataType(dataTable) {
119115

120116
throw new Error('Invalid data type. Data accepts either: DataTable || generator || Array || function');
121117
}
118+
119+
function maskSecretInTitle(scenarios) {
120+
scenarios.forEach(scenario => {
121+
const res = [];
122+
123+
scenario.test.title.split(',').forEach(item => {
124+
res.push(item.replace(/{"_secret":"(.*)"}/, '"*****"'));
125+
});
126+
127+
scenario.test.title = res.join(',');
128+
});
129+
}

0 commit comments

Comments
 (0)