diff --git a/lib/data/context.js b/lib/data/context.js index 8b26b76fb..4d6d21bdf 100644 --- a/lib/data/context.js +++ b/lib/data/context.js @@ -23,6 +23,7 @@ module.exports = function (context) { .inject({ current: dataRow.data })); } }); + maskSecretInTitle(scenarios); return new DataScenarioConfig(scenarios); }, only: { @@ -42,6 +43,7 @@ module.exports = function (context) { .inject({ current: dataRow.data })); } }); + maskSecretInTitle(scenarios); return new DataScenarioConfig(scenarios); }, }, @@ -71,12 +73,6 @@ function replaceTitle(title, dataRow) { // it should be printed if (Object.prototype.toString.call(dataRow.data) === (Object()).toString() && dataRow.data.toString() !== (Object()).toString()) { - Object.entries(dataRow.data).forEach(entry => { - const [key, value] = entry; - if (value instanceof Secret) { - dataRow.data[key] = value.getMasked(); - } - }); return `${title} | ${dataRow.data}`; } @@ -119,3 +115,15 @@ function detectDataType(dataTable) { throw new Error('Invalid data type. Data accepts either: DataTable || generator || Array || function'); } + +function maskSecretInTitle(scenarios) { + scenarios.forEach(scenario => { + const res = []; + + scenario.test.title.split(',').forEach(item => { + res.push(item.replace(/{"_secret":"(.*)"}/, '"*****"')); + }); + + scenario.test.title = res.join(','); + }); +}