lundi 22 mai 2017

How to write a unit test for file permission to be run by root

I'm working on an application that is supposed to fail gracefully when it is given a file that it does not have read permissions for. I have written a unit test to verify this behavior.

However, when the unit test is run as root, which sometimes happens on new VMs where my team is too busy to set up proper users, the test fail because the files are actually readable and our expected errors never occur.

How do you test for this?

Aucun commentaire:

Enregistrer un commentaire