From 322458b5b2f80e179ef43b904c2665254c0a3763 Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Thu, 21 Mar 2013 14:54:46 +0100 Subject: [PATCH] Fix structured DNS record output Recent LDAP refactoring replaced entry_attrs regular dict with normalized keys (i.e. lowercase) with LDAPEntry instance which keys may not be normalized. This broke CND command output when --structured and --all options were used. Force lowercase normalization of the LDAPEntry keys in DNS plugin structured format postprocessing. Also add a missing test for DNS record structured output. https://fedorahosted.org/freeipa/ticket/3526 --- ipalib/plugins/dns.py | 2 ++ tests/test_xmlrpc/test_dns_plugin.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index a23d1b823..dabab8405 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -2197,6 +2197,8 @@ class dnsrecord(LDAPObject): def postprocess_record(self, record, **options): if options.get('structured', False): for attr in record.keys(): + # attributes in LDAPEntry may not be normalized + attr = attr.lower() try: param = self.params[attr] except KeyError: diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py index 190248494..945bca384 100644 --- a/tests/test_xmlrpc/test_dns_plugin.py +++ b/tests/test_xmlrpc/test_dns_plugin.py @@ -1078,6 +1078,34 @@ class test_dns(Declarative): }, ), + dict( + desc='Show record %r in zone %r with --structured and --all options'\ + % (dnsrev1, revdnszone1), + command=('dnsrecord_show', [revdnszone1, dnsrev1], + {'structured': True, 'all': True}), + expected={ + 'value': dnsrev1, + 'summary': None, + 'result': { + 'dn': dnsrev1_dn, + 'idnsname': [dnsrev1], + 'objectclass': objectclasses.dnsrecord, + 'dnsrecords': [ + { + 'dnstype': u'PTR', + 'dnsdata': u'foo-1.example.com.', + 'ptr_part_hostname': u'foo-1.example.com.' + }, + { + 'dnstype': u'CNAME', + 'dnsdata': u'foo-1.example.com.', + 'cname_part_hostname': u'foo-1.example.com.' + } + ], + }, + }, + ), + dict( desc='Update global DNS settings', command=('dnsconfig_mod', [], {'idnsforwarders' : [u'80.142.15.80'],}),