Search code examples
pythonunit-testingsecurityprivacy

How to use sensitive data in unit tests?


I've entered login information during tests but I no longer want this data to be present in the source code which will be uploaded to GitHub soon. How can I make use of this data in the tests without storing the login info in the source code? Is it safe to store it in an environment variable? A database? A local file? What's the best way to go about encrypting and decrypting this info?


Solution

  • Keep in mind that the sensitive data will still be in the Git repository. If you want to delete some sensitive data from the Git history, have a look at this question: Remove sensitive files and their commits from Git history

    For login informations i would try to mock the login process. Otherwise others who want to run the tests somehow need to get theses sensitive informations.