Skip to content

Commit c780f9a

Browse files
authored
mask secret data rows in data-driven titles (#5693)
1 parent eb1bcdc commit c780f9a

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

lib/data/context.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ function replaceTitle(title, dataRow) {
6868
return `${title} | {${JSON.stringify(dataRow.data)}}`
6969
}
7070

71+
if (typeof dataRow.data.getMasked === 'function') {
72+
return `${title} | ${dataRow.data.getMasked()}`
73+
}
74+
7175
// if `dataRow` is object and has own `toString()` method,
7276
// it should be printed
7377
if (Object.prototype.toString.call(dataRow.data) === Object().toString() && dataRow.data.toString() !== Object().toString()) {

test/unit/data/ui_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,11 @@ describe('ui', () => {
122122
expect(dataScenarioConfig.scenarios[0].test.title).to.equal('scenario | {"username":"jon","password":"snow"}')
123123
})
124124
})
125+
126+
describe('secret data rows', () => {
127+
it("should not leak a secret data row's value into the title", () => {
128+
const dataScenarioConfig = context.Data([new Secret('theSecretPassword')]).Scenario('scenario', () => {})
129+
expect(dataScenarioConfig.scenarios[0].test.title).to.equal('scenario | *****')
130+
})
131+
})
125132
})

0 commit comments

Comments
 (0)