浏览代码

Add tests for [unix_http_server] chmod= and chown= bad values

Mike Naberezny 10 年之前
父节点
当前提交
4c60a1287d
共有 1 个文件被更改,包括 34 次插入0 次删除
  1. 34 0
      supervisor/tests/test_options.py

+ 34 - 0
supervisor/tests/test_options.py

@@ -941,6 +941,40 @@ class ServerOptionsTests(unittest.TestCase):
         self.assertEqual(options.server_configs[0]['file'], '/tmp/supvtest.sock')
         self.assertEqual(options.server_configs[0]['chmod'], 493)
 
+    def test_options_afunix_chmod_bad(self):
+        instance = self._makeOne()
+        text = lstrip("""\
+        [supervisord]
+
+        [unix_http_server]
+        file=/tmp/file
+        chmod=NaN
+        """)
+        instance.configfile = StringIO(text)
+        try:
+            instance.read_config(StringIO(text))
+            self.fail("nothing raised")
+        except ValueError as exc:
+            self.assertEqual(exc.args[0],
+                "Invalid chmod value NaN")
+
+    def test_options_afunix_chown_bad(self):
+        instance = self._makeOne()
+        text = lstrip("""\
+        [supervisord]
+
+        [unix_http_server]
+        file=/tmp/file
+        chown=thisisnotavaliduser
+        """)
+        instance.configfile = StringIO(text)
+        try:
+            instance.read_config(StringIO(text))
+            self.fail("nothing raised")
+        except ValueError as exc:
+            self.assertEqual(exc.args[0],
+                "Invalid sockchown value thisisnotavaliduser")
+
     def test_options_afunix_no_file(self):
         instance = self._makeOne()
         text = lstrip("""\