Re: [Freeipa-devel] [PATCH] 689 make deepcopy of objectclasses
Jakub Hrozek wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/24/2011 04:58 PM, Rob Crittenden wrote: Jakub Hrozek wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/24/2011 04:50 PM, Rob Crittenden wrote: In the host plugin we modify the default set of objectclasses depending on what kind of host we're creating. This was actually updating the objectclass of the object itself so that the objectclass variable was storing duplicate objectclasses (because we sometimes append values). Make a deepcopy instead. I also re-ordered some values in the host plugin to match what the unit tests expect. It was easier to change in one place than many and have the same result :-) rob I think you sent a wrong patch (688, should have been 689) Ok, here goes. rob Ack pushed to master ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 689 make deepcopy of objectclasses
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/24/2011 04:58 PM, Rob Crittenden wrote: > Jakub Hrozek wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> On 01/24/2011 04:50 PM, Rob Crittenden wrote: >>> In the host plugin we modify the default set of objectclasses depending >>> on what kind of host we're creating. This was actually updating the >>> objectclass of the object itself so that the objectclass variable was >>> storing duplicate objectclasses (because we sometimes append values). >>> >>> Make a deepcopy instead. >>> >>> I also re-ordered some values in the host plugin to match what the unit >>> tests expect. It was easier to change in one place than many and have >>> the same result :-) >>> >>> rob >>> >> >> I think you sent a wrong patch (688, should have been 689) > > Ok, here goes. > > rob Ack -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk09rEAACgkQHsardTLnvCV5zACgih6krPeHUe4UzDEccDlYYV8n g9AAoN47pXdhXtVDimqi+OUX1d1whtmT =gYvF -END PGP SIGNATURE- ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 689 make deepcopy of objectclasses
Jakub Hrozek wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/24/2011 04:50 PM, Rob Crittenden wrote: In the host plugin we modify the default set of objectclasses depending on what kind of host we're creating. This was actually updating the objectclass of the object itself so that the objectclass variable was storing duplicate objectclasses (because we sometimes append values). Make a deepcopy instead. I also re-ordered some values in the host plugin to match what the unit tests expect. It was easier to change in one place than many and have the same result :-) rob I think you sent a wrong patch (688, should have been 689) Ok, here goes. rob >From 2512a94629e55e3693ec9b348fff09866f21585d Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 24 Jan 2011 10:46:44 -0500 Subject: [PATCH] Make a copy of objectclasses so a call can't update them globally. In the host plugin we may change the default objectclasses based on the options selected. This was affecting it globally and causing subsequent calls to fail. --- ipalib/plugins/baseldap.py |3 ++- ipalib/plugins/host.py |8 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index e7ccb77..27e543d 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -23,6 +23,7 @@ Base classes for LDAP plugins. import re import json import time +from copy import deepcopy from ipalib import api, crud, errors from ipalib import Method, Object @@ -504,7 +505,7 @@ class LDAPCreate(CallbackInterface, crud.Create): ldap = self.obj.backend entry_attrs = self.args_options_2_entry(*keys, **options) -entry_attrs['objectclass'] = self.obj.object_class +entry_attrs['objectclass'] = deepcopy(self.obj.object_class) if self.obj.object_class_config: config = ldap.get_ipa_config()[1] diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index 6947d90..3225a78 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -323,15 +323,15 @@ class host_add(LDAPCreate): entry_attrs['krbprincipalname'] = 'host/%s@%s' % ( keys[-1], self.api.env.realm ) +if 'krbprincipalaux' not in entry_attrs: +entry_attrs['objectclass'].append('krbprincipalaux') if 'krbprincipal' not in entry_attrs: entry_attrs['objectclass'].append('krbprincipal') -if 'krbprincipal' not in entry_attrs: -entry_attrs['objectclass'].append('krbprincipalaux') else: -if 'krbprincipal' in entry_attrs['objectclass']: -entry_attrs['objectclass'].remove('krbprincipal') if 'krbprincipalaux' in entry_attrs['objectclass']: entry_attrs['objectclass'].remove('krbprincipalaux') +if 'krbprincipal' in entry_attrs['objectclass']: +entry_attrs['objectclass'].remove('krbprincipal') if 'random' in options: if options.get('random'): entry_attrs['userpassword'] = ipa_generate_password() -- 1.7.3.4 ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] 689 make deepcopy of objectclasses
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/24/2011 04:50 PM, Rob Crittenden wrote: > In the host plugin we modify the default set of objectclasses depending > on what kind of host we're creating. This was actually updating the > objectclass of the object itself so that the objectclass variable was > storing duplicate objectclasses (because we sometimes append values). > > Make a deepcopy instead. > > I also re-ordered some values in the host plugin to match what the unit > tests expect. It was easier to change in one place than many and have > the same result :-) > > rob > I think you sent a wrong patch (688, should have been 689) -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk09oP8ACgkQHsardTLnvCWNzQCgoWpYWVo4kq4vdRP1/XWqF+8S smgAoKFYRGzpAvCyrFwiiRE/uiL7X+6l =+FB/ -END PGP SIGNATURE- ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
[Freeipa-devel] [PATCH] 689 make deepcopy of objectclasses
In the host plugin we modify the default set of objectclasses depending on what kind of host we're creating. This was actually updating the objectclass of the object itself so that the objectclass variable was storing duplicate objectclasses (because we sometimes append values). Make a deepcopy instead. I also re-ordered some values in the host plugin to match what the unit tests expect. It was easier to change in one place than many and have the same result :-) rob >From 459b204be01bd57ba2420a269b3a9702dfc22a3c Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 24 Jan 2011 10:43:59 -0500 Subject: [PATCH] Fix failed tests. API for utcoffset changed and strings are more robust. In Python 2.7 the API for time.utcoffset() changed. We do more automatic conversions of strings so need to loosen the tests a bit. --- ipapython/test/test_ipautil.py |8 tests/test_ipalib/test_parameters.py |7 --- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ipapython/test/test_ipautil.py b/ipapython/test/test_ipautil.py index ef1afd3..ff9f282 100644 --- a/ipapython/test/test_ipautil.py +++ b/ipapython/test/test_ipautil.py @@ -275,7 +275,7 @@ class TestTimeParser(unittest.TestCase): time = ipautil.parse_generalized_time(timestr) self.assertEqual(0, time.tzinfo.houroffset) self.assertEqual(0, time.tzinfo.minoffset) -offset = time.tzinfo.utcoffset() +offset = time.tzinfo.utcoffset(time.tzinfo.dst()) self.assertEqual(0, offset.seconds) timestr = "20051213141205+0500" @@ -283,7 +283,7 @@ class TestTimeParser(unittest.TestCase): time = ipautil.parse_generalized_time(timestr) self.assertEqual(5, time.tzinfo.houroffset) self.assertEqual(0, time.tzinfo.minoffset) -offset = time.tzinfo.utcoffset() +offset = time.tzinfo.utcoffset(time.tzinfo.dst()) self.assertEqual(5 * 60 * 60, offset.seconds) timestr = "20051213141205-0500" @@ -293,7 +293,7 @@ class TestTimeParser(unittest.TestCase): self.assertEqual(0, time.tzinfo.minoffset) # NOTE - the offset is always positive - it's minutes #_east_ of UTC -offset = time.tzinfo.utcoffset() +offset = time.tzinfo.utcoffset(time.tzinfo.dst()) self.assertEqual((24 - 5) * 60 * 60, offset.seconds) timestr = "20051213141205-0930" @@ -301,7 +301,7 @@ class TestTimeParser(unittest.TestCase): time = ipautil.parse_generalized_time(timestr) self.assertEqual(-9, time.tzinfo.houroffset) self.assertEqual(-30, time.tzinfo.minoffset) -offset = time.tzinfo.utcoffset() +offset = time.tzinfo.utcoffset(time.tzinfo.dst()) self.assertEqual(((24 - 9) * 60 * 60) - (30 * 60), offset.seconds) diff --git a/tests/test_ipalib/test_parameters.py b/tests/test_ipalib/test_parameters.py index fd9880d..e90a262 100644 --- a/tests/test_ipalib/test_parameters.py +++ b/tests/test_ipalib/test_parameters.py @@ -33,6 +33,7 @@ from ipalib import parameters, request, errors, config from ipalib.constants import TYPE_ERROR, CALLABLE_ERROR, NULLS from ipalib.errors import ValidationError from ipalib import _ +from xmlrpclib import MAXINT class test_DefaultFrom(ClassChecker): """ @@ -921,7 +922,7 @@ class test_Str(ClassChecker): mthd = o._convert_scalar for value in (u'Hello', 42, 1.2, unicode_str): assert mthd(value) == unicode(value) -bad = [True, 'Hello', dict(one=1), utf8_bytes] +bad = [True, dict(one=1)] for value in bad: e = raises(errors.ConversionError, mthd, value) assert e.name == 'my_str' @@ -1164,7 +1165,7 @@ class test_Int(ClassChecker): assert o.type is int assert isinstance(o, parameters.Int) assert o.minvalue is None -assert o.maxvalue is None +assert o.maxvalue == int(MAXINT) # Test when min > max: e = raises(ValueError, self.cls, 'my_number', minvalue=22, maxvalue=15) @@ -1233,7 +1234,7 @@ class test_Int(ClassChecker): """ o = self.cls('my_number') # Assure invalid inputs raise error -for bad in ['hello', u'hello', True, None, '10', u'', u'.']: +for bad in ['hello', u'hello', True, None, u'', u'.']: e = raises(errors.ConversionError, o._convert_scalar, bad) assert e.name == 'my_number' assert e.index is None -- 1.7.3.4 ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel