From b5a327eb9c0c1ec3f77a36676d6cc9878353ec1b Mon Sep 17 00:00:00 2001 From: Thiago da Silva Date: Thu, 19 Feb 2015 14:59:48 -0500 Subject: adding functions setfsuid and setfsgid Did not add functional tests at the moment. This function requires superuser privilege to execute Change-Id: I35c0a6b3eba60586da64ccfb4dc818d403542f41 Signed-off-by: Thiago da Silva --- test/unit/gluster/test_gfapi.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/unit/gluster/test_gfapi.py') diff --git a/test/unit/gluster/test_gfapi.py b/test/unit/gluster/test_gfapi.py index 550ba79..f772b0d 100644 --- a/test/unit/gluster/test_gfapi.py +++ b/test/unit/gluster/test_gfapi.py @@ -761,6 +761,36 @@ class TestVolume(unittest.TestCase): mock_unlink.assert_called_once_with("dir1/file") mock_rmdir.assert_called_with("dir1") + def test_setfsuid_success(self): + mock_glfs_setfsuid = Mock() + mock_glfs_setfsuid.return_value = 0 + + with patch("glusterfs.gfapi.api.glfs_setfsuid", mock_glfs_setfsuid): + ret = self.vol.setfsuid(1000) + self.assertEquals(ret, 0) + + def test_setfsuid_fail(self): + mock_glfs_setfsuid = Mock() + mock_glfs_setfsuid.return_value = -1 + + with patch("glusterfs.gfapi.api.glfs_setfsuid", mock_glfs_setfsuid): + self.assertRaises(OSError, self.vol.setfsuid, 1001) + + def test_setfsgid_success(self): + mock_glfs_setfsgid = Mock() + mock_glfs_setfsgid.return_value = 0 + + with patch("glusterfs.gfapi.api.glfs_setfsgid", mock_glfs_setfsgid): + ret = self.vol.setfsgid(1000) + self.assertEquals(ret, 0) + + def test_setfsgid_fail(self): + mock_glfs_setfsgid = Mock() + mock_glfs_setfsgid.return_value = -1 + + with patch("glusterfs.gfapi.api.glfs_setfsgid", mock_glfs_setfsgid): + self.assertRaises(OSError, self.vol.setfsgid, 1001) + def test_setxattr_success(self): mock_glfs_setxattr = Mock() mock_glfs_setxattr.return_value = 0 -- cgit