浏览代码

Test for uid and gid set

Ask Solem 13 年之前
父节点
当前提交
4925f8d57f
共有 1 个文件被更改,包括 21 次插入0 次删除
  1. 21 0
      celery/tests/test_utils/test_platforms.py

+ 21 - 0
celery/tests/test_utils/test_platforms.py

@@ -0,0 +1,21 @@
+from mock import patch
+
+from celery import platforms
+from celery.tests.utils import unittest
+
+
+class test_drop_privileges(unittest.TestCase):
+
+    @patch("os.setuid")
+    @patch("os.setgid")
+    @patch("celery.platforms.parse_uid")
+    @patch("celery.platforms.parse_gid")
+    def test_uid_gid_is_set(self, parse_gid, parse_uid, setgid, setuid):
+        parse_gid.return_value = 20
+        parse_uid.return_value = 20
+
+        platforms.set_effective_user("foo", "foo")
+
+        setuid.assert_called_with(20)
+        setgid.assert_called_with(20)
+