summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHervé Beraud <hberaud@redhat.com>2022-08-02 12:27:25 +0200
committerHervé Beraud <herveberaud.pro@gmail.com>2022-09-13 15:50:42 +0000
commit03a2344d8de0c213f6b3453b5d357a53d6b313d4 (patch)
tree4f24d5d97589ac8c58a2b8cfa1114a75e34d994a
parentde1dbeed235d2df7cf1528aef6ad4a70ddf8559f (diff)
downloadoslo-config-stable/wallaby.tar.gz
Disable a config test if ran under the root userstable/wallaby
The `test_conf_file_permission_denied` is designed to test if a config file can't be read due to missing file permissions. However if we run unit tests with the root user we will beneficiat from the root privileges and so this test will fails. This can be reproduced by running `tox` with `sudo`. These changes propose to skip this test if root privileges are detected. Closes-bug: #1983358 Change-Id: Idd124082265032c30f83242b612d002d7093aa61 (cherry picked from commit 7b838f5c31c3219d13661ec612d750e58683cbe6) (cherry picked from commit 966c588a0c5b973a324ebe1390f8a0f064a44540) (cherry picked from commit 3290e603dd855f5575fc30acd213bd50670810b8)
-rw-r--r--oslo_config/tests/test_cfg.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py
index 505cb00..2eb2084 100644
--- a/oslo_config/tests/test_cfg.py
+++ b/oslo_config/tests/test_cfg.py
@@ -21,6 +21,7 @@ import os
import shutil
import sys
import tempfile
+import unittest
from unittest import mock
import fixtures
@@ -3805,6 +3806,8 @@ class SadPathTestCase(BaseTestCase):
self.assertRaises(cfg.ConfigFilesNotFoundError,
self.conf, ['--config-file', path])
+ @unittest.skipIf(os.getuid() == 0,
+ "Not supported with the root privileges")
def test_conf_file_permission_denied(self):
(fd, path) = tempfile.mkstemp()