Is there a best practice for securely storing test users' passwords used in automated test?

Is it better to connect to a DB and query for each user's credentials as needed? Then where should I store the DB connection credentials? Still on my same repo? That won't stop an unwanted person from getting the passwords, once they've gained access to the repo/code.

Is it better to store the creds in a props file, and chmod it to be read-only for specific users running the tests? Can't anyone just chmod it back, and gain access?

Or I could create a password-protected file, and write code to look for the password as an environment variable. It would require anyone running the test to know the password, and set the var in their env.

Is there any better way?


First of all, you should definitely avoid storing user credentials in the code repository.

What we are currently doing for our test automation setup is:

  • reading user credentials and access keys (in our case, for browserstack) from environment variables
  • when running tests on the Jenkins CI, we are using the Credentials plugin to store credentials and set environment variables appropriately

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.