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
This commit is contained in:
Martin Kosek 2013-03-21 14:54:46 +01:00
parent c2034805d3
commit 322458b5b2
2 changed files with 30 additions and 0 deletions

View File

@ -2197,6 +2197,8 @@ class dnsrecord(LDAPObject):
def postprocess_record(self, record, **options): def postprocess_record(self, record, **options):
if options.get('structured', False): if options.get('structured', False):
for attr in record.keys(): for attr in record.keys():
# attributes in LDAPEntry may not be normalized
attr = attr.lower()
try: try:
param = self.params[attr] param = self.params[attr]
except KeyError: except KeyError:

View File

@ -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( dict(
desc='Update global DNS settings', desc='Update global DNS settings',
command=('dnsconfig_mod', [], {'idnsforwarders' : [u'80.142.15.80'],}), command=('dnsconfig_mod', [], {'idnsforwarders' : [u'80.142.15.80'],}),