Imported Upstream version 4.8.10

This commit is contained in:
Mario Fetka
2021-10-03 11:06:28 +02:00
parent 10dfc9587b
commit 03a8170b15
2361 changed files with 1883897 additions and 338759 deletions

View File

@@ -18,10 +18,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Test the `ipalib/plugins/automount.py' module.
Test the `ipaserver/plugins/automount.py' module.
"""
import sys
import textwrap
import tempfile
import shutil
@@ -30,11 +29,15 @@ from ipalib import api
from ipalib import errors
from ipapython.dn import DN
from nose.tools import raises, assert_raises # pylint: disable=E0611
from xmlrpc_test import XMLRPC_test, assert_attr_equal
from ipaplatform.paths import paths
import pytest
import six
from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test, assert_attr_equal
from ipatests.util import assert_deepequal
if six.PY3:
unicode = str
class MockTextui(list):
"""Collects output lines"""
@@ -45,6 +48,10 @@ class MockTextui(list):
class AutomountTest(XMLRPC_test):
"""Provides common functionality for automount tests"""
locname = u'testlocation'
tofiles_output = '' # To be overridden
def check_tofiles(self):
"""Check automountlocation_tofiles output against self.tofiles_output
"""
@@ -80,6 +87,8 @@ class AutomountTest(XMLRPC_test):
break
else:
current_file.write(line + '\n')
assert current_file is not None, ('The input file does not contain any'
'records of files to be opened.')
current_file.close()
self.failsafe_add(api.Object.automountlocation, self.locname)
@@ -97,7 +106,7 @@ class AutomountTest(XMLRPC_test):
skipped=(),
duplicatemaps=(),
duplicatekeys=(),
)), res)
)), res) # pylint: disable=used-before-assignment
self.check_tofiles()
finally:
res = api.Command['automountlocation_del'](self.locname)['result']
@@ -107,11 +116,12 @@ class AutomountTest(XMLRPC_test):
# Success; delete the temporary directory
shutil.rmtree(conf_directory)
@pytest.mark.tier1
class test_automount(AutomountTest):
"""
Test the `automount` plugin.
"""
locname = u'testlocation'
mapname = u'testmap'
keyname = u'testkey'
keyname_rename = u'testkey_rename'
@@ -169,12 +179,13 @@ class test_automount(AutomountTest):
assert res
assert_attr_equal(res, 'automountkey', self.keyname)
@raises(errors.DuplicateEntry)
def test_4_automountkey_add(self):
"""
Test adding a duplicate key using `xmlrpc.automountkey_add` method.
"""
res = api.Command['automountkey_add'](self.locname, self.mapname, **self.key_kw)
with pytest.raises(errors.DuplicateEntry):
api.Command['automountkey_add'](
self.locname, self.mapname, **self.key_kw)
def test_5_automountmap_show(self):
"""
@@ -222,7 +233,7 @@ class test_automount(AutomountTest):
assert_attr_equal(res, 'automountinformation', self.newinfo)
assert_attr_equal(res, 'automountkey', self.keyname_rename)
def test_a_automountmap_mod(self):
def test_a1_automountmap_mod(self):
"""
Test the `xmlrpc.automountmap_mod` method.
"""
@@ -244,7 +255,7 @@ class test_automount(AutomountTest):
dn=DN(('automountmapname', self.mapname),
('cn', self.locname),
('cn', 'automount'), api.env.basedn),
description=(u'description of map',),
description=(u'new description',),
automountmapname=(u'testmap',)),),
orphankeys=[(
dict(
@@ -291,7 +302,7 @@ class test_automount(AutomountTest):
assert not res['failed']
# Verify that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountkey_show'](self.locname, self.mapname, **delkey_kw)
def test_c_automountlocation_del(self):
@@ -303,7 +314,7 @@ class test_automount(AutomountTest):
assert not res['failed']
# Verify that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountlocation_show'](self.locname)
def test_d_automountmap_del(self):
@@ -312,15 +323,15 @@ class test_automount(AutomountTest):
"""
# Verify that the second key we added is gone
key_kw = {'automountkey': self.keyname2, 'automountinformation': self.info, 'raw': True}
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountkey_show'](self.locname, self.mapname, **key_kw)
@pytest.mark.tier1
class test_automount_direct(AutomountTest):
"""
Test the `automount` plugin indirect map functionality.
"""
locname = u'testlocation'
mapname = u'auto.direct2'
keyname = u'/-'
direct_kw = { 'key' : keyname }
@@ -353,12 +364,13 @@ class test_automount_direct(AutomountTest):
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
@raises(errors.DuplicateEntry)
def test_2_automountmap_add_duplicate(self):
"""
Test adding a duplicate direct map.
"""
res = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.direct_kw)['result']
with pytest.raises(errors.DuplicateEntry):
api.Command['automountmap_add_indirect'](
self.locname, self.mapname, **self.direct_kw)
def test_2a_automountmap_tofiles(self):
"""Test the `automountmap_tofiles` command"""
@@ -373,7 +385,7 @@ class test_automount_direct(AutomountTest):
assert not res['failed']
# Verity that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountlocation_show'](self.locname)
def test_z_import_roundtrip(self):
@@ -382,11 +394,11 @@ class test_automount_direct(AutomountTest):
self.check_import_roundtrip()
@pytest.mark.tier1
class test_automount_indirect(AutomountTest):
"""
Test the `automount` plugin indirect map functionality.
"""
locname = u'testlocation'
mapname = u'auto.home'
keyname = u'/home'
parentmap = u'auto.master'
@@ -421,12 +433,14 @@ class test_automount_indirect(AutomountTest):
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
@raises(errors.DuplicateEntry)
def test_1a_automountmap_add_indirect(self):
"""
Test adding a duplicate indirect map.
"""
api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.map_kw)['result']
with pytest.raises(errors.DuplicateEntry):
api.Command['automountmap_add_indirect'](
self.locname, self.mapname, **self.map_kw
)
def test_2_automountmap_show(self):
"""
@@ -449,7 +463,7 @@ class test_automount_indirect(AutomountTest):
assert not res['failed']
# Verify that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountkey_show'](self.locname, self.parentmap, **self.key_kw)
def test_4_automountmap_del(self):
@@ -461,7 +475,7 @@ class test_automount_indirect(AutomountTest):
assert not res['failed']
# Verify that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountmap_show'](self.locname, self.mapname)
def test_5_automountlocation_del(self):
@@ -473,7 +487,7 @@ class test_automount_indirect(AutomountTest):
assert not res['failed']
# Verity that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountlocation_show'](self.locname)
def test_z_import_roundtrip(self):
@@ -481,11 +495,12 @@ class test_automount_indirect(AutomountTest):
"""
self.check_import_roundtrip()
@pytest.mark.tier1
class test_automount_indirect_no_parent(AutomountTest):
"""
Test the `automount` plugin Indirect map function.
"""
locname = u'testlocation'
mapname = u'auto.home'
keyname = u'/home'
mapname2 = u'auto.direct2'
@@ -557,7 +572,7 @@ class test_automount_indirect_no_parent(AutomountTest):
assert not res['failed']
# Verify that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountkey_show'](self.locname, self.parentmap, **delkey_kw)
def test_4_automountmap_del(self):
@@ -569,7 +584,7 @@ class test_automount_indirect_no_parent(AutomountTest):
assert not res['failed']
# Verify that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountmap_show'](self.locname, self.mapname)
def test_5_automountlocation_del(self):
@@ -581,5 +596,5 @@ class test_automount_indirect_no_parent(AutomountTest):
assert not res['failed']
# Verity that it is gone
with assert_raises(errors.NotFound):
with pytest.raises(errors.NotFound):
api.Command['automountlocation_show'](self.locname)