Skip to content

Passwords stored with secret() are written into inputs as asterisks ("****") not as the actual string #3878

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

Closed
KreuzigTobias opened this issue Sep 21, 2023 · 0 comments · Fixed by #3885

Comments

@KreuzigTobias
Copy link

What are you trying to achieve?

Using Data Driven Tests with an array of test data which is reading the credentials from an .env-file (passwords, cleartext). I used the CodeceptJS function secret() to hide them and expected to see the tests use the correct password, and that it is only hidden in outputs.

Expected output is:

The test feature --
  The scenario | {"username":"Username","password": ***}
      'The real password: theLoggedPasswordInCleartext'
      I.fillField('somePasswordLocator', '****')
  ✔ OK in 7ms

  The scenario | {"username":"theSecondUsername","password": ***}
      'The real password: theLoggedPasswordInCleartext'
      I.fillField('somePasswordLocator', '****')
  ✔ OK in 1ms

What do you get instead?

The passwords are not only hidden in the outputs, but the asterisks are also used within the tests. Which makes logging in impossible.

The test feature --
  The scenario | {"username":"Username","password": ***}
      'The real password: ****'
      I.fillField('somePasswordLocator', '****')
  ✖

  The scenario | {"username":"theSecondUsername","password": ***}
      'The real password: ****'
      I.fillField('somePasswordLocator', '****')
  ✖

Testfile

const accounts = new DataTable(['role', 'username', 'password']);
accounts.add([
  'ROLE_A',
  process.env['FIRST_USERNAME'],
  secret(process.env['FIRST_PASSWORD']),
]);
accounts.add([
  'ROLE_B',
  process.env['SECOND_USERNAME'],
  secret(process.env['SECOND_PASSWORD']),
]);

Data(accounts)
  .Scenario(
    'ScenarioTitle',
    ({ I, pageObject, current }) => {
      I.say("Given I'am logged in");
      I.amOnPage('/');
      loginPage.**sendForm**(current.username, current.password);
  )

loginPageObject

  **sendForm**(username, password) {
    I.waitForElement(this.fields.username, 10);
    I.fillField(this.fields.username, username);
    I.fillField(this.fields.password, password);
    I.click(this.submitButton);
  },

Details

  • CodeceptJS version: 3.4.1
  • NodeJS Version: v18.17.1
  • Operating System: MacOS

Might be related to the changes from this issue:
#3429

@KreuzigTobias KreuzigTobias changed the title Passwords stored with secret() are written to output as asterisks ("****") Passwords stored with secret() are written into inputs as asterisks ("****") not as the actual string Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant