URL: https://github.com/freeipa/freeipa/pull/5922
Author: rcritten
 Title: #5922: [Backport][ipa-4-9] Display all orphaned keys in 
automountlocation-tofiles
Action: opened

PR body:
"""
This PR was opened automatically because PR #5920 was pushed to master and 
backport to ipa-4-9 is required.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/5922/head:pr5922
git checkout pr5922
From f9ef8d7be07f5792a7f2efe36fe40f8e73351084 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Thu, 22 Jul 2021 15:53:00 -0400
Subject: [PATCH 1/3] Display all orphaned keys in automountlocation-tofiles

Only the first key was being displayed for any orphaned map.

https://pagure.io/freeipa/issue/7814

Signed-off-by: Rob Crittenden <rcrit...@redhat.com>
---
 ipaclient/plugins/automount.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ipaclient/plugins/automount.py b/ipaclient/plugins/automount.py
index 650c7485408..b4be17e6498 100644
--- a/ipaclient/plugins/automount.py
+++ b/ipaclient/plugins/automount.py
@@ -104,13 +104,15 @@ def output_for_cli(self, textui, result, *keys, **options):
             textui.print_plain('/etc/%s:' % m['automountmapname'])
             for k in orphankeys:
                 if len(k) == 0: continue
-                dn = DN(k[0]['dn'])
-                if dn['automountmapname'] == m['automountmapname'][0]:
-                    textui.print_plain(
-                        '%s\t%s' % (
-                            k[0]['automountkey'][0], k[0]['automountinformation'][0]
+                for key in k:
+                    dn = DN(key['dn'])
+                    if dn['automountmapname'] == m['automountmapname'][0]:
+                        textui.print_plain(
+                            '%s\t%s' % (
+                                key['automountkey'][0],
+                                key['automountinformation'][0]
+                            )
                         )
-                    )
 
 
 @register()

From 72b2f58479d68433b700a089bf01f8e9a086bec8 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Thu, 22 Jul 2021 17:07:26 -0400
Subject: [PATCH 2/3] ipatests: Add test for ipa automountlocation-tofiles

Only the first key of orphaned automount keys was being
displayed.

tofiles was created because making sense of LDAP automount
information is a brain squeezer. The purpose is not to
display in a precise file format but to display it in
a sensible and understandable way.

https://pagure.io/freeipa/issue/7814

Signed-off-by: Rob Crittenden <rcrit...@redhat.com>
---
 ipatests/test_integration/test_commands.py | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/ipatests/test_integration/test_commands.py b/ipatests/test_integration/test_commands.py
index 5d755998edd..d64519eb75d 100644
--- a/ipatests/test_integration/test_commands.py
+++ b/ipatests/test_integration/test_commands.py
@@ -1499,3 +1499,51 @@ def test_client_doesnot_throw_responsenotready_error(self):
         )
         # Run the command again after cache is removed
         self.master.run_command(['ipa', 'user-show', 'ipauser1'])
+
+
+class TestIPAautomount(IntegrationTest):
+    @classmethod
+    def install(cls, mh):
+        tasks.install_master(cls.master, setup_dns=True)
+
+    def test_tofiles_orphan_keys(self):
+        """
+        Validate automountlocation-tofiles output
+
+        automount in LDAP is difficult to keep straight so a client-side
+        map generator was created.
+        """
+        tasks.kinit_admin(self.master)
+
+        self.master.run_command(
+            [
+                'ipa',
+                'automountmap-add', 'default',
+                'auto.test'
+            ]
+        )
+        self.master.run_command(
+            [
+                'ipa',
+                'automountkey-add', 'default',
+                'auto.test',
+                '--key', '/test',
+                '--info', 'nfs.example.com:/exports/test'
+            ]
+        )
+        self.master.run_command(
+            [
+                'ipa',
+                'automountkey-add', 'default',
+                'auto.test',
+                '--key', '/test2',
+                '--info', 'nfs.example.com:/exports/test2'
+            ]
+        )
+        result = self.master.run_command(
+            [
+                'ipa', 'automountlocation-tofiles', 'default'
+            ]
+        ).stdout_text
+        assert '/test' in result
+        assert '/test2' in result

From cc0d84457f09214a83b2bb0d16fed64fa2f61675 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Fri, 23 Jul 2021 11:25:30 -0400
Subject: [PATCH 3/3] Fix automountlocation-tofiles expected output in xmlrpc
 test

The previous output matched the bad behavior of only displaying
one orphaned key.

https://pagure.io/freeipa/issue/7814

Signed-off-by: Rob Crittenden <rcrit...@redhat.com>
---
 ipatests/test_xmlrpc/test_automount_plugin.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ipatests/test_xmlrpc/test_automount_plugin.py b/ipatests/test_xmlrpc/test_automount_plugin.py
index 69167afc1e9..90b8a759f74 100644
--- a/ipatests/test_xmlrpc/test_automount_plugin.py
+++ b/ipatests/test_xmlrpc/test_automount_plugin.py
@@ -143,6 +143,7 @@ class test_automount(AutomountTest):
         ---------------------------
         /etc/testmap:
         testkey2\tro
+        testkey_rename\trw
         """).strip()
 
     def test_0_automountlocation_add(self):
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to