Skip to content

Commit

Permalink
Remove all references to deleted indirect map from parent map
Browse files Browse the repository at this point in the history
An attempt to do this was already coded but the wrong
argument was used. It was passing in the location name and
not the map name so the map wouldn't be completely removed.

Include a test to verify that the map is gone after removing
it by calling automountlocation-tofiles which will fail if the
map wasn't properly removed.

Fixes: https://pagure.io/freeipa/issue/9397

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
  • Loading branch information
rcritten authored and flo-renaud committed Aug 21, 2023
1 parent 82b129f commit d98d5e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ipaserver/plugins/automount.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def post_callback(self, ldap, dn, *keys, **options):
# delete optional parental connection (direct maps may not have this)
try:
entry_attrs = ldap.find_entry_by_attr(
'automountinformation', keys[0], 'automount',
'automountinformation', keys[1], 'automount',
base_dn=DN(self.obj.container_dn, api.env.basedn)
)
ldap.delete_entry(entry_attrs)
Expand Down
27 changes: 26 additions & 1 deletion ipatests/test_xmlrpc/test_automount_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,32 @@ def test_4_automountmap_del(self):
with pytest.raises(errors.NotFound):
api.Command['automountmap_show'](self.locname, self.mapname)

def test_5_automountlocation_del(self):
def test_5_automountmap_add_indirect(self):
"""
Add back the indirect map
"""
res = api.Command['automountmap_add_indirect'](
self.locname, self.mapname, **self.map_kw)['result']
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)

def test_6_automountmap_del(self):
"""
Remove the indirect map without removing the key first.
"""
res = api.Command['automountmap_del'](
self.locname, self.mapname)['result']
assert res
assert not res['failed']

# Verify that it is gone
with pytest.raises(errors.NotFound):
api.Command['automountmap_show'](self.locname, self.mapname)

# automountlocation-tofiles should succeed if the map was removed
api.Command['automountlocation_tofiles'](self.locname)

def test_7_automountlocation_del(self):
"""
Remove the location.
"""
Expand Down

0 comments on commit d98d5e4

Please sign in to comment.