def test_dont_drop_permissions(self, mock_setgid, mock_setuid, mock_setgroups): fw = Framework(config_path) fw.drop_permissions() self.assertFalse(mock_setuid.called) self.assertFalse(mock_setgid.called) self.assertFalse(mock_setgroups.called)
def test_drop_permissions(self, mock_getenv, mock_setgid, mock_setuid, mock_setgroups, mock_getuid): fw = Framework(config_path) nobody_uid = pwd.getpwnam('nobody').pw_uid nogroup_gid = grp.getgrnam('nogroup').gr_gid fw.drop_permissions() mock_setuid.assert_called_with(nobody_uid) mock_setgid.assert_called_with(nogroup_gid) mock_setgroups.assert_called_with([])
def test_cant_drop_permissions(self, mock_getenv, mock_setgid, mock_setuid, mock_setgroups, mock_getuid): fw = Framework(config_path) self.assertFalse(fw.drop_permissions())