#coding=utf-8
# Authors:
# Jakub Hrozek <jhrozek@redhat.com>
#
# Copyright (C) 2009 Red Hat
# see file 'COPYING' for use and warranty information
#
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 2 only
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
import tempfile
import shutil
import unittest
import subprocess
import errno
# module under test
import pysss
try:
except subprocess.CalledProcessError:
return {}
kw = {}
del kw['asq']
return kw
if kw != {}:
try:
except subprocess.CalledProcessError:
return []
members = [ value.strip() for key, value in [ l.split(':') for l in output.split('\n') if ":" in l ] if key == "memberof" ]
return members
for group in group_list:
else:
"Test that the local backed binding can be instantiated"
"Test adding a local user"
# check home directory was created with default name
"Test adding a local user with modified parameters"
gecos="foo bar",
gecos="foo bar",
homeDirectory="/home/foobar",
loginShell="/bin/zsh")
# check home directory was created with nondefault name
"Test adding a local user without creating his home dir"
# check home directory was not created
"Test adding a local user and init his homedir from a custom location"
try:
finally:
"Test adding a local user with group membership"
try:
["gr1","gr2"])
finally:
"Test adding a local user with a custom UID"
uid=1024)
uidNumber=1024)
"Test that local.useradd() requires the username parameter"
"Test adding a local with a duplicite name"
try:
except IOError as e:
else:
finally:
"Test adding a local with a duplicite user ID"
try:
except IOError as e:
else:
finally:
try:
except IOError as e:
else:
fail("Was expecting exception")
"Test modifying user attributes"
gecos="foo bar",
gecos="foo bar",
homeDirectory="/home/foobar",
loginShell="/bin/zsh")
"Test modifying UID"
uid=1024)
uidNumber=1024)
"Test adding to and removing from groups"
try:
["gr1","gr2"])
rmgroups=["gr2"])
["gr1"])
rmgroups=["gr1"])
[])
finally:
"Test locking and unlocking user"
disabled="true")
disabled="false")
"Test adding a local group"
"Test adding a local group with a custom GID"
gid=1024)
gidNumber=1024)
"Test that local.groupadd() requires the groupname parameter"
"Test adding a local with a duplicite name"
try:
except IOError as e:
else:
finally:
"Test adding a local with a duplicite group ID"
try:
except IOError as e:
else:
finally:
try:
except IOError as e:
else:
fail("Was expecting exception")
"Test modifying UID"
gid=1024)
gidNumber=1024)
"Test adding to groups"
try:
["gr1","gr2"])
rmgroups=["gr2"])
["gr1"])
rmgroups=["gr1"])
[])
finally:
# -------------- run the test suite -------------- #
if __name__ == "__main__":