URL: https://github.com/freeipa/freeipa/pull/104
Author: martbab
 Title: #104: Backport XMLRPC test fixes to ipa-4-3 branch
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/104/head:pr104
git checkout pr104
From 2a95cf2cce9a032d453eb84f319d7a82ab964c22 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Fri, 19 Aug 2016 10:39:40 +0200
Subject: [PATCH 1/2] Raise DuplicatedEnrty error when user exists in
 delete_container

We do not have right to write to users delete_container. In case that
user already exists in that container and we tried to add entry, we
receive ACIError. This must be checked and DuplicationEntry error must
be raised before.

Original ticket:
https://fedorahosted.org/freeipa/ticket/6199

Backported to ipa-4-3:
https://fedorahosted.org/freeipa/ticket/6316
---
 ipalib/plugins/user.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index 2b792af..a207809 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -356,6 +356,10 @@ class user(baseuser):
         ),
     )
 
+    def get_delete_dn(self, *keys, **options):
+        active_dn = self.get_dn(*keys, **options)
+        return DN(active_dn[0], self.delete_container_dn, api.env.basedn)
+
     def get_either_dn(self, *keys, **options):
         '''
         Returns the DN of a user
@@ -372,7 +376,7 @@ def get_either_dn(self, *keys, **options):
             dn = active_dn
         except errors.NotFound:
             # Check that this value is a Delete user
-            delete_dn = DN(active_dn[0], self.delete_container_dn, api.env.basedn)
+            delete_dn = self.get_delete_dn(*keys, **options)
             try:
                 ldap.get_entry(delete_dn, ['dn'])
 
@@ -416,7 +420,14 @@ class user_add(baseuser_add):
     )
 
     def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
-        dn = self.obj.get_either_dn(*keys, **options)
+        delete_dn = self.obj.get_delete_dn(*keys, **options)
+        try:
+            ldap.get_entry(delete_dn, [''])
+        except errors.NotFound:
+            pass
+        else:
+            raise self.obj.handle_duplicate_entry(*keys)
+
         if not options.get('noprivate', False):
             try:
                 # The Managed Entries plugin will allow a user to be created

From dde22fbd3b438f761740f31315d6a91cebd4e721 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Fri, 12 Aug 2016 19:49:33 +0200
Subject: [PATCH 2/2] Tests: fix test_forward_zones in
 test_xmlrpc/test_dns_plugin

Class test_forward_zones in ipatests/test_xmlrpc/test_dns_plugin
was using DNS zone 'fwzone2.test.' and expected to get warning
'Forwarding policy conflicts with some automatic empty zones.'
(aka 'DNSForwardPolicyConflictWithEmptyZone').

This does not make sense because 'test.' zone is not listed in IANA registry
'Locally-Served DNS Zones':
http://www.iana.org/assignments/locally-served-dns-zones/locally-served-dns-zones.xhtml

To fix this I simply removed the warning from set of expected results.

Original ticket:
https://fedorahosted.org/freeipa/ticket/6213

Backported to ipa-4-3:
https://fedorahosted.org/freeipa/ticket/6317
---
 ipatests/test_xmlrpc/test_dns_plugin.py | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py
index 7c2450f..810c7c3 100644
--- a/ipatests/test_xmlrpc/test_dns_plugin.py
+++ b/ipatests/test_xmlrpc/test_dns_plugin.py
@@ -3417,15 +3417,7 @@ def setup_class(cls):
             expected={
                 'value': fwzone2_dnsname,
                 'summary': None,
-                u'messages': (
-                    {u'message': lambda x: x.startswith(
-                        u"Forwarding policy conflicts with some "
-                        "automatic empty zones."),
-                     u'code': 13021,
-                     u'type': u'warning',
-                     u'name': u'DNSForwardPolicyConflictWithEmptyZone',
-                    },
-                    {u'message': lambda x: x.startswith(
+                u'messages': ({u'message': lambda x: x.startswith(
                         u"DNS server %s: query '%s SOA':" %
                         (forwarder1, fwzone2)),
                      u'code': 13006,
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to