Only test permission failures if we're not root

or, more generally, if we're on a system where permissions are being enforced

Closes: #1979
This commit is contained in:
Peter Eckersley
2015-12-21 19:58:07 -08:00
parent 0c704fa7f2
commit aa6bf73d4a
+10 -1
View File
@@ -66,8 +66,17 @@ class AuthenticatorTest(unittest.TestCase):
def test_prepare_reraises_other_errors(self):
self.auth.full_path = os.path.join(self.path, "null")
permission_canary = os.path.join(self.path, "rnd")
f = open(permission_canary, "w")
f.write("thingimy")
f.close()
os.chmod(self.path, 0o000)
self.assertRaises(errors.PluginError, self.auth.prepare)
try:
open(permission_canary, "r")
print("Warning, running tests as root skips permissions tests...")
except IOError:
# ok, permissions work, test away...
self.assertRaises(errors.PluginError, self.auth.prepare)
os.chmod(self.path, 0o700)
@mock.patch("letsencrypt.plugins.webroot.os.chown")