Re: [Freeipa-devel] [PATCH] 310 Exclude attributelevelrights from --raw result processing in baseldap
On 07/31/2014 10:24 AM, Jan Cholasta wrote: Dne 29.7.2014 v 12:00 Petr Viktorin napsal(a): On 07/29/2014 08:27 AM, Jan Cholasta wrote: Dne 28.7.2014 v 19:59 Petr Viktorin napsal(a): On 07/24/2014 05:33 PM, Jan Cholasta wrote: Hi, the attached patch fixes https://fedorahosted.org/freeipa/ticket/4371. Honza NACK If the value *is* a str, with this patch it ends up undefined. Right, fixed. ACK, pushed to: master: 785e13dd1e16ad03d4ef03edcb672d6f9d8b457b ipa-4-1: 785e13dd1e16ad03d4ef03edcb672d6f9d8b457b ipa-4-0: 2eee6060f3237cc4cf23f4044e67e95d7fad195d Could you also write a test for this, though? Sure. Thanks! ACK, pushed to: master: 34de95545d0a09de2f1acc6987edc27feb762c1b ipa-4-0: c93fe68e398a32b1ed0a139613da452e151e7156 ipa-4-1: 34de95545d0a09de2f1acc6987edc27feb762c1b -- Petr³ ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 310 Exclude attributelevelrights from --raw result processing in baseldap
Dne 29.7.2014 v 12:00 Petr Viktorin napsal(a): On 07/29/2014 08:27 AM, Jan Cholasta wrote: Dne 28.7.2014 v 19:59 Petr Viktorin napsal(a): On 07/24/2014 05:33 PM, Jan Cholasta wrote: Hi, the attached patch fixes https://fedorahosted.org/freeipa/ticket/4371. Honza NACK If the value *is* a str, with this patch it ends up undefined. Right, fixed. ACK, pushed to: master: 785e13dd1e16ad03d4ef03edcb672d6f9d8b457b ipa-4-1: 785e13dd1e16ad03d4ef03edcb672d6f9d8b457b ipa-4-0: 2eee6060f3237cc4cf23f4044e67e95d7fad195d Could you also write a test for this, though? Sure. -- Jan Cholasta From 8f48103e93f27e33f9dca676fb986e61571fa971 Mon Sep 17 00:00:00 2001 From: Jan Cholasta jchol...@redhat.com Date: Thu, 31 Jul 2014 10:22:23 +0200 Subject: [PATCH] Add test for baseldap.entry_to_dict. --- ipatests/test_xmlrpc/test_baseldap_plugin.py | 49 1 file changed, 49 insertions(+) diff --git a/ipatests/test_xmlrpc/test_baseldap_plugin.py b/ipatests/test_xmlrpc/test_baseldap_plugin.py index 6a8501f..1a4bb0f 100644 --- a/ipatests/test_xmlrpc/test_baseldap_plugin.py +++ b/ipatests/test_xmlrpc/test_baseldap_plugin.py @@ -21,8 +21,13 @@ Test the `ipalib.plugins.baseldap` module. +import ldap + +from ipapython.dn import DN +from ipapython import ipaldap from ipalib import errors from ipalib.plugins import baseldap +from ipatests.util import assert_deepequal def test_exc_wrapper(): @@ -157,3 +162,47 @@ def test_exc_callback_registration(): messages = [] subclass_instance.test_fail() assert messages == ['Base exc_callback', 'Subclass registered callback'] + + +def test_entry_to_dict(): +class FakeAttributeType(object): +def __init__(self, name, syntax): +self.names = (name,) +self.syntax = syntax + +class FakeSchema(object): +def get_obj(self, type, name): +if type != ldap.schema.AttributeType: +return +if name == 'binaryattr': +return FakeAttributeType(name, '1.3.6.1.4.1.1466.115.121.1.40') +elif name == 'textattr': +return FakeAttributeType(name, '1.3.6.1.4.1.1466.115.121.1.15') +elif name == 'dnattr': +return FakeAttributeType(name, '1.3.6.1.4.1.1466.115.121.1.12') + +class FakeIPASimpleLDAPObject(ipaldap.IPASimpleLDAPObject): +def __init__(self): +super(FakeIPASimpleLDAPObject, self).__init__('ldap://test', False) +self._schema = FakeSchema() +self._has_schema = True + +conn = FakeIPASimpleLDAPObject() +rights = {'nothing': 'is'} + +entry = ipaldap.LDAPEntry( +conn, +DN('cn=test'), +textattr=[u'text'], +dnattr=[DN('cn=test')], +binaryattr=['\xffabcd'], +attributelevelrights=rights) +the_dict = { +u'dn': u'cn=test', +u'textattr': [u'text'], +u'dnattr': [u'cn=test'], +u'binaryattr': ['\xffabcd'], +u'attributelevelrights': rights} +assert_deepequal( +baseldap.entry_to_dict(entry, all=True, raw=True), +the_dict) -- 1.9.3 ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 310 Exclude attributelevelrights from --raw result processing in baseldap
Dne 28.7.2014 v 19:59 Petr Viktorin napsal(a): On 07/24/2014 05:33 PM, Jan Cholasta wrote: Hi, the attached patch fixes https://fedorahosted.org/freeipa/ticket/4371. Honza NACK If the value *is* a str, with this patch it ends up undefined. Right, fixed. -- Jan Cholasta From 803c7cb55a12fba965876bb6a031cf0c7fbfd5c7 Mon Sep 17 00:00:00 2001 From: Jan Cholasta jchol...@redhat.com Date: Thu, 24 Jul 2014 17:17:48 +0200 Subject: [PATCH] Exclude attributelevelrights from --raw result processing in baseldap. https://fedorahosted.org/freeipa/ticket/4371 --- ipalib/plugins/baseldap.py | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 865a357..26b43b9 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -240,9 +240,13 @@ def entry_from_entry(entry, newentry): def entry_to_dict(entry, **options): if options.get('raw', False): result = {} -for attr, value in entry.raw.iteritems(): -if entry.conn.get_type(attr) is not str: -value = list(value) +for attr in entry.iterkeys(): +if attr.lower() == 'attributelevelrights': +value = entry[attr] +elif entry.conn.get_type(attr) is str: +value = entry.raw[attr] +else: +value = list(entry.raw[attr]) for (i, v) in enumerate(value): try: value[i] = v.decode('utf-8') -- 1.9.3 ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 310 Exclude attributelevelrights from --raw result processing in baseldap
On 07/29/2014 08:27 AM, Jan Cholasta wrote: Dne 28.7.2014 v 19:59 Petr Viktorin napsal(a): On 07/24/2014 05:33 PM, Jan Cholasta wrote: Hi, the attached patch fixes https://fedorahosted.org/freeipa/ticket/4371. Honza NACK If the value *is* a str, with this patch it ends up undefined. Right, fixed. ACK, pushed to: master: 785e13dd1e16ad03d4ef03edcb672d6f9d8b457b ipa-4-1: 785e13dd1e16ad03d4ef03edcb672d6f9d8b457b ipa-4-0: 2eee6060f3237cc4cf23f4044e67e95d7fad195d Could you also write a test for this, though? -- Petr³ ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 310 Exclude attributelevelrights from --raw result processing in baseldap
On 07/24/2014 05:33 PM, Jan Cholasta wrote: Hi, the attached patch fixes https://fedorahosted.org/freeipa/ticket/4371. Honza NACK If the value *is* a str, with this patch it ends up undefined. -- Petr³ ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel