freeipa/ipatests/test_xmlrpc/test_automount_plugin.py

602 lines
21 KiB
Python
Raw Normal View History

2009-06-24 08:12:27 -05:00
# Authors:
# Rob Crittenden <rcritten@redhat.com>
# Pavel Zuna <pzuna@redhat.com>
#
# Copyright (C) 2008 Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
2009-06-24 08:12:27 -05:00
#
# 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/>.
2009-06-24 08:12:27 -05:00
"""
Test the `ipaserver/plugins/automount.py' module.
2009-06-24 08:12:27 -05:00
"""
import textwrap
import tempfile
import shutil
2009-06-24 08:12:27 -05:00
from ipalib import api
from ipalib import errors
Use DN objects instead of strings * Convert every string specifying a DN into a DN object * Every place a dn was manipulated in some fashion it was replaced by the use of DN operators * Add new DNParam parameter type for parameters which are DN's * DN objects are used 100% of the time throughout the entire data pipeline whenever something is logically a dn. * Many classes now enforce DN usage for their attributes which are dn's. This is implmented via ipautil.dn_attribute_property(). The only permitted types for a class attribute specified to be a DN are either None or a DN object. * Require that every place a dn is used it must be a DN object. This translates into lot of:: assert isinstance(dn, DN) sprinkled through out the code. Maintaining these asserts is valuable to preserve DN type enforcement. The asserts can be disabled in production. The goal of 100% DN usage 100% of the time has been realized, these asserts are meant to preserve that. The asserts also proved valuable in detecting functions which did not obey their function signatures, such as the baseldap pre and post callbacks. * Moved ipalib.dn to ipapython.dn because DN class is shared with all components, not just the server which uses ipalib. * All API's now accept DN's natively, no need to convert to str (or unicode). * Removed ipalib.encoder and encode/decode decorators. Type conversion is now explicitly performed in each IPASimpleLDAPObject method which emulates a ldap.SimpleLDAPObject method. * Entity & Entry classes now utilize DN's * Removed __getattr__ in Entity & Entity clases. There were two problems with it. It presented synthetic Python object attributes based on the current LDAP data it contained. There is no way to validate synthetic attributes using code checkers, you can't search the code to find LDAP attribute accesses (because synthetic attriutes look like Python attributes instead of LDAP data) and error handling is circumscribed. Secondly __getattr__ was hiding Python internal methods which broke class semantics. * Replace use of methods inherited from ldap.SimpleLDAPObject via IPAdmin class with IPAdmin methods. Directly using inherited methods was causing us to bypass IPA logic. Mostly this meant replacing the use of search_s() with getEntry() or getList(). Similarly direct access of the LDAP data in classes using IPAdmin were replaced with calls to getValue() or getValues(). * Objects returned by ldap2.find_entries() are now compatible with either the python-ldap access methodology or the Entity/Entry access methodology. * All ldap operations now funnel through the common IPASimpleLDAPObject giving us a single location where we interface to python-ldap and perform conversions. * The above 4 modifications means we've greatly reduced the proliferation of multiple inconsistent ways to perform LDAP operations. We are well on the way to having a single API in IPA for doing LDAP (a long range goal). * All certificate subject bases are now DN's * DN objects were enhanced thusly: - find, rfind, index, rindex, replace and insert methods were added - AVA, RDN and DN classes were refactored in immutable and mutable variants, the mutable variants are EditableAVA, EditableRDN and EditableDN. By default we use the immutable variants preserving important semantics. To edit a DN cast it to an EditableDN and cast it back to DN when done editing. These issues are fully described in other documentation. - first_key_match was removed - DN equalty comparison permits comparison to a basestring * Fixed ldapupdate to work with DN's. This work included: - Enhance test_updates.py to do more checking after applying update. Add test for update_from_dict(). Convert code to use unittest classes. - Consolidated duplicate code. - Moved code which should have been in the class into the class. - Fix the handling of the 'deleteentry' update action. It's no longer necessary to supply fake attributes to make it work. Detect case where subsequent update applies a change to entry previously marked for deletetion. General clean-up and simplification of the 'deleteentry' logic. - Rewrote a couple of functions to be clearer and more Pythonic. - Added documentation on the data structure being used. - Simplfy the use of update_from_dict() * Removed all usage of get_schema() which was being called prior to accessing the .schema attribute of an object. If a class is using internal lazy loading as an optimization it's not right to require users of the interface to be aware of internal optimization's. schema is now a property and when the schema property is accessed it calls a private internal method to perform the lazy loading. * Added SchemaCache class to cache the schema's from individual servers. This was done because of the observation we talk to different LDAP servers, each of which may have it's own schema. Previously we globally cached the schema from the first server we connected to and returned that schema in all contexts. The cache includes controls to invalidate it thus forcing a schema refresh. * Schema caching is now senstive to the run time context. During install and upgrade the schema can change leading to errors due to out-of-date cached schema. The schema cache is refreshed in these contexts. * We are aware of the LDAP syntax of all LDAP attributes. Every attribute returned from an LDAP operation is passed through a central table look-up based on it's LDAP syntax. The table key is the LDAP syntax it's value is a Python callable that returns a Python object matching the LDAP syntax. There are a handful of LDAP attributes whose syntax is historically incorrect (e.g. DistguishedNames that are defined as DirectoryStrings). The table driven conversion mechanism is augmented with a table of hard coded exceptions. Currently only the following conversions occur via the table: - dn's are converted to DN objects - binary objects are converted to Python str objects (IPA convention). - everything else is converted to unicode using UTF-8 decoding (IPA convention). However, now that the table driven conversion mechanism is in place it would be trivial to do things such as converting attributes which have LDAP integer syntax into a Python integer, etc. * Expected values in the unit tests which are a DN no longer need to use lambda expressions to promote the returned value to a DN for equality comparison. The return value is automatically promoted to a DN. The lambda expressions have been removed making the code much simpler and easier to read. * Add class level logging to a number of classes which did not support logging, less need for use of root_logger. * Remove ipaserver/conn.py, it was unused. * Consolidated duplicate code wherever it was found. * Fixed many places that used string concatenation to form a new string rather than string formatting operators. This is necessary because string formatting converts it's arguments to a string prior to building the result string. You can't concatenate a string and a non-string. * Simplify logic in rename_managed plugin. Use DN operators to edit dn's. * The live version of ipa-ldap-updater did not generate a log file. The offline version did, now both do. https://fedorahosted.org/freeipa/ticket/1670 https://fedorahosted.org/freeipa/ticket/1671 https://fedorahosted.org/freeipa/ticket/1672 https://fedorahosted.org/freeipa/ticket/1673 https://fedorahosted.org/freeipa/ticket/1674 https://fedorahosted.org/freeipa/ticket/1392 https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
from ipapython.dn import DN
import pytest
import six
2009-06-24 08:12:27 -05:00
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"""
# Extend the mock object if other textui methods are called
def print_plain(self, line):
self.append(unicode(line))
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
"""
res = api.Command['automountlocation_tofiles'](self.locname)
mock_ui = MockTextui()
command = api.Command['automountlocation_tofiles']
command.output_for_cli(mock_ui, res, self.locname, version=u'2.88')
expected_output = self.tofiles_output
assert_deepequal(expected_output, u'\n'.join(mock_ui))
def check_import_roundtrip(self):
"""Check automountlocation_tofiles/automountlocation_import roundtrip
Loads self.tofiles_output (which should correspond to
automountlocation_tofiles output), then checks the resulting map
against tofiles_output again.
Do not use this if the test creates maps that aren't connected to
auto.master -- these can't be imported successfully.
"""
conf_directory = tempfile.mkdtemp()
# Parse the tofiles_output into individual files, replace /etc/ by
# our temporary directory name
current_file = None
for line in self.tofiles_output.splitlines():
line = line.replace('/etc/', '%s/' % conf_directory)
if line.startswith(conf_directory) and line.endswith(':'):
current_file = open(line.rstrip(':'), 'w')
elif '--------' in line:
current_file.close()
elif line.startswith('maps not connected to '):
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)
try:
# Feed the files to automountlocation_import & check
master_file = u'%s/auto.master' % conf_directory
automountlocation_import = api.Command['automountlocation_import']
res = automountlocation_import(self.locname, master_file,
version=u'2.88')
assert_deepequal(dict(
result=dict(
keys=lambda k: k,
maps=lambda m: m,
skipped=(),
duplicatemaps=(),
duplicatekeys=(),
)), res) # pylint: disable=used-before-assignment
self.check_tofiles()
finally:
res = api.Command['automountlocation_del'](self.locname)['result']
assert res
assert not res['failed']
# Success; delete the temporary directory
shutil.rmtree(conf_directory)
@pytest.mark.tier1
class test_automount(AutomountTest):
2009-06-24 08:12:27 -05:00
"""
Test the `automount` plugin.
"""
mapname = u'testmap'
keyname = u'testkey'
keyname_rename = u'testkey_rename'
2009-06-24 08:12:27 -05:00
keyname2 = u'testkey2'
description = u'description of map'
info = u'ro'
newinfo = u'rw'
2010-12-07 16:18:04 -06:00
map_kw = {'automountmapname': mapname, 'description': description, 'raw': True}
key_kw = {'automountkey': keyname, 'automountinformation': info, 'raw': True}
key_kw2 = {'automountkey': keyname2, 'automountinformation': info, 'raw': True}
tofiles_output = textwrap.dedent(u"""
/etc/auto.master:
/-\t/etc/auto.direct
---------------------------
/etc/auto.direct:
maps not connected to /etc/auto.master:
---------------------------
/etc/testmap:
testkey2\tro
testkey_rename\trw
""").strip()
def test_0_automountlocation_add(self):
"""
Test adding a location `xmlrpc.automountlocation_add` method.
"""
ret = self.failsafe_add(
api.Object.automountlocation, self.locname
)
entry = ret['result']
assert_attr_equal(entry, 'cn', self.locname)
2009-06-24 08:12:27 -05:00
def test_1_automountmap_add(self):
"""
Test adding a map `xmlrpc.automountmap_add` method.
"""
2010-12-07 16:18:04 -06:00
res = api.Command['automountmap_add'](self.locname, **self.map_kw)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
def test_2_automountkey_add(self):
"""
Test adding a key using `xmlrpc.automountkey_add` method.
"""
2010-12-07 16:18:04 -06:00
res = api.Command['automountkey_add'](self.locname, self.mapname, **self.key_kw2)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountkey', self.keyname2)
def test_3_automountkey_add(self):
"""
Test adding a key using `xmlrpc.automountkey_add` method.
"""
2010-12-07 16:18:04 -06:00
res = api.Command['automountkey_add'](self.locname, self.mapname, **self.key_kw)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountkey', self.keyname)
def test_4_automountkey_add(self):
"""
Test adding a duplicate key using `xmlrpc.automountkey_add` method.
"""
with pytest.raises(errors.DuplicateEntry):
api.Command['automountkey_add'](
self.locname, self.mapname, **self.key_kw)
2009-06-24 08:12:27 -05:00
def test_5_automountmap_show(self):
"""
Test the `xmlrpc.automountmap_show` method.
"""
res = api.Command['automountmap_show'](self.locname, self.mapname, raw=True)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
def test_6_automountmap_find(self):
"""
Test the `xmlrpc.automountmap_find` method.
"""
res = api.Command['automountmap_find'](self.locname, self.mapname, raw=True)['result']
assert_attr_equal(res[0], 'automountmapname', self.mapname)
2009-06-24 08:12:27 -05:00
def test_7_automountkey_show(self):
"""
Test the `xmlrpc.automountkey_show` method.
"""
showkey_kw={'automountkey': self.keyname, 'automountinformation' : self.info, 'raw': True}
2010-12-07 16:18:04 -06:00
res = api.Command['automountkey_show'](self.locname, self.mapname, **showkey_kw)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountkey', self.keyname)
assert_attr_equal(res, 'automountinformation', self.info)
def test_8_automountkey_find(self):
"""
Test the `xmlrpc.automountkey_find` method.
"""
res = api.Command['automountkey_find'](self.locname, self.mapname, raw=True)['result']
2009-06-24 08:12:27 -05:00
assert res
assert len(res) == 2
assert_attr_equal(res[0], 'automountkey', self.keyname)
assert_attr_equal(res[0], 'automountinformation', self.info)
2009-06-24 08:12:27 -05:00
def test_9_automountkey_mod(self):
"""
Test the `xmlrpc.automountkey_mod` method.
"""
self.key_kw['newautomountinformation'] = self.newinfo
self.key_kw['rename'] = self.keyname_rename
2010-12-07 16:18:04 -06:00
res = api.Command['automountkey_mod'](self.locname, self.mapname, **self.key_kw)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountinformation', self.newinfo)
assert_attr_equal(res, 'automountkey', self.keyname_rename)
2009-06-24 08:12:27 -05:00
def test_a1_automountmap_mod(self):
2009-06-24 08:12:27 -05:00
"""
Test the `xmlrpc.automountmap_mod` method.
"""
2010-12-07 16:18:04 -06:00
mod_kw = {'description': u'new description'}
res = api.Command['automountmap_mod'](self.locname, self.mapname, **mod_kw)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'description', 'new description')
def test_a2_automountmap_tofiles(self):
"""
Test the `automountlocation_tofiles` command.
"""
res = api.Command['automountlocation_tofiles'](self.locname,
version=u'2.88')
assert_deepequal(dict(
result=dict(
keys={'auto.direct': ()},
orphanmaps=(dict(
Use DN objects instead of strings * Convert every string specifying a DN into a DN object * Every place a dn was manipulated in some fashion it was replaced by the use of DN operators * Add new DNParam parameter type for parameters which are DN's * DN objects are used 100% of the time throughout the entire data pipeline whenever something is logically a dn. * Many classes now enforce DN usage for their attributes which are dn's. This is implmented via ipautil.dn_attribute_property(). The only permitted types for a class attribute specified to be a DN are either None or a DN object. * Require that every place a dn is used it must be a DN object. This translates into lot of:: assert isinstance(dn, DN) sprinkled through out the code. Maintaining these asserts is valuable to preserve DN type enforcement. The asserts can be disabled in production. The goal of 100% DN usage 100% of the time has been realized, these asserts are meant to preserve that. The asserts also proved valuable in detecting functions which did not obey their function signatures, such as the baseldap pre and post callbacks. * Moved ipalib.dn to ipapython.dn because DN class is shared with all components, not just the server which uses ipalib. * All API's now accept DN's natively, no need to convert to str (or unicode). * Removed ipalib.encoder and encode/decode decorators. Type conversion is now explicitly performed in each IPASimpleLDAPObject method which emulates a ldap.SimpleLDAPObject method. * Entity & Entry classes now utilize DN's * Removed __getattr__ in Entity & Entity clases. There were two problems with it. It presented synthetic Python object attributes based on the current LDAP data it contained. There is no way to validate synthetic attributes using code checkers, you can't search the code to find LDAP attribute accesses (because synthetic attriutes look like Python attributes instead of LDAP data) and error handling is circumscribed. Secondly __getattr__ was hiding Python internal methods which broke class semantics. * Replace use of methods inherited from ldap.SimpleLDAPObject via IPAdmin class with IPAdmin methods. Directly using inherited methods was causing us to bypass IPA logic. Mostly this meant replacing the use of search_s() with getEntry() or getList(). Similarly direct access of the LDAP data in classes using IPAdmin were replaced with calls to getValue() or getValues(). * Objects returned by ldap2.find_entries() are now compatible with either the python-ldap access methodology or the Entity/Entry access methodology. * All ldap operations now funnel through the common IPASimpleLDAPObject giving us a single location where we interface to python-ldap and perform conversions. * The above 4 modifications means we've greatly reduced the proliferation of multiple inconsistent ways to perform LDAP operations. We are well on the way to having a single API in IPA for doing LDAP (a long range goal). * All certificate subject bases are now DN's * DN objects were enhanced thusly: - find, rfind, index, rindex, replace and insert methods were added - AVA, RDN and DN classes were refactored in immutable and mutable variants, the mutable variants are EditableAVA, EditableRDN and EditableDN. By default we use the immutable variants preserving important semantics. To edit a DN cast it to an EditableDN and cast it back to DN when done editing. These issues are fully described in other documentation. - first_key_match was removed - DN equalty comparison permits comparison to a basestring * Fixed ldapupdate to work with DN's. This work included: - Enhance test_updates.py to do more checking after applying update. Add test for update_from_dict(). Convert code to use unittest classes. - Consolidated duplicate code. - Moved code which should have been in the class into the class. - Fix the handling of the 'deleteentry' update action. It's no longer necessary to supply fake attributes to make it work. Detect case where subsequent update applies a change to entry previously marked for deletetion. General clean-up and simplification of the 'deleteentry' logic. - Rewrote a couple of functions to be clearer and more Pythonic. - Added documentation on the data structure being used. - Simplfy the use of update_from_dict() * Removed all usage of get_schema() which was being called prior to accessing the .schema attribute of an object. If a class is using internal lazy loading as an optimization it's not right to require users of the interface to be aware of internal optimization's. schema is now a property and when the schema property is accessed it calls a private internal method to perform the lazy loading. * Added SchemaCache class to cache the schema's from individual servers. This was done because of the observation we talk to different LDAP servers, each of which may have it's own schema. Previously we globally cached the schema from the first server we connected to and returned that schema in all contexts. The cache includes controls to invalidate it thus forcing a schema refresh. * Schema caching is now senstive to the run time context. During install and upgrade the schema can change leading to errors due to out-of-date cached schema. The schema cache is refreshed in these contexts. * We are aware of the LDAP syntax of all LDAP attributes. Every attribute returned from an LDAP operation is passed through a central table look-up based on it's LDAP syntax. The table key is the LDAP syntax it's value is a Python callable that returns a Python object matching the LDAP syntax. There are a handful of LDAP attributes whose syntax is historically incorrect (e.g. DistguishedNames that are defined as DirectoryStrings). The table driven conversion mechanism is augmented with a table of hard coded exceptions. Currently only the following conversions occur via the table: - dn's are converted to DN objects - binary objects are converted to Python str objects (IPA convention). - everything else is converted to unicode using UTF-8 decoding (IPA convention). However, now that the table driven conversion mechanism is in place it would be trivial to do things such as converting attributes which have LDAP integer syntax into a Python integer, etc. * Expected values in the unit tests which are a DN no longer need to use lambda expressions to promote the returned value to a DN for equality comparison. The return value is automatically promoted to a DN. The lambda expressions have been removed making the code much simpler and easier to read. * Add class level logging to a number of classes which did not support logging, less need for use of root_logger. * Remove ipaserver/conn.py, it was unused. * Consolidated duplicate code wherever it was found. * Fixed many places that used string concatenation to form a new string rather than string formatting operators. This is necessary because string formatting converts it's arguments to a string prior to building the result string. You can't concatenate a string and a non-string. * Simplify logic in rename_managed plugin. Use DN operators to edit dn's. * The live version of ipa-ldap-updater did not generate a log file. The offline version did, now both do. https://fedorahosted.org/freeipa/ticket/1670 https://fedorahosted.org/freeipa/ticket/1671 https://fedorahosted.org/freeipa/ticket/1672 https://fedorahosted.org/freeipa/ticket/1673 https://fedorahosted.org/freeipa/ticket/1674 https://fedorahosted.org/freeipa/ticket/1392 https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
dn=DN(('automountmapname', self.mapname),
('cn', self.locname),
('cn', 'automount'), api.env.basedn),
description=(u'new description',),
automountmapname=(u'testmap',)),),
orphankeys=[(
dict(
Use DN objects instead of strings * Convert every string specifying a DN into a DN object * Every place a dn was manipulated in some fashion it was replaced by the use of DN operators * Add new DNParam parameter type for parameters which are DN's * DN objects are used 100% of the time throughout the entire data pipeline whenever something is logically a dn. * Many classes now enforce DN usage for their attributes which are dn's. This is implmented via ipautil.dn_attribute_property(). The only permitted types for a class attribute specified to be a DN are either None or a DN object. * Require that every place a dn is used it must be a DN object. This translates into lot of:: assert isinstance(dn, DN) sprinkled through out the code. Maintaining these asserts is valuable to preserve DN type enforcement. The asserts can be disabled in production. The goal of 100% DN usage 100% of the time has been realized, these asserts are meant to preserve that. The asserts also proved valuable in detecting functions which did not obey their function signatures, such as the baseldap pre and post callbacks. * Moved ipalib.dn to ipapython.dn because DN class is shared with all components, not just the server which uses ipalib. * All API's now accept DN's natively, no need to convert to str (or unicode). * Removed ipalib.encoder and encode/decode decorators. Type conversion is now explicitly performed in each IPASimpleLDAPObject method which emulates a ldap.SimpleLDAPObject method. * Entity & Entry classes now utilize DN's * Removed __getattr__ in Entity & Entity clases. There were two problems with it. It presented synthetic Python object attributes based on the current LDAP data it contained. There is no way to validate synthetic attributes using code checkers, you can't search the code to find LDAP attribute accesses (because synthetic attriutes look like Python attributes instead of LDAP data) and error handling is circumscribed. Secondly __getattr__ was hiding Python internal methods which broke class semantics. * Replace use of methods inherited from ldap.SimpleLDAPObject via IPAdmin class with IPAdmin methods. Directly using inherited methods was causing us to bypass IPA logic. Mostly this meant replacing the use of search_s() with getEntry() or getList(). Similarly direct access of the LDAP data in classes using IPAdmin were replaced with calls to getValue() or getValues(). * Objects returned by ldap2.find_entries() are now compatible with either the python-ldap access methodology or the Entity/Entry access methodology. * All ldap operations now funnel through the common IPASimpleLDAPObject giving us a single location where we interface to python-ldap and perform conversions. * The above 4 modifications means we've greatly reduced the proliferation of multiple inconsistent ways to perform LDAP operations. We are well on the way to having a single API in IPA for doing LDAP (a long range goal). * All certificate subject bases are now DN's * DN objects were enhanced thusly: - find, rfind, index, rindex, replace and insert methods were added - AVA, RDN and DN classes were refactored in immutable and mutable variants, the mutable variants are EditableAVA, EditableRDN and EditableDN. By default we use the immutable variants preserving important semantics. To edit a DN cast it to an EditableDN and cast it back to DN when done editing. These issues are fully described in other documentation. - first_key_match was removed - DN equalty comparison permits comparison to a basestring * Fixed ldapupdate to work with DN's. This work included: - Enhance test_updates.py to do more checking after applying update. Add test for update_from_dict(). Convert code to use unittest classes. - Consolidated duplicate code. - Moved code which should have been in the class into the class. - Fix the handling of the 'deleteentry' update action. It's no longer necessary to supply fake attributes to make it work. Detect case where subsequent update applies a change to entry previously marked for deletetion. General clean-up and simplification of the 'deleteentry' logic. - Rewrote a couple of functions to be clearer and more Pythonic. - Added documentation on the data structure being used. - Simplfy the use of update_from_dict() * Removed all usage of get_schema() which was being called prior to accessing the .schema attribute of an object. If a class is using internal lazy loading as an optimization it's not right to require users of the interface to be aware of internal optimization's. schema is now a property and when the schema property is accessed it calls a private internal method to perform the lazy loading. * Added SchemaCache class to cache the schema's from individual servers. This was done because of the observation we talk to different LDAP servers, each of which may have it's own schema. Previously we globally cached the schema from the first server we connected to and returned that schema in all contexts. The cache includes controls to invalidate it thus forcing a schema refresh. * Schema caching is now senstive to the run time context. During install and upgrade the schema can change leading to errors due to out-of-date cached schema. The schema cache is refreshed in these contexts. * We are aware of the LDAP syntax of all LDAP attributes. Every attribute returned from an LDAP operation is passed through a central table look-up based on it's LDAP syntax. The table key is the LDAP syntax it's value is a Python callable that returns a Python object matching the LDAP syntax. There are a handful of LDAP attributes whose syntax is historically incorrect (e.g. DistguishedNames that are defined as DirectoryStrings). The table driven conversion mechanism is augmented with a table of hard coded exceptions. Currently only the following conversions occur via the table: - dn's are converted to DN objects - binary objects are converted to Python str objects (IPA convention). - everything else is converted to unicode using UTF-8 decoding (IPA convention). However, now that the table driven conversion mechanism is in place it would be trivial to do things such as converting attributes which have LDAP integer syntax into a Python integer, etc. * Expected values in the unit tests which are a DN no longer need to use lambda expressions to promote the returned value to a DN for equality comparison. The return value is automatically promoted to a DN. The lambda expressions have been removed making the code much simpler and easier to read. * Add class level logging to a number of classes which did not support logging, less need for use of root_logger. * Remove ipaserver/conn.py, it was unused. * Consolidated duplicate code wherever it was found. * Fixed many places that used string concatenation to form a new string rather than string formatting operators. This is necessary because string formatting converts it's arguments to a string prior to building the result string. You can't concatenate a string and a non-string. * Simplify logic in rename_managed plugin. Use DN operators to edit dn's. * The live version of ipa-ldap-updater did not generate a log file. The offline version did, now both do. https://fedorahosted.org/freeipa/ticket/1670 https://fedorahosted.org/freeipa/ticket/1671 https://fedorahosted.org/freeipa/ticket/1672 https://fedorahosted.org/freeipa/ticket/1673 https://fedorahosted.org/freeipa/ticket/1674 https://fedorahosted.org/freeipa/ticket/1392 https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
dn=DN(('description', self.keyname2),
('automountmapname', 'testmap'),
('cn', self.locname),
('cn', 'automount'), api.env.basedn),
automountkey=(self.keyname2,),
description=(self.keyname2,),
automountinformation=(u'ro',),
),
dict(
Use DN objects instead of strings * Convert every string specifying a DN into a DN object * Every place a dn was manipulated in some fashion it was replaced by the use of DN operators * Add new DNParam parameter type for parameters which are DN's * DN objects are used 100% of the time throughout the entire data pipeline whenever something is logically a dn. * Many classes now enforce DN usage for their attributes which are dn's. This is implmented via ipautil.dn_attribute_property(). The only permitted types for a class attribute specified to be a DN are either None or a DN object. * Require that every place a dn is used it must be a DN object. This translates into lot of:: assert isinstance(dn, DN) sprinkled through out the code. Maintaining these asserts is valuable to preserve DN type enforcement. The asserts can be disabled in production. The goal of 100% DN usage 100% of the time has been realized, these asserts are meant to preserve that. The asserts also proved valuable in detecting functions which did not obey their function signatures, such as the baseldap pre and post callbacks. * Moved ipalib.dn to ipapython.dn because DN class is shared with all components, not just the server which uses ipalib. * All API's now accept DN's natively, no need to convert to str (or unicode). * Removed ipalib.encoder and encode/decode decorators. Type conversion is now explicitly performed in each IPASimpleLDAPObject method which emulates a ldap.SimpleLDAPObject method. * Entity & Entry classes now utilize DN's * Removed __getattr__ in Entity & Entity clases. There were two problems with it. It presented synthetic Python object attributes based on the current LDAP data it contained. There is no way to validate synthetic attributes using code checkers, you can't search the code to find LDAP attribute accesses (because synthetic attriutes look like Python attributes instead of LDAP data) and error handling is circumscribed. Secondly __getattr__ was hiding Python internal methods which broke class semantics. * Replace use of methods inherited from ldap.SimpleLDAPObject via IPAdmin class with IPAdmin methods. Directly using inherited methods was causing us to bypass IPA logic. Mostly this meant replacing the use of search_s() with getEntry() or getList(). Similarly direct access of the LDAP data in classes using IPAdmin were replaced with calls to getValue() or getValues(). * Objects returned by ldap2.find_entries() are now compatible with either the python-ldap access methodology or the Entity/Entry access methodology. * All ldap operations now funnel through the common IPASimpleLDAPObject giving us a single location where we interface to python-ldap and perform conversions. * The above 4 modifications means we've greatly reduced the proliferation of multiple inconsistent ways to perform LDAP operations. We are well on the way to having a single API in IPA for doing LDAP (a long range goal). * All certificate subject bases are now DN's * DN objects were enhanced thusly: - find, rfind, index, rindex, replace and insert methods were added - AVA, RDN and DN classes were refactored in immutable and mutable variants, the mutable variants are EditableAVA, EditableRDN and EditableDN. By default we use the immutable variants preserving important semantics. To edit a DN cast it to an EditableDN and cast it back to DN when done editing. These issues are fully described in other documentation. - first_key_match was removed - DN equalty comparison permits comparison to a basestring * Fixed ldapupdate to work with DN's. This work included: - Enhance test_updates.py to do more checking after applying update. Add test for update_from_dict(). Convert code to use unittest classes. - Consolidated duplicate code. - Moved code which should have been in the class into the class. - Fix the handling of the 'deleteentry' update action. It's no longer necessary to supply fake attributes to make it work. Detect case where subsequent update applies a change to entry previously marked for deletetion. General clean-up and simplification of the 'deleteentry' logic. - Rewrote a couple of functions to be clearer and more Pythonic. - Added documentation on the data structure being used. - Simplfy the use of update_from_dict() * Removed all usage of get_schema() which was being called prior to accessing the .schema attribute of an object. If a class is using internal lazy loading as an optimization it's not right to require users of the interface to be aware of internal optimization's. schema is now a property and when the schema property is accessed it calls a private internal method to perform the lazy loading. * Added SchemaCache class to cache the schema's from individual servers. This was done because of the observation we talk to different LDAP servers, each of which may have it's own schema. Previously we globally cached the schema from the first server we connected to and returned that schema in all contexts. The cache includes controls to invalidate it thus forcing a schema refresh. * Schema caching is now senstive to the run time context. During install and upgrade the schema can change leading to errors due to out-of-date cached schema. The schema cache is refreshed in these contexts. * We are aware of the LDAP syntax of all LDAP attributes. Every attribute returned from an LDAP operation is passed through a central table look-up based on it's LDAP syntax. The table key is the LDAP syntax it's value is a Python callable that returns a Python object matching the LDAP syntax. There are a handful of LDAP attributes whose syntax is historically incorrect (e.g. DistguishedNames that are defined as DirectoryStrings). The table driven conversion mechanism is augmented with a table of hard coded exceptions. Currently only the following conversions occur via the table: - dn's are converted to DN objects - binary objects are converted to Python str objects (IPA convention). - everything else is converted to unicode using UTF-8 decoding (IPA convention). However, now that the table driven conversion mechanism is in place it would be trivial to do things such as converting attributes which have LDAP integer syntax into a Python integer, etc. * Expected values in the unit tests which are a DN no longer need to use lambda expressions to promote the returned value to a DN for equality comparison. The return value is automatically promoted to a DN. The lambda expressions have been removed making the code much simpler and easier to read. * Add class level logging to a number of classes which did not support logging, less need for use of root_logger. * Remove ipaserver/conn.py, it was unused. * Consolidated duplicate code wherever it was found. * Fixed many places that used string concatenation to form a new string rather than string formatting operators. This is necessary because string formatting converts it's arguments to a string prior to building the result string. You can't concatenate a string and a non-string. * Simplify logic in rename_managed plugin. Use DN operators to edit dn's. * The live version of ipa-ldap-updater did not generate a log file. The offline version did, now both do. https://fedorahosted.org/freeipa/ticket/1670 https://fedorahosted.org/freeipa/ticket/1671 https://fedorahosted.org/freeipa/ticket/1672 https://fedorahosted.org/freeipa/ticket/1673 https://fedorahosted.org/freeipa/ticket/1674 https://fedorahosted.org/freeipa/ticket/1392 https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
dn=DN(('description', self.keyname_rename),
('automountmapname', 'testmap'),
('cn', self.locname),
('cn', 'automount'), api.env.basedn),
automountkey=(self.keyname_rename,),
description=(self.keyname_rename,),
automountinformation=(u'rw',),
))],
maps=(
dict(
Use DN objects instead of strings * Convert every string specifying a DN into a DN object * Every place a dn was manipulated in some fashion it was replaced by the use of DN operators * Add new DNParam parameter type for parameters which are DN's * DN objects are used 100% of the time throughout the entire data pipeline whenever something is logically a dn. * Many classes now enforce DN usage for their attributes which are dn's. This is implmented via ipautil.dn_attribute_property(). The only permitted types for a class attribute specified to be a DN are either None or a DN object. * Require that every place a dn is used it must be a DN object. This translates into lot of:: assert isinstance(dn, DN) sprinkled through out the code. Maintaining these asserts is valuable to preserve DN type enforcement. The asserts can be disabled in production. The goal of 100% DN usage 100% of the time has been realized, these asserts are meant to preserve that. The asserts also proved valuable in detecting functions which did not obey their function signatures, such as the baseldap pre and post callbacks. * Moved ipalib.dn to ipapython.dn because DN class is shared with all components, not just the server which uses ipalib. * All API's now accept DN's natively, no need to convert to str (or unicode). * Removed ipalib.encoder and encode/decode decorators. Type conversion is now explicitly performed in each IPASimpleLDAPObject method which emulates a ldap.SimpleLDAPObject method. * Entity & Entry classes now utilize DN's * Removed __getattr__ in Entity & Entity clases. There were two problems with it. It presented synthetic Python object attributes based on the current LDAP data it contained. There is no way to validate synthetic attributes using code checkers, you can't search the code to find LDAP attribute accesses (because synthetic attriutes look like Python attributes instead of LDAP data) and error handling is circumscribed. Secondly __getattr__ was hiding Python internal methods which broke class semantics. * Replace use of methods inherited from ldap.SimpleLDAPObject via IPAdmin class with IPAdmin methods. Directly using inherited methods was causing us to bypass IPA logic. Mostly this meant replacing the use of search_s() with getEntry() or getList(). Similarly direct access of the LDAP data in classes using IPAdmin were replaced with calls to getValue() or getValues(). * Objects returned by ldap2.find_entries() are now compatible with either the python-ldap access methodology or the Entity/Entry access methodology. * All ldap operations now funnel through the common IPASimpleLDAPObject giving us a single location where we interface to python-ldap and perform conversions. * The above 4 modifications means we've greatly reduced the proliferation of multiple inconsistent ways to perform LDAP operations. We are well on the way to having a single API in IPA for doing LDAP (a long range goal). * All certificate subject bases are now DN's * DN objects were enhanced thusly: - find, rfind, index, rindex, replace and insert methods were added - AVA, RDN and DN classes were refactored in immutable and mutable variants, the mutable variants are EditableAVA, EditableRDN and EditableDN. By default we use the immutable variants preserving important semantics. To edit a DN cast it to an EditableDN and cast it back to DN when done editing. These issues are fully described in other documentation. - first_key_match was removed - DN equalty comparison permits comparison to a basestring * Fixed ldapupdate to work with DN's. This work included: - Enhance test_updates.py to do more checking after applying update. Add test for update_from_dict(). Convert code to use unittest classes. - Consolidated duplicate code. - Moved code which should have been in the class into the class. - Fix the handling of the 'deleteentry' update action. It's no longer necessary to supply fake attributes to make it work. Detect case where subsequent update applies a change to entry previously marked for deletetion. General clean-up and simplification of the 'deleteentry' logic. - Rewrote a couple of functions to be clearer and more Pythonic. - Added documentation on the data structure being used. - Simplfy the use of update_from_dict() * Removed all usage of get_schema() which was being called prior to accessing the .schema attribute of an object. If a class is using internal lazy loading as an optimization it's not right to require users of the interface to be aware of internal optimization's. schema is now a property and when the schema property is accessed it calls a private internal method to perform the lazy loading. * Added SchemaCache class to cache the schema's from individual servers. This was done because of the observation we talk to different LDAP servers, each of which may have it's own schema. Previously we globally cached the schema from the first server we connected to and returned that schema in all contexts. The cache includes controls to invalidate it thus forcing a schema refresh. * Schema caching is now senstive to the run time context. During install and upgrade the schema can change leading to errors due to out-of-date cached schema. The schema cache is refreshed in these contexts. * We are aware of the LDAP syntax of all LDAP attributes. Every attribute returned from an LDAP operation is passed through a central table look-up based on it's LDAP syntax. The table key is the LDAP syntax it's value is a Python callable that returns a Python object matching the LDAP syntax. There are a handful of LDAP attributes whose syntax is historically incorrect (e.g. DistguishedNames that are defined as DirectoryStrings). The table driven conversion mechanism is augmented with a table of hard coded exceptions. Currently only the following conversions occur via the table: - dn's are converted to DN objects - binary objects are converted to Python str objects (IPA convention). - everything else is converted to unicode using UTF-8 decoding (IPA convention). However, now that the table driven conversion mechanism is in place it would be trivial to do things such as converting attributes which have LDAP integer syntax into a Python integer, etc. * Expected values in the unit tests which are a DN no longer need to use lambda expressions to promote the returned value to a DN for equality comparison. The return value is automatically promoted to a DN. The lambda expressions have been removed making the code much simpler and easier to read. * Add class level logging to a number of classes which did not support logging, less need for use of root_logger. * Remove ipaserver/conn.py, it was unused. * Consolidated duplicate code wherever it was found. * Fixed many places that used string concatenation to form a new string rather than string formatting operators. This is necessary because string formatting converts it's arguments to a string prior to building the result string. You can't concatenate a string and a non-string. * Simplify logic in rename_managed plugin. Use DN operators to edit dn's. * The live version of ipa-ldap-updater did not generate a log file. The offline version did, now both do. https://fedorahosted.org/freeipa/ticket/1670 https://fedorahosted.org/freeipa/ticket/1671 https://fedorahosted.org/freeipa/ticket/1672 https://fedorahosted.org/freeipa/ticket/1673 https://fedorahosted.org/freeipa/ticket/1674 https://fedorahosted.org/freeipa/ticket/1392 https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
dn=DN(('description', '/- auto.direct'),
('automountmapname', 'auto.master'),
('cn', self.locname),
('cn', 'automount'), api.env.basedn),
automountkey=(u'/-',),
description=(u'/- auto.direct',),
automountinformation=(u'auto.direct',)
),
))), res)
# Also check the CLI output
self.check_tofiles()
2009-06-24 08:12:27 -05:00
def test_b_automountkey_del(self):
"""
Test the `xmlrpc.automountkey_del` method.
"""
delkey_kw={'automountkey': self.keyname_rename, 'automountinformation' : self.newinfo}
2010-12-07 16:18:04 -06:00
res = api.Command['automountkey_del'](self.locname, self.mapname, **delkey_kw)['result']
assert res
assert not res['failed']
2009-06-24 08:12:27 -05:00
# Verify that it is gone
with pytest.raises(errors.NotFound):
2010-12-07 16:18:04 -06:00
api.Command['automountkey_show'](self.locname, self.mapname, **delkey_kw)
2009-06-24 08:12:27 -05:00
def test_c_automountlocation_del(self):
2009-06-24 08:12:27 -05:00
"""
Test the `xmlrpc.automountlocation_del` method.
2009-06-24 08:12:27 -05:00
"""
res = api.Command['automountlocation_del'](self.locname)['result']
assert res
assert not res['failed']
2009-06-24 08:12:27 -05:00
# Verify that it is gone
with pytest.raises(errors.NotFound):
api.Command['automountlocation_show'](self.locname)
2009-06-24 08:12:27 -05:00
def test_d_automountmap_del(self):
"""
Test that the `xmlrpc.automountlocation_del` method removes all maps and keys
2009-06-24 08:12:27 -05:00
"""
# Verify that the second key we added is gone
key_kw = {'automountkey': self.keyname2, 'automountinformation': self.info, 'raw': True}
with pytest.raises(errors.NotFound):
2010-12-07 16:18:04 -06:00
api.Command['automountkey_show'](self.locname, self.mapname, **key_kw)
2009-06-24 08:12:27 -05:00
@pytest.mark.tier1
class test_automount_direct(AutomountTest):
"""
Test the `automount` plugin indirect map functionality.
"""
mapname = u'auto.direct2'
keyname = u'/-'
direct_kw = { 'key' : keyname }
tofiles_output = textwrap.dedent(u"""
/etc/auto.master:
/-\t/etc/auto.direct
/-\t/etc/auto.direct2
---------------------------
/etc/auto.direct:
---------------------------
/etc/auto.direct2:
maps not connected to /etc/auto.master:
""").strip()
def test_0_automountlocation_add(self):
"""
Test adding a location.
"""
res = api.Command['automountlocation_add'](self.locname, raw=True)['result']
assert res
assert_attr_equal(res, 'cn', self.locname)
def test_1_automountmap_add_direct(self):
"""
Test adding a second direct map with a different info
"""
res = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.direct_kw)['result']
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
def test_2_automountmap_add_duplicate(self):
"""
Test adding a duplicate direct map.
"""
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"""
self.check_tofiles()
def test_3_automountlocation_del(self):
"""
Remove the location.
"""
res = api.Command['automountlocation_del'](self.locname)['result']
assert res
assert not res['failed']
# Verity that it is gone
with pytest.raises(errors.NotFound):
api.Command['automountlocation_show'](self.locname)
2009-06-24 08:12:27 -05:00
def test_z_import_roundtrip(self):
"""Check automountlocation_tofiles/automountlocation_import roundtrip
"""
self.check_import_roundtrip()
@pytest.mark.tier1
class test_automount_indirect(AutomountTest):
2009-06-24 08:12:27 -05:00
"""
Test the `automount` plugin indirect map functionality.
"""
mapname = u'auto.home'
keyname = u'/home'
parentmap = u'auto.master'
map_kw = {'key': keyname, 'parentmap': parentmap, 'raw': True}
key_kw = {'automountkey': keyname, 'automountinformation': mapname}
tofiles_output = textwrap.dedent(u"""
/etc/auto.master:
/-\t/etc/auto.direct
/home\t/etc/auto.home
---------------------------
/etc/auto.direct:
---------------------------
/etc/auto.home:
maps not connected to /etc/auto.master:
""").strip()
def test_0_automountlocation_add(self):
"""
Test adding a location.
"""
res = api.Command['automountlocation_add'](self.locname, raw=True)['result']
assert res
assert_attr_equal(res, 'cn', self.locname)
2009-06-24 08:12:27 -05:00
def test_1_automountmap_add_indirect(self):
"""
Test adding an indirect map.
"""
res = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.map_kw)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
2009-06-24 08:12:27 -05:00
def test_1a_automountmap_add_indirect(self):
"""
Test adding a duplicate indirect map.
"""
with pytest.raises(errors.DuplicateEntry):
api.Command['automountmap_add_indirect'](
self.locname, self.mapname, **self.map_kw
)
2009-06-24 08:12:27 -05:00
def test_2_automountmap_show(self):
"""
Test the `xmlrpc.automountmap_show` method.
"""
res = api.Command['automountmap_show'](self.locname, self.mapname, raw=True)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
2009-06-24 08:12:27 -05:00
def test_2a_automountmap_tofiles(self):
"""Test the `automountmap_tofiles` command"""
self.check_tofiles()
2009-06-24 08:12:27 -05:00
def test_3_automountkey_del(self):
"""
Remove the indirect key /home.
"""
res = api.Command['automountkey_del'](self.locname, self.parentmap, **self.key_kw)['result']
assert res
assert not res['failed']
2009-06-24 08:12:27 -05:00
# Verify that it is gone
with pytest.raises(errors.NotFound):
api.Command['automountkey_show'](self.locname, self.parentmap, **self.key_kw)
2009-06-24 08:12:27 -05:00
def test_4_automountmap_del(self):
"""
Remove the indirect map for auto.home.
"""
res = api.Command['automountmap_del'](self.locname, self.mapname)['result']
assert res
assert not res['failed']
2009-06-24 08:12:27 -05:00
# Verify that it is gone
with pytest.raises(errors.NotFound):
api.Command['automountmap_show'](self.locname, self.mapname)
def test_5_automountlocation_del(self):
"""
Remove the location.
"""
res = api.Command['automountlocation_del'](self.locname)['result']
assert res
assert not res['failed']
# Verity that it is gone
with pytest.raises(errors.NotFound):
api.Command['automountlocation_show'](self.locname)
2009-06-24 08:12:27 -05:00
def test_z_import_roundtrip(self):
"""Check automountlocation_tofiles/automountlocation_import roundtrip
"""
self.check_import_roundtrip()
2009-06-24 08:12:27 -05:00
@pytest.mark.tier1
class test_automount_indirect_no_parent(AutomountTest):
2009-06-24 08:12:27 -05:00
"""
Test the `automount` plugin Indirect map function.
"""
mapname = u'auto.home'
keyname = u'/home'
mapname2 = u'auto.direct2'
keyname2 = u'direct2'
2009-06-24 08:12:27 -05:00
parentmap = u'auto.master'
map_kw = {'key': keyname, 'raw': True}
map_kw2 = {'key': keyname2, 'raw': True}
tofiles_output = textwrap.dedent(u"""
/etc/auto.master:
/-\t/etc/auto.direct
/home\t/etc/auto.home
---------------------------
/etc/auto.direct:
---------------------------
/etc/auto.home:
direct2\t-fstype=autofs ldap:auto.direct2
maps not connected to /etc/auto.master:
---------------------------
/etc/auto.direct2:
""").strip()
def test_0_automountlocation_add(self):
"""
Test adding a location.
"""
res = api.Command['automountlocation_add'](self.locname, raw=True)['result']
assert res
assert_attr_equal(res, 'cn', self.locname)
2009-06-24 08:12:27 -05:00
def test_1_automountmap_add_indirect(self):
"""
Test adding an indirect map with default parent.
"""
res = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.map_kw)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
2009-06-24 08:12:27 -05:00
def test_2_automountkey_show(self):
"""
Test the `xmlrpc.automountkey_show` method with default parent.
"""
showkey_kw = {'automountkey': self.keyname, 'automountinformation': self.mapname, 'raw': True}
2010-12-07 16:18:04 -06:00
res = api.Command['automountkey_show'](self.locname, self.parentmap, **showkey_kw)['result']
2009-06-24 08:12:27 -05:00
assert res
assert_attr_equal(res, 'automountkey', self.keyname)
def test_2a_automountmap_add_indirect(self):
"""
Test adding an indirect map with default parent.
"""
res = api.Command['automountmap_add_indirect'](self.locname,
u'auto.direct2', parentmap=self.mapname, **self.map_kw2)['result']
assert res
assert_attr_equal(res, 'automountmapname', self.mapname2)
def test_2b_automountmap_tofiles(self):
"""Test the `automountmap_tofiles` command"""
self.check_tofiles()
2009-06-24 08:12:27 -05:00
def test_3_automountkey_del(self):
"""
Remove the indirect key /home.
"""
delkey_kw={'automountkey': self.keyname, 'automountinformation': self.mapname}
2010-12-07 16:18:04 -06:00
res = api.Command['automountkey_del'](self.locname, self.parentmap, **delkey_kw)['result']
assert res
assert not res['failed']
2009-06-24 08:12:27 -05:00
# Verify that it is gone
with pytest.raises(errors.NotFound):
2010-12-07 16:18:04 -06:00
api.Command['automountkey_show'](self.locname, self.parentmap, **delkey_kw)
2009-06-24 08:12:27 -05:00
def test_4_automountmap_del(self):
"""
Remove the indirect map for auto.home.
"""
res = api.Command['automountmap_del'](self.locname, self.mapname)['result']
assert res
assert not res['failed']
2009-06-24 08:12:27 -05:00
# Verify that it is gone
with pytest.raises(errors.NotFound):
api.Command['automountmap_show'](self.locname, self.mapname)
def test_5_automountlocation_del(self):
"""
Remove the location.
"""
res = api.Command['automountlocation_del'](self.locname)['result']
assert res
assert not res['failed']
# Verity that it is gone
with pytest.raises(errors.NotFound):
api.Command['automountlocation_show'](self.locname)