ent_test.py revision efdcf49660505e13607b99ba82eb504cf37b8794
#
# ent.py module tests
#
# Copyright (c) 2015 Red Hat, Inc.
# Author: Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
#
# 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, see <http://www.gnu.org/licenses/>.
#
import re
import os
import io
import shutil
import pytest
import ent
from util import *
def backup_envvar_file(name):
return path
def restore_envvar_file(name):
def passwd_path(request):
name = "NSS_WRAPPER_PASSWD"
return backup_envvar_file(name)
def group_path(request):
name = "NSS_WRAPPER_GROUP"
return backup_envvar_file(name)
"{name}:{passwd}:{uid}:{gid}:{gecos}:{dir}:{shell}\n".format(**u)
for u in USER_LIST
])
"%s:%s:%s:%s\n" % (g["name"], g["passwd"], g["gid"],
for g in GROUP_LIST
])
try:
assert False
except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
try:
assert False
except AssertionError as e:
assert str(e) == "'name' mismatch: 'user1' != 'user2'"
try:
assert False
except AssertionError as e:
assert str(e) == "'getpwuid(): uid not found: 1003'"
try:
assert False
except AssertionError as e:
assert str(e) == "'name' mismatch: 'user1' != 'user2'"
try:
assert False
except AssertionError as e:
try:
assert False
except AssertionError as e:
try:
assert False
except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
try:
assert False
except AssertionError as e:
assert str(e) == \
"user 'user1' mismatch: 'name' mismatch: 'user2' != 'user1'"
try:
assert False
except AssertionError as e:
assert str(e) == "'getpwuid(): uid not found: 1003'"
try:
assert False
except AssertionError as e:
assert str(e) == \
"user 1001 mismatch: 'uid' mismatch: 1002 != 1001"
try:
assert False
except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
try:
assert False
except AssertionError as e:
assert str(e) == \
"user 'user1' mismatch: 'uid' mismatch: 1002 != 1001"
try:
assert False
except AssertionError as e:
assert str(e) == "'getpwuid(): uid not found: 1003'"
try:
assert False
except AssertionError as e:
assert str(e) == \
"user 1001 mismatch: 'name' mismatch: 'user2' != 'user1'"
try:
assert False
except AssertionError as e:
try:
assert False
except AssertionError as e:
try:
except AssertionError as e:
try:
except AssertionError as e:
try:
except AssertionError as e:
try:
except AssertionError as e:
try:
except AssertionError as e:
try:
assert False
except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
try:
assert False
except AssertionError as e:
assert str(e) == "'name' mismatch: 'group1' != 'group2'"
try:
assert False
except AssertionError as e:
assert str(e) == "'getgrgid(): gid not found: 2003'"
try:
assert False
except AssertionError as e:
assert str(e) == "'name' mismatch: 'group1' != 'group2'"
try:
assert False
except AssertionError as e:
try:
assert False
except AssertionError as e:
try:
assert False
except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
try:
assert False
except AssertionError as e:
assert str(e) == "group 'group1' mismatch: " + \
"'name' mismatch: 'group2' != 'group1'"
try:
assert False
except AssertionError as e:
assert str(e) == "'getgrgid(): gid not found: 2003'"
try:
assert False
except AssertionError as e:
assert str(e) == \
"group 2001 mismatch: 'gid' mismatch: 2002 != 2001"
try:
assert False
except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
try:
assert False
except AssertionError as e:
assert str(e) == \
"group 'group1' mismatch: 'gid' mismatch: 2002 != 2001"
try:
assert False
except AssertionError as e:
assert str(e) == "'getgrgid(): gid not found: 2003'"
try:
assert False
except AssertionError as e:
assert str(e) == \
"group 2001 mismatch: 'name' mismatch: 'group2' != 'group1'"
try:
assert False
except AssertionError as e:
try:
assert False
except AssertionError as e: