mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 21:43:09 +00:00
skip permission-related tests if the environment is not suitable
posix superuser can do anything on the filesystem
This commit is contained in:
parent
9585925627
commit
2091b7ee86
@ -222,7 +222,8 @@ class GridManagerCommandLine(TestCase):
|
||||
result.output,
|
||||
)
|
||||
|
||||
@skipIf(not platform.isLinux(), "I only know how permissions work on linux")
|
||||
@skipIf(platform.isWindows(), "We don't know how to set permissions on Windows.")
|
||||
@skipIf(os.getuid() == 0, "cannot test as superuser which all of the permissions")
|
||||
def test_sign_bad_perms(self):
|
||||
"""
|
||||
Error reported if we can't create certificate file
|
||||
|
@ -1,17 +1,7 @@
|
||||
"""
|
||||
Ported to Python 3.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from unittest import skipIf
|
||||
from functools import (
|
||||
partial,
|
||||
)
|
||||
@ -42,6 +32,7 @@ from twisted.internet import defer
|
||||
from twisted.python.filepath import (
|
||||
FilePath,
|
||||
)
|
||||
from twisted.python.runtime import platform
|
||||
from testtools.matchers import (
|
||||
Equals,
|
||||
AfterPreprocessing,
|
||||
@ -156,12 +147,12 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
|
||||
yield client.create_client(basedir)
|
||||
self.assertIn("[client]helper.furl", str(ctx.exception))
|
||||
|
||||
def test_unreadable_config(self):
|
||||
if sys.platform == "win32":
|
||||
# if somebody knows a clever way to do this (cause
|
||||
# EnvironmentError when reading a file that really exists), on
|
||||
# windows, please fix this
|
||||
raise unittest.SkipTest("can't make unreadable files on windows")
|
||||
@skipIf(platform.isWindows(), "We don't know how to set permissions on Windows.")
|
||||
@skipIf(os.getuid() == 0, "cannot test as superuser which all of the permissions")
|
||||
def test_unreadable_config(self):
|
||||
basedir = "test_client.Basic.test_unreadable_config"
|
||||
os.mkdir(basedir)
|
||||
fn = os.path.join(basedir, "tahoe.cfg")
|
||||
|
@ -1,14 +1,4 @@
|
||||
"""
|
||||
Ported to Python 3.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import os
|
||||
@ -31,6 +21,7 @@ from unittest import skipIf
|
||||
from twisted.python.filepath import (
|
||||
FilePath,
|
||||
)
|
||||
from twisted.python.runtime import platform
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import defer
|
||||
|
||||
@ -333,10 +324,8 @@ class TestCase(testutil.SignalMixin, unittest.TestCase):
|
||||
default = [("hello", "world")]
|
||||
self.assertEqual(config.items("nosuch", default), default)
|
||||
|
||||
@skipIf(
|
||||
"win32" in sys.platform.lower() or "cygwin" in sys.platform.lower(),
|
||||
"We don't know how to set permissions on Windows.",
|
||||
)
|
||||
@skipIf(platform.isWindows(), "We don't know how to set permissions on Windows.")
|
||||
@skipIf(os.getuid() == 0, "cannot test as superuser which all of the permissions")
|
||||
def test_private_config_unreadable(self):
|
||||
"""
|
||||
Asking for inaccessible private config is an error
|
||||
@ -351,10 +340,8 @@ class TestCase(testutil.SignalMixin, unittest.TestCase):
|
||||
with self.assertRaises(Exception):
|
||||
config.get_or_create_private_config("foo")
|
||||
|
||||
@skipIf(
|
||||
"win32" in sys.platform.lower() or "cygwin" in sys.platform.lower(),
|
||||
"We don't know how to set permissions on Windows.",
|
||||
)
|
||||
@skipIf(platform.isWindows(), "We don't know how to set permissions on Windows.")
|
||||
@skipIf(os.getuid() == 0, "cannot test as superuser which all of the permissions")
|
||||
def test_private_config_unreadable_preexisting(self):
|
||||
"""
|
||||
error if reading private config data fails
|
||||
@ -411,6 +398,7 @@ class TestCase(testutil.SignalMixin, unittest.TestCase):
|
||||
self.assertEqual(len(counter), 1) # don't call unless necessary
|
||||
self.assertEqual(value, "newer")
|
||||
|
||||
@skipIf(os.getuid() == 0, "cannot test as superuser which all of the permissions")
|
||||
def test_write_config_unwritable_file(self):
|
||||
"""
|
||||
Existing behavior merely logs any errors upon writing
|
||||
|
Loading…
Reference in New Issue
Block a user