This issue was found during testing of 2386.
---
dnsrecord_add interactive mode did not work correctly when more
than one DNS record part was entered as command line option. It
asked for remaining options more than once. This patch fixes
this situation and also adds tests to cover this use case
properly.

https://fedorahosted.org/freeipa/ticket/2641

>From 9a22cf81eef0a62b05c0c08209c5cbab0223a912 Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Mon, 16 Apr 2012 11:00:00 +0200
Subject: [PATCH] Fix dnsrecord_add interactive mode

dnsrecord_add interactive mode did not work correctly when more
than one DNS record part was entered as command line option. It
asked for remaining options more than once. This patch fixes
this situation and also adds tests to cover this use case
properly.

https://fedorahosted.org/freeipa/ticket/2641
---
 ipalib/plugins/dns.py          |    2 +-
 tests/test_cmdline/test_cli.py |   49 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index b7069fb7a5e9db699c7dcd7dc581f3c99d1a79ee..3618dd619c2eb284f22e54a629fb72aff87e8b25 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -2046,7 +2046,7 @@ class dnsrecord(LDAPObject):
                 continue
 
             if rrparam.name not in processed:
-                processed.append(rrparam)
+                processed.append(rrparam.name)
                 yield rrparam
 
 api.register(dnsrecord)
diff --git a/tests/test_cmdline/test_cli.py b/tests/test_cmdline/test_cli.py
index 46b33d548f07b930665ae596c69246fb478202a4..095577a3b776341d5571f82ecbab55e7e3527f8e 100644
--- a/tests/test_cmdline/test_cli.py
+++ b/tests/test_cmdline/test_cli.py
@@ -186,3 +186,52 @@ class TestCLIParsing(object):
                     version=API_VERSION)
         finally:
             self.run_command('dnszone_del', idnsname=u'test-example.com')
+
+    def test_dnsrecord_add_ask_for_missing_fields(self):
+        sshfp_parts = (1, 1, u'E3B72BA346B90570EED94BE9334E34AA795CED23')
+
+        with self.fake_stdin('SSHFP\n%d\n%d\n%s' % sshfp_parts):
+            self.check_command('dnsrecord-add test-example.com sshfp',
+                'dnsrecord_add',
+                dnszoneidnsname=u'test-example.com',
+                idnsname=u'sshfp',
+                sshfp_part_fp_type=sshfp_parts[0],
+                sshfp_part_algorithm=sshfp_parts[1],
+                sshfp_part_fingerprint=sshfp_parts[2],
+                structured=False,
+                raw=False,
+                all=False,
+                force=False,
+                version=API_VERSION)
+
+        # NOTE: when a DNS record part is passed via command line, it is not
+        # converted to its base type when transfered via wire
+        with self.fake_stdin('%d\n%s' % (sshfp_parts[1], sshfp_parts[2])):
+            self.check_command('dnsrecord-add test-example.com sshfp ' \
+                    '--sshfp-algorithm=%d' % sshfp_parts[0],
+                'dnsrecord_add',
+                dnszoneidnsname=u'test-example.com',
+                idnsname=u'sshfp',
+                sshfp_part_fp_type=sshfp_parts[0],
+                sshfp_part_algorithm=unicode(sshfp_parts[1]),   # passed via cmdline
+                sshfp_part_fingerprint=sshfp_parts[2],
+                structured=False,
+                raw=False,
+                all=False,
+                force=False,
+                version=API_VERSION)
+
+        with self.fake_stdin(sshfp_parts[2]):
+            self.check_command('dnsrecord-add test-example.com sshfp ' \
+                    '--sshfp-algorithm=%d --sshfp-fp-type=%d' % (sshfp_parts[0], sshfp_parts[1]),
+                'dnsrecord_add',
+                dnszoneidnsname=u'test-example.com',
+                idnsname=u'sshfp',
+                sshfp_part_fp_type=unicode(sshfp_parts[0]),     # passed via cmdline
+                sshfp_part_algorithm=unicode(sshfp_parts[1]),   # passed via cmdline
+                sshfp_part_fingerprint=sshfp_parts[2],
+                structured=False,
+                raw=False,
+                all=False,
+                force=False,
+                version=API_VERSION)
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to