A wrong way of handling --group DN object caused Internal Error
for this command. Fix that and also provide unit tests to avoid
another regression.

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

-- 
Martin Kosek <mko...@redhat.com>
Senior Software Engineer - Identity Management Team
Red Hat Inc.
From 17b72a2cac4e617e8b6e046abb39a10dbfbfd5a1 Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Wed, 19 Dec 2012 15:38:52 +0100
Subject: [PATCH] Fix delegation-find command --group handling

A wrong way of handling --group DN object caused Internal Error
for this command. Fix that and also provide unit tests to avoid
another regression.

https://fedorahosted.org/freeipa/ticket/3311
---
 ipalib/plugins/aci.py                       |  2 +-
 tests/test_xmlrpc/test_delegation_plugin.py | 40 +++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index 7d5bf504c135314d6bf4c9c804249a2a26bae803..702ae010160984636603c75872ddbdddd79bd52c 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -801,7 +801,7 @@ class aci_find(crud.Search):
                 groupdn = a.bindrule['expression']
                 groupdn = DN(groupdn.replace('ldap:///',''))
                 try:
-                    cn = groupdn[0]['cn'].value
+                    cn = groupdn[0]['cn']
                 except (IndexError, KeyError):
                     cn = None
                 if cn is None or cn != kw['group']:
diff --git a/tests/test_xmlrpc/test_delegation_plugin.py b/tests/test_xmlrpc/test_delegation_plugin.py
index a31fed3edf1477a7f4db4783e4b8d6c92b3fdec2..bc3b96a2736d6d7f10a0e781f62fb7db7a532bb1 100644
--- a/tests/test_xmlrpc/test_delegation_plugin.py
+++ b/tests/test_xmlrpc/test_delegation_plugin.py
@@ -178,6 +178,46 @@ class test_delegation(Declarative):
 
 
         dict(
+            desc='Search for %r using --group filter' % delegation1,
+            command=('delegation_find', [delegation1], {'group': u'editors'}),
+            expected=dict(
+                count=1,
+                truncated=False,
+                summary=u'1 delegation matched',
+                result=[
+                    {
+                    'attrs': [u'street', u'c', u'l', u'st', u'postalcode'],
+                    'permissions': [u'write'],
+                    'aciname': delegation1,
+                    'group': u'editors',
+                    'memberof': member1,
+                    },
+                ],
+            ),
+        ),
+
+
+        dict(
+            desc='Search for %r using --membergroup filter' % delegation1,
+            command=('delegation_find', [delegation1], {'memberof': member1}),
+            expected=dict(
+                count=1,
+                truncated=False,
+                summary=u'1 delegation matched',
+                result=[
+                    {
+                    'attrs': [u'street', u'c', u'l', u'st', u'postalcode'],
+                    'permissions': [u'write'],
+                    'aciname': delegation1,
+                    'group': u'editors',
+                    'memberof': member1,
+                    },
+                ],
+            ),
+        ),
+
+
+        dict(
             desc='Search for %r with --pkey-only' % delegation1,
             command=('delegation_find', [delegation1], {'pkey_only' : True}),
             expected=dict(
-- 
1.7.11.7

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

Reply via email to