Commit d7c133c2 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[3056] Skip some more tests when run as the root user

parent 949a2522
......@@ -137,9 +137,24 @@ class TestMemmgr(unittest.TestCase):
self.assertEqual(1, answer[0])
self.assertIsNotNone(re.search('not a directory', answer[1]))
# Bad update: directory exists but is not readable.
os.mkdir(self.__test_mapped_file_dir, 0o500) # drop writable bit
@unittest.skipIf(os.getuid() == 0,
'test cannot be run as root user')
def test_configure_bad_permissions(self):
self.__mgr._setup_ccsession()
# Pretend specified directories exist and writable
os.path.isdir = lambda x: True
os.access = lambda x, y: True
# Initial configuration.
self.assertEqual((0, None),
parse_answer(self.__mgr._config_handler({})))
os.path.isdir = self.__orig_isdir
os.access = self.__orig_os_access
# Bad update: directory exists but is not writable.
os.mkdir(self.__test_mapped_file_dir, 0o500) # drop writable bit
user_cfg = {'mapped_file_dir': self.__test_mapped_file_dir}
answer = parse_answer(self.__mgr._config_handler(user_cfg))
self.assertEqual(1, answer[0])
......
......@@ -399,6 +399,19 @@ Options:
'add', 'user1', 'pass1'
])
@unittest.skipIf(os.getuid() == 0,
'test cannot be run as root user')
def test_bad_file_permissions(self):
"""
Check for graceful handling of bad file argument
"""
# Create the test file
self.run_check(0, None, None,
[ self.TOOL,
'-f', self.OUTPUT_FILE,
'add', 'user1', 'pass1'
])
# Make it non-writable (don't worry about cleanup, the
# file should be deleted after each test anyway
os.chmod(self.OUTPUT_FILE, stat.S_IRUSR)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment