Skip to content

Passwords stored with secret() are written to output when using data-driven tests #3429

@jdoose

Description

@jdoose

What are you trying to achieve?

Using Data Driven Tests with an array of test data which contains credentials (passwords, secrets). I used the CodeceptJS function secret() to store them and expected to not see the passwords in the output (instead, see it masked like when not using data-driven tests).

Expected output is:

The test feature --
  The scenario | {"username":"Username","password": ***}
  ✔ OK in 7ms

  The scenario | {"username":"theSecondUsername","password": ***}
  ✔ OK in 1ms

(or similar)

What do you get instead?

The passwords are printed to the output.

Current output is:

The test feature --
  The scenario | {"username":"Username","password":{"_secret":"theSecretPassword"}}
  ✔ OK in 7ms

  The scenario | {"username":"theSecondUsername","password":{"_secret":"AnotherSecretPassword"}}
  ✔ OK in 1ms

Test source code I used:

const testAccounts = new DataTable(['username', 'password']);
testAccounts.add(['Username', secret('theSecretPassword')]);
testAccounts.add(['theSecondUsername', secret('AnotherSecretPassword')]);

Feature('The test feature');
Data(testAccounts).Scenario('The scenario', ({ current }) => {
  ...
});

Details

  • CodeceptJS version: 3.3.3
  • NodeJS Version: v15.14.0
  • Operating System: MacOS

I took a quick look, but I am not confident:

This may be related to the function replaceTitle in lib/data/context.js

return `${title} | {${JSON.stringify(dataRow.data)}}`;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions