2010-12-01 10:23:52 -06:00
|
|
|
# Authors:
|
|
|
|
# Rob Crittenden <rcritten@redhat.com>
|
|
|
|
# Pavel Zuna <pzuna@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
2010-12-09 06:59:11 -06:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2010-12-01 10:23:52 -06:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2010-12-09 06:59:11 -06:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
"""
|
|
|
|
Test the `ipalib/plugins/permission.py` module.
|
|
|
|
"""
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
import os
|
|
|
|
|
2013-09-13 09:08:22 -05:00
|
|
|
import nose
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
from ipalib import api, errors
|
2013-05-21 06:40:27 -05:00
|
|
|
from ipatests.test_xmlrpc import objectclasses
|
2013-11-13 09:31:58 -06:00
|
|
|
from xmlrpc_test import Declarative
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
from ipapython.dn import DN
|
2013-11-29 05:57:30 -06:00
|
|
|
import inspect
|
2010-12-01 10:23:52 -06:00
|
|
|
|
2013-09-13 09:08:22 -05:00
|
|
|
try:
|
|
|
|
from ipaserver.plugins.ldap2 import ldap2
|
|
|
|
except ImportError:
|
|
|
|
have_ldap2 = False
|
|
|
|
else:
|
|
|
|
import krbV
|
|
|
|
have_ldap2 = True
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
permission1 = u'testperm'
|
2011-08-09 20:21:56 -05:00
|
|
|
permission1_dn = DN(('cn',permission1),
|
|
|
|
api.env.container_permission,api.env.basedn)
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
|
2011-01-27 05:17:10 -06:00
|
|
|
permission1_renamed = u'testperm1_rn'
|
2011-08-09 20:21:56 -05:00
|
|
|
permission1_renamed_dn = DN(('cn',permission1_renamed),
|
|
|
|
api.env.container_permission,api.env.basedn)
|
2011-01-27 05:17:10 -06:00
|
|
|
|
2012-04-11 02:37:15 -05:00
|
|
|
permission1_renamed_ucase = u'Testperm_RN'
|
2012-06-19 07:49:19 -05:00
|
|
|
permission1_renamed_ucase_dn = DN(('cn',permission1_renamed_ucase),
|
2012-04-11 02:37:15 -05:00
|
|
|
api.env.container_permission,api.env.basedn)
|
|
|
|
|
2011-01-27 05:17:10 -06:00
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
permission2 = u'testperm2'
|
2011-08-09 20:21:56 -05:00
|
|
|
permission2_dn = DN(('cn',permission2),
|
|
|
|
api.env.container_permission,api.env.basedn)
|
2010-12-01 10:23:52 -06:00
|
|
|
|
2012-08-22 09:39:01 -05:00
|
|
|
permission3 = u'testperm3'
|
|
|
|
permission3_dn = DN(('cn',permission3),
|
|
|
|
api.env.container_permission,api.env.basedn)
|
|
|
|
permission3_attributelevelrights = {
|
2013-09-25 08:46:11 -05:00
|
|
|
'member': u'rscwo',
|
|
|
|
'seealso': u'rscwo',
|
|
|
|
'ipapermissiontype': u'rscwo',
|
|
|
|
'cn': u'rscwo',
|
|
|
|
'businesscategory': u'rscwo',
|
|
|
|
'objectclass': u'rscwo',
|
|
|
|
'memberof': u'rscwo',
|
|
|
|
'aci': u'rscwo',
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermlocation': u'rscwo',
|
2013-09-25 08:46:11 -05:00
|
|
|
'o': u'rscwo',
|
2013-09-13 09:08:22 -05:00
|
|
|
'ipapermincludedattr': u'rscwo',
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermdefaultattr': u'rscwo',
|
|
|
|
'ipapermexcludedattr': u'rscwo',
|
2013-09-25 08:46:11 -05:00
|
|
|
'owner': u'rscwo',
|
|
|
|
'ou': u'rscwo',
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermright': u'rscwo',
|
2013-09-25 08:46:11 -05:00
|
|
|
'nsaccountlock': u'rscwo',
|
|
|
|
'description': u'rscwo',
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermtargetfilter': u'rscwo',
|
|
|
|
'ipapermbindruletype': u'rscwo',
|
|
|
|
'ipapermlocation': u'rscwo',
|
|
|
|
'ipapermtarget': u'rscwo',
|
|
|
|
'type': u'rscwo',
|
|
|
|
'targetgroup': u'rscwo',
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': u'rscwo',
|
2012-08-22 09:39:01 -05:00
|
|
|
}
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
privilege1 = u'testpriv1'
|
2011-08-09 20:21:56 -05:00
|
|
|
privilege1_dn = DN(('cn',privilege1),
|
|
|
|
api.env.container_privilege,api.env.basedn)
|
2010-12-01 10:23:52 -06:00
|
|
|
|
2012-04-06 03:56:46 -05:00
|
|
|
invalid_permission1 = u'bad;perm'
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
users_dn = DN(api.env.container_user, api.env.basedn)
|
|
|
|
groups_dn = DN(api.env.container_group, api.env.basedn)
|
2013-12-05 11:10:02 -06:00
|
|
|
etc_dn = DN('cn=etc', api.env.basedn)
|
2013-12-05 11:18:32 -06:00
|
|
|
nonexistent_dn = DN('cn=does not exist', api.env.basedn)
|
2014-03-26 11:11:23 -05:00
|
|
|
admin_dn = DN('uid=admin', users_dn)
|
2013-11-13 09:31:58 -06:00
|
|
|
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
def verify_permission_aci(name, dn, acistring):
|
|
|
|
"""Return test dict that verifies the ACI at the given location"""
|
|
|
|
return dict(
|
|
|
|
desc="Verify ACI of %s #(%s)" % (name, lineinfo(2)),
|
|
|
|
command=('aci_show', [name], dict(
|
|
|
|
aciprefix=u'permission', location=dn, raw=True)),
|
|
|
|
expected=dict(
|
|
|
|
result=dict(aci=acistring),
|
|
|
|
summary=None,
|
|
|
|
value=name,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def verify_permission_aci_missing(name, dn):
|
|
|
|
"""Return test dict that checks the ACI at the given location is missing"""
|
|
|
|
return dict(
|
|
|
|
desc="Verify ACI of %s is missing #(%s)" % (name, lineinfo(2)),
|
|
|
|
command=('aci_show', [name], dict(
|
|
|
|
aciprefix=u'permission', location=dn, raw=True)),
|
|
|
|
expected=errors.NotFound(
|
|
|
|
reason='ACI with name "%s" not found' % name),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def lineinfo(level):
|
|
|
|
"""Return "filename:lineno" for `level`-th caller"""
|
|
|
|
# Declarative tests hide tracebacks.
|
|
|
|
# Including this info in the test name makes it possible
|
|
|
|
# to locate failing tests.
|
|
|
|
frame = inspect.currentframe()
|
|
|
|
for i in range(level):
|
|
|
|
frame = frame.f_back
|
|
|
|
lineno = frame.f_lineno
|
|
|
|
filename = os.path.basename(frame.f_code.co_filename)
|
|
|
|
return '%s:%s' % (filename, lineno)
|
|
|
|
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
class test_permission_negative(Declarative):
|
|
|
|
"""Make sure invalid operations fail"""
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
cleanup_commands = [
|
2013-10-22 05:15:52 -05:00
|
|
|
('permission_del', [permission1], {'force': True}),
|
2010-12-01 10:23:52 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Try to retrieve non-existent %r' % permission1,
|
|
|
|
command=('permission_show', [permission1], {}),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(
|
|
|
|
reason=u'%s: permission not found' % permission1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to update non-existent %r' % permission1,
|
2013-11-13 09:31:58 -06:00
|
|
|
command=('permission_mod', [permission1], dict(ipapermright=u'all')),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(
|
|
|
|
reason=u'%s: permission not found' % permission1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to delete non-existent %r' % permission1,
|
|
|
|
command=('permission_del', [permission1], {}),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(
|
|
|
|
reason=u'%s: permission not found' % permission1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for non-existent %r' % permission1,
|
|
|
|
command=('permission_find', [permission1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=0,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'0 permissions matched',
|
|
|
|
result=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Try creating %r with no ipapermright' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.RequirementError(name='ipapermright'),
|
|
|
|
),
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
dict(
|
2013-11-13 09:31:58 -06:00
|
|
|
desc='Try creating %r with no target option' % permission1,
|
2010-12-01 10:23:52 -06:00
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'write',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='target',
|
|
|
|
error='there must be at least one target entry specifier '
|
|
|
|
'(e.g. target, targetfilter, attrs)'),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci_missing(permission1, api.env.basedn),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Try to create invalid %r' % invalid_permission1,
|
|
|
|
command=('permission_add', [invalid_permission1], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
type=u'user',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'write',
|
|
|
|
)),
|
|
|
|
expected=errors.ValidationError(name='name',
|
|
|
|
error='May only contain letters, numbers, -, _, ., and space'),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci_missing(permission1, users_dn),
|
|
|
|
|
2014-02-21 06:58:15 -06:00
|
|
|
dict(
|
|
|
|
desc='Try creating %r with bad attribute name' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermright=u'write',
|
|
|
|
attrs=u'bogusattr',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.InvalidSyntax(
|
|
|
|
attr=r'targetattr "bogusattr" does not exist in schema. '
|
|
|
|
r'Please add attributeTypes "bogusattr" to '
|
|
|
|
r'schema if necessary. '
|
|
|
|
r'ACL Syntax Error(-5):'
|
|
|
|
r'(targetattr = \22bogusattr\22)'
|
|
|
|
r'(targetfilter = \22(objectclass=posixaccount)\22)'
|
|
|
|
r'(version 3.0;acl \22permission:%(name)s\22;'
|
|
|
|
r'allow (write) groupdn = \22ldap:///%(dn)s\22;)' % dict(
|
|
|
|
name=permission1,
|
|
|
|
dn=permission1_dn),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci_missing(permission1, users_dn),
|
|
|
|
|
2014-02-25 10:24:02 -06:00
|
|
|
dict(
|
|
|
|
desc='Try to create permission with : in the name',
|
|
|
|
command=('permission_add', ['bad:' + permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermright=u'write',
|
|
|
|
)),
|
|
|
|
expected=errors.ValidationError(name='name',
|
|
|
|
error='May only contain letters, numbers, -, _, ., and space'),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci_missing(permission1, users_dn),
|
|
|
|
|
2014-03-06 07:25:36 -06:00
|
|
|
dict(
|
|
|
|
desc='Try to create permission with full and extra target filter',
|
|
|
|
command=('permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermright=u'write',
|
|
|
|
ipapermtargetfilter=u'(cn=*)',
|
|
|
|
extratargetfilter=u'(sn=*)',
|
|
|
|
)),
|
|
|
|
expected=errors.ValidationError(name='ipapermtargetfilter',
|
|
|
|
error='cannot specify full target filter and extra target '
|
|
|
|
'filter simultaneously'),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci_missing(permission1, users_dn),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Create %r so we can try breaking it' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2010-12-01 10:23:52 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=permission1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
2013-11-13 09:31:58 -06:00
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try remove ipapermright from %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermright=None,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.RequirementError(name='ipapermright'),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to remove type from %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=None,
|
2013-11-13 09:31:58 -06:00
|
|
|
type=None,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='target',
|
|
|
|
error='there must be at least one target entry specifier '
|
|
|
|
'(e.g. target, targetfilter, attrs)'),
|
|
|
|
),
|
|
|
|
|
2014-02-28 09:27:22 -06:00
|
|
|
dict(
|
|
|
|
desc='Try to "remove" empty memberof from %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
memberof=None,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.EmptyModlist(),
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
2014-01-06 08:51:20 -06:00
|
|
|
desc='Try to remove targetfilter and memberof from %r' % permission1,
|
2013-11-13 09:31:58 -06:00
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=None,
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=None,
|
2013-11-13 09:31:58 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='target',
|
|
|
|
error='there must be at least one target entry specifier '
|
|
|
|
'(e.g. target, targetfilter, attrs)'),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
2014-02-28 09:27:22 -06:00
|
|
|
desc='Try to rename %r to invalid %r' % (
|
2013-11-13 09:31:58 -06:00
|
|
|
permission1, invalid_permission1),
|
|
|
|
command=('permission_mod', [permission1], dict(
|
|
|
|
rename=invalid_permission1,
|
|
|
|
)),
|
|
|
|
expected=errors.ValidationError(name='rename',
|
|
|
|
error='May only contain letters, numbers, -, _, ., and space'),
|
|
|
|
),
|
|
|
|
|
2013-09-13 09:08:22 -05:00
|
|
|
dict(
|
|
|
|
desc='Try setting ipapermexcludedattr on %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermexcludedattr=[u'cn'],
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='ipapermexcludedattr',
|
|
|
|
error='only available on managed permissions'),
|
|
|
|
),
|
2014-03-06 07:25:36 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to setting both full and extra target filter on %s' % permission1,
|
|
|
|
command=('permission_mod', [permission1], dict(
|
|
|
|
ipapermtargetfilter=u'(cn=*)',
|
|
|
|
extratargetfilter=u'(sn=*)',
|
|
|
|
)),
|
|
|
|
expected=errors.ValidationError(name='ipapermtargetfilter',
|
|
|
|
error='cannot specify full target filter and extra target '
|
|
|
|
'filter simultaneously'),
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class test_permission(Declarative):
|
|
|
|
"""Misc. tests for the permission plugin"""
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
|
|
|
('permission_del', [permission2], {'force': True}),
|
|
|
|
('permission_del', [permission3], {'force': True}),
|
|
|
|
('permission_del', [permission1_renamed], {'force': True}),
|
|
|
|
('permission_del', [permission1_renamed_ucase], {'force': True}),
|
|
|
|
('privilege_del', [privilege1], {}),
|
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
2010-12-01 10:23:52 -06:00
|
|
|
type=u'user',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to create duplicate %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
type=u'user',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
),
|
2013-11-13 09:31:58 -06:00
|
|
|
expected=errors.DuplicateEntry(
|
|
|
|
message='permission with name "%s" already exists' % permission1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % privilege1,
|
|
|
|
command=('privilege_add', [privilege1],
|
|
|
|
dict(description=u'privilege desc. 1')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=privilege1,
|
|
|
|
summary=u'Added privilege "%s"' % privilege1,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=privilege1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[privilege1],
|
|
|
|
description=[u'privilege desc. 1'],
|
|
|
|
objectclass=objectclasses.privilege,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Add permission %r to privilege %r' % (permission1, privilege1),
|
|
|
|
command=('privilege_add_permission', [privilege1],
|
|
|
|
dict(permission=permission1)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
completed=1,
|
|
|
|
failed=dict(
|
|
|
|
member=dict(
|
|
|
|
permission=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
result={
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': privilege1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [privilege1],
|
|
|
|
'description': [u'privilege desc. 1'],
|
|
|
|
'memberof_permission': [permission1],
|
2012-11-15 20:38:26 -06:00
|
|
|
'objectclass': objectclasses.privilege,
|
2010-12-01 10:23:52 -06:00
|
|
|
}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r' % permission1,
|
|
|
|
command=('permission_show', [permission1], {}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result={
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2010-12-01 10:23:52 -06:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-02-02 14:28:15 -06:00
|
|
|
dict(
|
|
|
|
desc='Retrieve %r with --raw' % permission1,
|
2013-11-13 09:31:58 -06:00
|
|
|
command=('permission_show', [permission1], {'raw': True}),
|
2012-02-02 14:28:15 -06:00
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result={
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2012-02-02 14:28:15 -06:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'member': [privilege1_dn],
|
2013-09-13 09:08:22 -05:00
|
|
|
'ipapermincludedattr': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermright': [u'write'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
'ipapermtargetfilter': [u'(objectclass=posixaccount)'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'aci': ['(targetattr = "sn")'
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-11-13 09:31:58 -06:00
|
|
|
'(version 3.0;acl "permission:%(name)s";'
|
|
|
|
'allow (write) groupdn = "ldap:///%(pdn)s";)' %
|
|
|
|
{'tdn': DN(('uid', '*'), users_dn),
|
|
|
|
'name': permission1,
|
|
|
|
'pdn': permission1_dn}],
|
2012-02-02 14:28:15 -06:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
dict(
|
|
|
|
desc='Search for %r' % permission1,
|
|
|
|
command=('permission_find', [permission1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2010-12-01 10:23:52 -06:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-05-11 14:28:03 -05:00
|
|
|
dict(
|
|
|
|
desc='Search for %r using --name' % permission1,
|
|
|
|
command=('permission_find', [], {'cn': permission1}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2012-05-11 14:28:03 -05:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2012-05-11 14:28:03 -05:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2012-05-11 14:28:03 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
2013-11-13 09:31:58 -06:00
|
|
|
desc='Search for non-existent permission using --name',
|
2012-05-11 14:28:03 -05:00
|
|
|
command=('permission_find', [], {'cn': u'notfound'}),
|
|
|
|
expected=dict(
|
|
|
|
count=0,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'0 permissions matched',
|
|
|
|
result=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
dict(
|
|
|
|
desc='Search for %r' % privilege1,
|
|
|
|
command=('permission_find', [privilege1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2010-12-01 10:23:52 -06:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-02-02 14:28:15 -06:00
|
|
|
dict(
|
|
|
|
desc='Search for %r with --raw' % permission1,
|
2013-11-13 09:31:58 -06:00
|
|
|
command=('permission_find', [permission1], {'raw': True}),
|
2012-02-02 14:28:15 -06:00
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2012-02-02 14:28:15 -06:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'member': [privilege1_dn],
|
2013-09-13 09:08:22 -05:00
|
|
|
'ipapermincludedattr': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermright': [u'write'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
'ipapermtargetfilter': [u'(objectclass=posixaccount)'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'aci': ['(targetattr = "sn")'
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-11-13 09:31:58 -06:00
|
|
|
'(version 3.0;acl "permission:%(name)s";'
|
|
|
|
'allow (write) groupdn = "ldap:///%(pdn)s";)' %
|
|
|
|
{'tdn': DN(('uid', '*'), users_dn),
|
|
|
|
'name': permission1,
|
|
|
|
'pdn': permission1_dn}],
|
2012-02-02 14:28:15 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
dict(
|
|
|
|
desc='Create %r' % permission2,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission2], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
type=u'user',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'write',
|
2013-09-25 08:46:11 -05:00
|
|
|
setattr=u'owner=cn=test',
|
|
|
|
addattr=u'owner=cn=test2',
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'cn'],
|
2010-12-01 10:23:52 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission2,
|
|
|
|
summary=u'Added permission "%s"' % permission2,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=permission2_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[permission2],
|
|
|
|
objectclass=objectclasses.permission,
|
2013-11-13 09:31:58 -06:00
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
2012-06-29 06:24:14 -05:00
|
|
|
owner=[u'cn=test', u'cn=test2'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'cn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission2, users_dn,
|
|
|
|
'(targetattr = "cn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission2 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission2_dn,
|
|
|
|
),
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
dict(
|
|
|
|
desc='Search for %r' % permission1,
|
|
|
|
command=('permission_find', [permission1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=2,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'2 permissions matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2010-12-01 10:23:52 -06:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
},
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission2_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [permission2],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'cn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-01-16 04:14:59 -06:00
|
|
|
dict(
|
|
|
|
desc='Search for %r with --pkey-only' % permission1,
|
|
|
|
command=('permission_find', [permission1], {'pkey_only' : True}),
|
|
|
|
expected=dict(
|
|
|
|
count=2,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'2 permissions matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2012-01-16 04:14:59 -06:00
|
|
|
'cn': [permission1],
|
|
|
|
},
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission2_dn,
|
2012-01-16 04:14:59 -06:00
|
|
|
'cn': [permission2],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-05-31 05:39:24 -05:00
|
|
|
dict(
|
|
|
|
desc='Search by ACI attribute with --pkey-only',
|
|
|
|
command=('permission_find', [], {'pkey_only': True,
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'krbminpwdlife']}),
|
2012-05-31 05:39:24 -05:00
|
|
|
expected=dict(
|
2014-04-14 13:51:29 -05:00
|
|
|
count=2,
|
2012-05-31 05:39:24 -05:00
|
|
|
truncated=False,
|
2014-04-14 13:51:29 -05:00
|
|
|
summary=u'2 permissions matched',
|
2012-05-31 05:39:24 -05:00
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': DN(('cn','Modify Group Password Policy'),
|
|
|
|
api.env.container_permission, api.env.basedn),
|
2012-05-31 05:39:24 -05:00
|
|
|
'cn': [u'Modify Group Password Policy'],
|
|
|
|
},
|
2014-04-14 13:51:29 -05:00
|
|
|
{
|
|
|
|
'dn': DN(('cn', 'System: Read Group Password Policy'),
|
|
|
|
api.env.container_permission, api.env.basedn),
|
|
|
|
'cn': [u'System: Read Group Password Policy'],
|
|
|
|
},
|
2012-05-31 05:39:24 -05:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
dict(
|
|
|
|
desc='Search for %r' % privilege1,
|
|
|
|
command=('privilege_find', [privilege1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 privilege matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': privilege1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [privilege1],
|
|
|
|
'description': [u'privilege desc. 1'],
|
|
|
|
'memberof_permission': [permission1],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-05-23 10:00:24 -05:00
|
|
|
dict(
|
|
|
|
desc='Search for %r with a limit of 1 (truncated)' % permission1,
|
|
|
|
command=('permission_find', [permission1], dict(sizelimit=1)),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=True,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2012-05-23 10:00:24 -05:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2012-05-23 10:00:24 -05:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2012-05-23 10:00:24 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r with a limit of 2' % permission1,
|
|
|
|
command=('permission_find', [permission1], dict(sizelimit=2)),
|
|
|
|
expected=dict(
|
|
|
|
count=2,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'2 permissions matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2012-05-23 10:00:24 -05:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2012-05-23 10:00:24 -05:00
|
|
|
'member_privilege': [privilege1],
|
|
|
|
},
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission2_dn,
|
2012-05-23 10:00:24 -05:00
|
|
|
'cn': [permission2],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'cn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2012-05-23 10:00:24 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
# This tests setting truncated to True in the post_callback of
|
|
|
|
# permission_find(). The return order in LDAP is not guaranteed
|
2014-02-21 05:29:39 -06:00
|
|
|
# so do not check the actual entry.
|
2012-05-23 10:00:24 -05:00
|
|
|
dict(
|
|
|
|
desc='Search for permissions by attr with a limit of 1 (truncated)',
|
2014-02-21 05:29:39 -06:00
|
|
|
command=('permission_find', [u'Modify'],
|
|
|
|
dict(attrs=u'ipaenabledflag', sizelimit=1)),
|
2012-05-23 10:00:24 -05:00
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=True,
|
|
|
|
summary=u'1 permission matched',
|
2014-02-21 05:29:39 -06:00
|
|
|
result=[lambda res:
|
|
|
|
DN(res['dn']).endswith(DN(api.env.container_permission,
|
|
|
|
api.env.basedn)) and
|
|
|
|
'ipapermission' in res['objectclass']],
|
2012-05-23 10:00:24 -05:00
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
dict(
|
|
|
|
desc='Update %r' % permission1,
|
|
|
|
command=(
|
2012-06-29 06:24:14 -05:00
|
|
|
'permission_mod', [permission1], dict(
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'read',
|
2012-06-29 06:24:14 -05:00
|
|
|
memberof=u'ipausers',
|
|
|
|
setattr=u'owner=cn=other-test',
|
|
|
|
addattr=u'owner=cn=other-test2',
|
|
|
|
)
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=permission1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
cn=[permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
objectclass=objectclasses.permission,
|
2010-12-01 10:23:52 -06:00
|
|
|
member_privilege=[privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'read'],
|
|
|
|
memberof=[u'ipausers'],
|
2012-06-29 06:24:14 -05:00
|
|
|
owner=[u'cn=other-test', u'cn=other-test2'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(memberOf=%s)' % DN('cn=ipausers', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (read) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2010-12-01 10:23:52 -06:00
|
|
|
dict(
|
|
|
|
desc='Retrieve %r to verify update' % permission1,
|
|
|
|
command=('permission_show', [permission1], {}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result={
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2010-12-01 10:23:52 -06:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2010-12-01 10:23:52 -06:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'read'],
|
|
|
|
'memberof': [u'ipausers'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2010-12-01 10:23:52 -06:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
2011-01-27 05:17:10 -06:00
|
|
|
desc='Try to rename %r to existing permission %r' % (permission1,
|
|
|
|
permission2),
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(rename=permission2,
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'all',)
|
2011-01-27 05:17:10 -06:00
|
|
|
),
|
|
|
|
expected=errors.DuplicateEntry(),
|
|
|
|
),
|
|
|
|
|
2012-04-11 02:37:15 -05:00
|
|
|
dict(
|
|
|
|
desc='Try to rename %r to empty name' % (permission1),
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(rename=u'',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'all',)
|
2012-04-11 02:37:15 -05:00
|
|
|
),
|
2012-04-17 03:26:20 -05:00
|
|
|
expected=errors.ValidationError(name='rename',
|
2012-04-11 02:37:15 -05:00
|
|
|
error=u'New name can not be empty'),
|
|
|
|
),
|
|
|
|
|
2011-01-27 05:17:10 -06:00
|
|
|
dict(
|
|
|
|
desc='Check integrity of original permission %r' % permission1,
|
|
|
|
command=('permission_show', [permission1], {}),
|
2010-12-01 10:23:52 -06:00
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
2011-01-27 05:17:10 -06:00
|
|
|
summary=None,
|
|
|
|
result={
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_dn,
|
2011-01-27 05:17:10 -06:00
|
|
|
'cn': [permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2011-01-27 05:17:10 -06:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'read'],
|
|
|
|
'memberof': [u'ipausers'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2011-01-27 05:17:10 -06:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Rename %r to permission %r' % (permission1,
|
|
|
|
permission1_renamed),
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(rename=permission1_renamed,
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright= u'all',)
|
2011-01-27 05:17:10 -06:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result={
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_renamed_dn,
|
2011-01-27 05:17:10 -06:00
|
|
|
'cn': [permission1_renamed],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2011-01-27 05:17:10 -06:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'all'],
|
|
|
|
'memberof': [u'ipausers'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2011-01-27 05:17:10 -06:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci_missing(permission1, users_dn),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1_renamed, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(memberOf=%s)' % DN('cn=ipausers', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1_renamed +
|
|
|
|
'allow (all) groupdn = "ldap:///%s";)' % permission1_renamed_dn,
|
|
|
|
),
|
|
|
|
|
2011-01-27 05:17:10 -06:00
|
|
|
|
|
|
|
dict(
|
2012-04-11 02:37:15 -05:00
|
|
|
desc='Rename %r to permission %r' % (permission1_renamed,
|
|
|
|
permission1_renamed_ucase),
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1_renamed], dict(rename=permission1_renamed_ucase,
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright= u'write',)
|
2012-04-11 02:37:15 -05:00
|
|
|
),
|
2011-01-27 05:17:10 -06:00
|
|
|
expected=dict(
|
|
|
|
value=permission1_renamed,
|
2012-04-11 02:37:15 -05:00
|
|
|
summary=u'Modified permission "%s"' % permission1_renamed,
|
|
|
|
result={
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn': permission1_renamed_ucase_dn,
|
2012-06-19 07:49:19 -05:00
|
|
|
'cn': [permission1_renamed_ucase],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2012-04-11 02:37:15 -05:00
|
|
|
'member_privilege': [privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
'type': [u'user'],
|
|
|
|
'ipapermright': [u'write'],
|
|
|
|
'memberof': [u'ipausers'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
2012-04-11 02:37:15 -05:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci_missing(permission1_renamed, users_dn),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1_renamed_ucase, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(memberOf=%s)' % DN('cn=ipausers', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1_renamed_ucase +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' %
|
|
|
|
permission1_renamed_ucase_dn,
|
|
|
|
),
|
2012-04-11 02:37:15 -05:00
|
|
|
|
2012-05-11 15:15:58 -05:00
|
|
|
dict(
|
|
|
|
desc='Change %r to a subtree type' % permission1_renamed_ucase,
|
|
|
|
command=(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'permission_mod', [permission1_renamed_ucase],
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(ipapermlocation=users_dn, type=None)
|
2012-05-11 15:15:58 -05:00
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1_renamed_ucase,
|
|
|
|
summary=u'Modified permission "%s"' % permission1_renamed_ucase,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=permission1_renamed_ucase_dn,
|
2012-06-19 07:49:19 -05:00
|
|
|
cn=[permission1_renamed_ucase],
|
2013-11-13 09:31:58 -06:00
|
|
|
objectclass=objectclasses.permission,
|
2012-05-11 15:15:58 -05:00
|
|
|
member_privilege=[privilege1],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
memberof=[u'ipausers'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
2012-05-11 15:15:58 -05:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1_renamed_ucase, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(memberOf=%s)")' % DN('cn=ipausers', groups_dn) +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1_renamed_ucase +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' %
|
|
|
|
permission1_renamed_ucase_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Reset --subtree of %r' % permission2,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission2],
|
|
|
|
dict(ipapermlocation=api.env.basedn)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission2,
|
|
|
|
summary=u'Modified permission "%s"' % permission2,
|
|
|
|
result={
|
|
|
|
'dn': permission2_dn,
|
|
|
|
'cn': [permission2],
|
|
|
|
'objectclass': objectclasses.permission,
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'cn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
2014-03-04 05:45:24 -06:00
|
|
|
'extratargetfilter': [u'(objectclass=posixaccount)'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermlocation': [api.env.basedn],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2012-05-11 15:15:58 -05:00
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission2, api.env.basedn,
|
|
|
|
'(targetattr = "cn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission2 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission2_dn,
|
|
|
|
),
|
|
|
|
|
2014-03-26 11:11:23 -05:00
|
|
|
dict(
|
|
|
|
desc='Change subtree of %r to admin' % permission1_renamed_ucase,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1_renamed_ucase],
|
|
|
|
dict(ipapermlocation=admin_dn)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1_renamed_ucase,
|
|
|
|
summary=u'Modified permission "%s"' % permission1_renamed_ucase,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_renamed_ucase_dn,
|
|
|
|
cn=[permission1_renamed_ucase],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
member_privilege=[privilege1],
|
|
|
|
ipapermlocation=[admin_dn],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
memberof=[u'ipausers'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1_renamed_ucase, admin_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(memberOf=%s)")' % DN('cn=ipausers', groups_dn) +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1_renamed_ucase +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' %
|
|
|
|
permission1_renamed_ucase_dn,
|
|
|
|
),
|
|
|
|
|
2012-05-11 15:15:58 -05:00
|
|
|
dict(
|
2014-03-04 05:45:24 -06:00
|
|
|
desc='Search for %r using --subtree' % permission1_renamed_ucase,
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
command=('permission_find', [],
|
2014-03-26 11:11:23 -05:00
|
|
|
{'ipapermlocation': u'ldap:///%s' % admin_dn}),
|
2012-05-11 15:15:58 -05:00
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[
|
|
|
|
{
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
'dn':permission1_renamed_ucase_dn,
|
2012-06-19 07:49:19 -05:00
|
|
|
'cn':[permission1_renamed_ucase],
|
2013-11-13 09:31:58 -06:00
|
|
|
'objectclass': objectclasses.permission,
|
2012-05-11 15:15:58 -05:00
|
|
|
'member_privilege':[privilege1],
|
2014-03-26 11:11:23 -05:00
|
|
|
'ipapermlocation': [admin_dn],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermright':[u'write'],
|
|
|
|
'memberof':[u'ipausers'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
2012-05-11 15:15:58 -05:00
|
|
|
},
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-04-17 11:42:35 -05:00
|
|
|
dict(
|
|
|
|
desc='Search using nonexistent --subtree',
|
2013-11-13 09:31:58 -06:00
|
|
|
command=('permission_find', [], {'ipapermlocation': u'foo'}),
|
|
|
|
expected=errors.ConversionError(
|
|
|
|
name='subtree', error='malformed RDN string = "foo"'),
|
2012-04-17 11:42:35 -05:00
|
|
|
),
|
|
|
|
|
|
|
|
|
2013-01-10 05:13:39 -06:00
|
|
|
dict(
|
|
|
|
desc='Search using --targetgroup',
|
|
|
|
command=('permission_find', [], {'targetgroup': u'ipausers'}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[
|
|
|
|
{
|
|
|
|
'dn': DN(('cn','Add user to default group'),
|
|
|
|
api.env.container_permission, api.env.basedn),
|
|
|
|
'cn': [u'Add user to default group'],
|
2014-03-17 09:53:06 -05:00
|
|
|
'objectclass': objectclasses.system_permission,
|
2013-01-10 05:13:39 -06:00
|
|
|
'member_privilege': [u'User Administrators'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'member'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'targetgroup': [u'ipausers'],
|
2013-04-12 09:21:57 -05:00
|
|
|
'memberindirect_role': [u'User Administrator'],
|
2013-11-13 09:31:58 -06:00
|
|
|
'ipapermright': [u'write'],
|
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermtarget': [DN(
|
|
|
|
'cn=ipausers', api.env.container_group,
|
|
|
|
api.env.basedn)],
|
|
|
|
'ipapermlocation': [api.env.basedn],
|
2013-01-10 05:13:39 -06:00
|
|
|
}
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
2012-04-11 02:37:15 -05:00
|
|
|
dict(
|
|
|
|
desc='Delete %r' % permission1_renamed_ucase,
|
|
|
|
command=('permission_del', [permission1_renamed_ucase], {}),
|
|
|
|
expected=dict(
|
2014-03-27 08:04:00 -05:00
|
|
|
result=dict(failed=[]),
|
|
|
|
value=[permission1_renamed_ucase],
|
2012-04-11 02:37:15 -05:00
|
|
|
summary=u'Deleted permission "%s"' % permission1_renamed_ucase,
|
2010-12-01 10:23:52 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci_missing(permission1_renamed_ucase, users_dn),
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to delete non-existent %r' % permission1,
|
|
|
|
command=('permission_del', [permission1], {}),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(
|
|
|
|
reason=u'%s: permission not found' % permission1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to retrieve non-existent %r' % permission1,
|
|
|
|
command=('permission_show', [permission1], {}),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(
|
|
|
|
reason=u'%s: permission not found' % permission1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to update non-existent %r' % permission1,
|
2011-02-01 05:31:54 -06:00
|
|
|
command=('permission_mod', [permission1], dict(rename=u'Foo')),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(
|
|
|
|
reason=u'%s: permission not found' % permission1),
|
2010-12-01 10:23:52 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r' % permission2,
|
|
|
|
command=('permission_del', [permission2], {}),
|
|
|
|
expected=dict(
|
2014-03-27 08:04:00 -05:00
|
|
|
result=dict(failed=[]),
|
|
|
|
value=[permission2],
|
2010-12-01 10:23:52 -06:00
|
|
|
summary=u'Deleted permission "%s"' % permission2,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci_missing(permission2, users_dn),
|
2010-12-01 10:23:52 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r' % permission1,
|
|
|
|
command=('permission_find', [permission1], {}),
|
|
|
|
expected=dict(
|
|
|
|
count=0,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'0 permissions matched',
|
|
|
|
result=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r' % privilege1,
|
|
|
|
command=('privilege_del', [privilege1], {}),
|
|
|
|
expected=dict(
|
2014-03-27 08:04:00 -05:00
|
|
|
result=dict(failed=[]),
|
|
|
|
value=[privilege1],
|
2010-12-01 10:23:52 -06:00
|
|
|
summary=u'Deleted privilege "%s"' % privilege1,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2012-02-07 06:07:09 -06:00
|
|
|
dict(
|
|
|
|
desc='Try to create permission %r with non-existing memberof' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
memberof=u'nonexisting',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'write',
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'cn'],
|
2012-02-07 06:07:09 -06:00
|
|
|
)
|
|
|
|
),
|
2012-03-27 08:27:11 -05:00
|
|
|
expected=errors.NotFound(reason=u'nonexisting: group not found'),
|
2012-02-07 06:07:09 -06:00
|
|
|
),
|
2011-12-06 17:15:41 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create memberof permission %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
memberof=u'editors',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'write',
|
2013-09-25 08:46:11 -05:00
|
|
|
type=u'user',
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2011-12-06 17:15:41 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=permission1_dn,
|
2011-12-06 17:15:41 -06:00
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
2013-11-13 09:31:58 -06:00
|
|
|
memberof=[u'editors'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
type=[u'user'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2012-02-07 06:07:09 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&(memberOf=%s)' % DN('cn=editors', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2012-02-07 06:07:09 -06:00
|
|
|
dict(
|
|
|
|
desc='Try to update non-existent memberof of %r' % permission1,
|
2012-03-27 08:27:11 -05:00
|
|
|
command=('permission_mod', [permission1], dict(
|
|
|
|
memberof=u'nonexisting')),
|
|
|
|
expected=errors.NotFound(reason=u'nonexisting: group not found'),
|
2012-02-07 06:07:09 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Update memberof permission %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
memberof=u'admins',
|
2012-02-07 06:07:09 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=permission1_dn,
|
2012-02-07 06:07:09 -06:00
|
|
|
cn=[permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
memberof=[u'admins'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
type=[u'user'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2012-02-07 06:07:09 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2012-02-07 06:07:09 -06:00
|
|
|
dict(
|
|
|
|
desc='Unset memberof of permission %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
memberof=None,
|
2012-02-07 06:07:09 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
value=permission1,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=permission1_dn,
|
2012-02-07 06:07:09 -06:00
|
|
|
cn=[permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
type=[u'user'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2011-12-06 17:15:41 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
2011-12-06 17:15:41 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r' % permission1,
|
|
|
|
command=('permission_del', [permission1], {}),
|
|
|
|
expected=dict(
|
2014-03-27 08:04:00 -05:00
|
|
|
result=dict(failed=[]),
|
|
|
|
value=[permission1],
|
2011-12-06 17:15:41 -06:00
|
|
|
summary=u'Deleted permission "%s"' % permission1,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci_missing(permission1, users_dn),
|
2011-12-06 17:15:41 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create targetgroup permission %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
targetgroup=u'editors',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'write',
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2011-12-06 17:15:41 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
Use DN objects instead of strings
* Convert every string specifying a DN into a DN object
* Every place a dn was manipulated in some fashion it was replaced by
the use of DN operators
* Add new DNParam parameter type for parameters which are DN's
* DN objects are used 100% of the time throughout the entire data
pipeline whenever something is logically a dn.
* Many classes now enforce DN usage for their attributes which are
dn's. This is implmented via ipautil.dn_attribute_property(). The
only permitted types for a class attribute specified to be a DN are
either None or a DN object.
* Require that every place a dn is used it must be a DN object.
This translates into lot of::
assert isinstance(dn, DN)
sprinkled through out the code. Maintaining these asserts is
valuable to preserve DN type enforcement. The asserts can be
disabled in production.
The goal of 100% DN usage 100% of the time has been realized, these
asserts are meant to preserve that.
The asserts also proved valuable in detecting functions which did
not obey their function signatures, such as the baseldap pre and
post callbacks.
* Moved ipalib.dn to ipapython.dn because DN class is shared with all
components, not just the server which uses ipalib.
* All API's now accept DN's natively, no need to convert to str (or
unicode).
* Removed ipalib.encoder and encode/decode decorators. Type conversion
is now explicitly performed in each IPASimpleLDAPObject method which
emulates a ldap.SimpleLDAPObject method.
* Entity & Entry classes now utilize DN's
* Removed __getattr__ in Entity & Entity clases. There were two
problems with it. It presented synthetic Python object attributes
based on the current LDAP data it contained. There is no way to
validate synthetic attributes using code checkers, you can't search
the code to find LDAP attribute accesses (because synthetic
attriutes look like Python attributes instead of LDAP data) and
error handling is circumscribed. Secondly __getattr__ was hiding
Python internal methods which broke class semantics.
* Replace use of methods inherited from ldap.SimpleLDAPObject via
IPAdmin class with IPAdmin methods. Directly using inherited methods
was causing us to bypass IPA logic. Mostly this meant replacing the
use of search_s() with getEntry() or getList(). Similarly direct
access of the LDAP data in classes using IPAdmin were replaced with
calls to getValue() or getValues().
* Objects returned by ldap2.find_entries() are now compatible with
either the python-ldap access methodology or the Entity/Entry access
methodology.
* All ldap operations now funnel through the common
IPASimpleLDAPObject giving us a single location where we interface
to python-ldap and perform conversions.
* The above 4 modifications means we've greatly reduced the
proliferation of multiple inconsistent ways to perform LDAP
operations. We are well on the way to having a single API in IPA for
doing LDAP (a long range goal).
* All certificate subject bases are now DN's
* DN objects were enhanced thusly:
- find, rfind, index, rindex, replace and insert methods were added
- AVA, RDN and DN classes were refactored in immutable and mutable
variants, the mutable variants are EditableAVA, EditableRDN and
EditableDN. By default we use the immutable variants preserving
important semantics. To edit a DN cast it to an EditableDN and
cast it back to DN when done editing. These issues are fully
described in other documentation.
- first_key_match was removed
- DN equalty comparison permits comparison to a basestring
* Fixed ldapupdate to work with DN's. This work included:
- Enhance test_updates.py to do more checking after applying
update. Add test for update_from_dict(). Convert code to use
unittest classes.
- Consolidated duplicate code.
- Moved code which should have been in the class into the class.
- Fix the handling of the 'deleteentry' update action. It's no longer
necessary to supply fake attributes to make it work. Detect case
where subsequent update applies a change to entry previously marked
for deletetion. General clean-up and simplification of the
'deleteentry' logic.
- Rewrote a couple of functions to be clearer and more Pythonic.
- Added documentation on the data structure being used.
- Simplfy the use of update_from_dict()
* Removed all usage of get_schema() which was being called prior to
accessing the .schema attribute of an object. If a class is using
internal lazy loading as an optimization it's not right to require
users of the interface to be aware of internal
optimization's. schema is now a property and when the schema
property is accessed it calls a private internal method to perform
the lazy loading.
* Added SchemaCache class to cache the schema's from individual
servers. This was done because of the observation we talk to
different LDAP servers, each of which may have it's own
schema. Previously we globally cached the schema from the first
server we connected to and returned that schema in all contexts. The
cache includes controls to invalidate it thus forcing a schema
refresh.
* Schema caching is now senstive to the run time context. During
install and upgrade the schema can change leading to errors due to
out-of-date cached schema. The schema cache is refreshed in these
contexts.
* We are aware of the LDAP syntax of all LDAP attributes. Every
attribute returned from an LDAP operation is passed through a
central table look-up based on it's LDAP syntax. The table key is
the LDAP syntax it's value is a Python callable that returns a
Python object matching the LDAP syntax. There are a handful of LDAP
attributes whose syntax is historically incorrect
(e.g. DistguishedNames that are defined as DirectoryStrings). The
table driven conversion mechanism is augmented with a table of
hard coded exceptions.
Currently only the following conversions occur via the table:
- dn's are converted to DN objects
- binary objects are converted to Python str objects (IPA
convention).
- everything else is converted to unicode using UTF-8 decoding (IPA
convention).
However, now that the table driven conversion mechanism is in place
it would be trivial to do things such as converting attributes
which have LDAP integer syntax into a Python integer, etc.
* Expected values in the unit tests which are a DN no longer need to
use lambda expressions to promote the returned value to a DN for
equality comparison. The return value is automatically promoted to
a DN. The lambda expressions have been removed making the code much
simpler and easier to read.
* Add class level logging to a number of classes which did not support
logging, less need for use of root_logger.
* Remove ipaserver/conn.py, it was unused.
* Consolidated duplicate code wherever it was found.
* Fixed many places that used string concatenation to form a new
string rather than string formatting operators. This is necessary
because string formatting converts it's arguments to a string prior
to building the result string. You can't concatenate a string and a
non-string.
* Simplify logic in rename_managed plugin. Use DN operators to edit
dn's.
* The live version of ipa-ldap-updater did not generate a log file.
The offline version did, now both do.
https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-05-13 06:36:35 -05:00
|
|
|
dn=permission1_dn,
|
2011-12-06 17:15:41 -06:00
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
2013-11-13 09:31:58 -06:00
|
|
|
targetgroup=[u'editors'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermtarget=[DN(('cn', 'editors'), groups_dn)],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
2011-12-06 17:15:41 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(target = "ldap:///%s")' % DN('cn=editors', groups_dn) +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2012-08-22 09:39:01 -05:00
|
|
|
dict(
|
|
|
|
desc='Create %r' % permission3,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission3], dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
type=u'user',
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=u'write',
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'cn']
|
2012-08-22 09:39:01 -05:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission3,
|
|
|
|
summary=u'Added permission "%s"' % permission3,
|
|
|
|
result=dict(
|
|
|
|
dn=permission3_dn,
|
|
|
|
cn=[permission3],
|
|
|
|
objectclass=objectclasses.permission,
|
2013-11-13 09:31:58 -06:00
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=(u'cn',),
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2012-08-22 09:39:01 -05:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission3, users_dn,
|
|
|
|
'(targetattr = "cn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission3 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission3_dn,
|
|
|
|
),
|
|
|
|
|
2012-08-22 09:39:01 -05:00
|
|
|
dict(
|
|
|
|
desc='Retrieve %r with --all --rights' % permission3,
|
|
|
|
command=('permission_show', [permission3], {'all' : True, 'rights' : True}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission3,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
dn=permission3_dn,
|
2012-08-22 09:39:01 -05:00
|
|
|
cn=[permission3],
|
|
|
|
objectclass=objectclasses.permission,
|
2013-11-13 09:31:58 -06:00
|
|
|
type=[u'user'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'cn'],
|
|
|
|
ipapermincludedattr=[u'cn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=[u'write'],
|
|
|
|
attributelevelrights=permission3_attributelevelrights,
|
|
|
|
ipapermbindruletype=[u'permission'],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2012-08-22 09:39:01 -05:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
2013-11-13 09:31:58 -06:00
|
|
|
desc='Modify %r with --all --rights' % permission3,
|
|
|
|
command=('permission_mod', [permission3], {
|
|
|
|
'all': True, 'rights': True,
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'cn', u'uid']}),
|
2012-08-22 09:39:01 -05:00
|
|
|
expected=dict(
|
|
|
|
value=permission3,
|
|
|
|
summary=u'Modified permission "%s"' % permission3,
|
|
|
|
result=dict(
|
2013-09-25 08:46:11 -05:00
|
|
|
dn=permission3_dn,
|
2012-08-22 09:39:01 -05:00
|
|
|
cn=[permission3],
|
|
|
|
objectclass=objectclasses.permission,
|
2013-11-13 09:31:58 -06:00
|
|
|
type=[u'user'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'cn', u'uid'],
|
|
|
|
ipapermincludedattr=[u'cn', u'uid'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=[u'write'],
|
2012-08-22 09:39:01 -05:00
|
|
|
attributelevelrights=permission3_attributelevelrights,
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission3, users_dn,
|
|
|
|
'(targetattr = "cn || uid")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission3 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission3_dn,
|
|
|
|
),
|
|
|
|
|
2014-01-06 08:51:20 -06:00
|
|
|
dict(
|
|
|
|
desc='Try to modify %r with naked targetfilter' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'ipapermtargetfilter': u"cn=admin"}),
|
|
|
|
expected=errors.ValidationError(
|
2014-03-06 07:37:20 -06:00
|
|
|
name='rawfilter',
|
2014-01-06 08:51:20 -06:00
|
|
|
error='must be enclosed in parentheses'),
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Try to modify %r with invalid targetfilter' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
2014-01-06 08:51:20 -06:00
|
|
|
{'ipapermtargetfilter': u"(ceci n'est pas un filtre)"}),
|
2013-11-13 09:31:58 -06:00
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='ipapermtargetfilter',
|
|
|
|
error='Bad search filter'),
|
|
|
|
),
|
2013-12-05 11:18:32 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try setting nonexisting location on %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermlocation=nonexistent_dn,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='ipapermlocation',
|
|
|
|
error='Entry %s does not exist' % nonexistent_dn)
|
|
|
|
),
|
2014-02-25 10:24:02 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for nonexisting permission with ":" in the name',
|
|
|
|
command=(
|
|
|
|
'permission_find', ['doesnotexist:' + permission1], {}
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
count=0,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'0 permissions matched',
|
|
|
|
result=[],
|
|
|
|
),
|
|
|
|
),
|
2013-11-13 09:31:58 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2013-12-05 11:10:02 -06:00
|
|
|
class test_permission_rollback(Declarative):
|
|
|
|
"""Test rolling back changes after failed update"""
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
|
|
|
]
|
|
|
|
|
|
|
|
_verifications = [
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r' % permission1,
|
|
|
|
command=('permission_show', [permission1], {}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result={
|
|
|
|
'dn': permission1_dn,
|
|
|
|
'cn': [permission1],
|
|
|
|
'objectclass': objectclasses.permission,
|
|
|
|
'ipapermright': [u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
'attrs': [u'sn'],
|
2013-12-05 11:10:02 -06:00
|
|
|
'ipapermbindruletype': [u'permission'],
|
|
|
|
'ipapermissiontype': [u'SYSTEM', u'V2'],
|
|
|
|
'ipapermlocation': [users_dn],
|
|
|
|
'ipapermtarget': [DN(('uid', 'admin'), users_dn)],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(target = "ldap:///%s")' % DN(('uid', 'admin'), users_dn) +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci_missing(permission1, etc_dn)
|
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
ipapermlocation=users_dn,
|
|
|
|
ipapermtarget=DN('uid=admin', users_dn),
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-12-05 11:10:02 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-12-05 11:10:02 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermtarget=[DN(('uid', 'admin'), users_dn)],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
] + _verifications + [
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Move %r to non-existent DN' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermlocation=DN('foo=bar'),
|
|
|
|
)
|
|
|
|
),
|
2013-12-05 11:18:32 -06:00
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='ipapermlocation',
|
|
|
|
error='Entry foo=bar does not exist'),
|
2013-12-05 11:10:02 -06:00
|
|
|
),
|
|
|
|
|
|
|
|
] + _verifications + [
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Move %r to another DN' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
dict(ipapermlocation=etc_dn)
|
|
|
|
),
|
|
|
|
expected=errors.InvalidSyntax(
|
|
|
|
attr=r'ACL Invalid Target Error(-8): '
|
|
|
|
r'Target is beyond the scope of the ACL'
|
|
|
|
r'(SCOPE:%(sdn)s) '
|
|
|
|
r'(targetattr = \22sn\22)'
|
|
|
|
r'(target = \22ldap:///%(tdn)s\22)'
|
|
|
|
r'(version 3.0;acl \22permission:testperm\22;'
|
|
|
|
r'allow (write) groupdn = \22ldap:///%(pdn)s\22;)' % dict(
|
|
|
|
sdn=etc_dn,
|
|
|
|
tdn=DN('uid=admin', users_dn),
|
|
|
|
pdn=permission1_dn)),
|
|
|
|
),
|
|
|
|
|
2014-03-03 07:46:51 -06:00
|
|
|
] + _verifications + [
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try adding an invalid attribute on %r with --all --rights' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
attrs=[u'cn', u'bogusattributexyz'],
|
|
|
|
rights=True,
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.InvalidSyntax(
|
|
|
|
attr=r'targetattr "bogusattributexyz" does not exist '
|
|
|
|
r'in schema. Please add attributeTypes '
|
|
|
|
r'"bogusattributexyz" to schema if necessary. ACL Syntax '
|
|
|
|
r'Error(-5):(targetattr = \22bogusattributexyz || cn\22)'
|
|
|
|
r'(target = \22ldap:///%(tdn)s\22)'
|
|
|
|
r'(version 3.0;acl \22permission:%(name)s\22;'
|
|
|
|
r'allow (write) groupdn = \22ldap:///%(dn)s\22;)' % dict(
|
|
|
|
tdn=DN('uid=admin', users_dn),
|
|
|
|
name=permission1,
|
|
|
|
dn=permission1_dn),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-12-05 11:10:02 -06:00
|
|
|
] + _verifications
|
|
|
|
|
2014-03-03 07:46:51 -06:00
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
class test_permission_sync_attributes(Declarative):
|
|
|
|
"""Test the effects of setting permission attributes"""
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
ipapermlocation=users_dn,
|
|
|
|
ipapermright=u'write',
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=u'sn',
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
2013-11-13 09:31:58 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")'
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Unset location on %r, verify type is gone' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermlocation=None,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
2014-03-04 05:45:24 -06:00
|
|
|
extratargetfilter=[
|
2014-01-06 08:51:20 -06:00
|
|
|
u'(objectclass=posixaccount)'],
|
2013-11-13 09:31:58 -06:00
|
|
|
memberof=[u'admins'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")'
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2014-01-06 08:51:20 -06:00
|
|
|
verify_permission_aci_missing(permission1, users_dn),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Reset location on %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermlocation=users_dn,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")'
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2014-01-06 08:51:20 -06:00
|
|
|
verify_permission_aci_missing(permission1, api.env.basedn),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
2014-01-06 08:51:20 -06:00
|
|
|
desc='Unset objectclass filter on %r, verify type is gone' % permission1,
|
2013-11-13 09:31:58 -06:00
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=u'(memberOf=%s)' % DN(('cn', 'admins'),
|
|
|
|
groups_dn),
|
2013-11-13 09:31:58 -06:00
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
2012-08-22 09:39:01 -05:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2013-11-13 09:31:58 -06:00
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(memberOf=%s)")' % DN('cn=admins', groups_dn) +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Unset targetfilter on %r, verify memberof is gone' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermtargetfilter=None,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Set type of %r to group' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
type=u'group',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'group'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[groups_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, groups_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=ipausergroup)")'
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Set target on %r, verify targetgroup is set' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermtarget=DN('cn=editors', groups_dn),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
2014-01-06 08:51:20 -06:00
|
|
|
type=[u'group'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermtarget=[DN('cn=editors', groups_dn)],
|
|
|
|
ipapermlocation=[groups_dn],
|
|
|
|
targetgroup=[u'editors'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2013-11-29 05:57:30 -06:00
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, groups_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(target = "ldap:///%s")' % DN(('cn', 'editors'), groups_dn) +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=ipausergroup)")'
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
2013-11-13 09:31:58 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class test_permission_sync_nice(Declarative):
|
|
|
|
"""Test the effects of setting convenience options on permissions"""
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermright=u'write',
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=u'sn',
|
2013-11-13 09:31:58 -06:00
|
|
|
memberof=u'admins',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(&(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount))")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
2014-01-06 08:51:20 -06:00
|
|
|
desc='Unset type on %r, verify target & filter are gone' % permission1,
|
2013-11-13 09:31:58 -06:00
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
type=None,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(memberOf=%s)")' % DN('cn=admins', groups_dn) +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Unset memberof on %r, verify targetfilter is gone' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
memberof=None,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Set type of %r to group' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
type=u'group',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'group'],
|
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[groups_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-29 05:57:30 -06:00
|
|
|
verify_permission_aci(
|
|
|
|
permission1, groups_dn,
|
|
|
|
'(targetattr = "sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=ipausergroup)")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Set targetgroup on %r, verify target is set' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
targetgroup=u'editors',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
2014-01-06 08:51:20 -06:00
|
|
|
type=[u'group'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermright=[u'write'],
|
2013-09-13 09:08:22 -05:00
|
|
|
attrs=[u'sn'],
|
2013-11-13 09:31:58 -06:00
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermtarget=[DN('cn=editors', groups_dn)],
|
|
|
|
ipapermlocation=[groups_dn],
|
|
|
|
targetgroup=[u'editors'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2013-11-29 05:57:30 -06:00
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, groups_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(target = "ldap:///%s")' % DN(('cn', 'editors'), groups_dn) +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=ipausergroup)")' +
|
2013-11-29 05:57:30 -06:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
2013-11-13 09:31:58 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2014-03-06 07:25:36 -06:00
|
|
|
class test_permission_targetfilter(Declarative):
|
|
|
|
"""Test the targetfilter options on permissions"""
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
|
|
|
]
|
|
|
|
|
|
|
|
_initial_aci = (
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(cn=*)' +
|
|
|
|
'(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount)' +
|
|
|
|
'(sn=*)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn
|
|
|
|
)
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermright=u'write',
|
|
|
|
attrs=u'sn',
|
|
|
|
memberof=u'admins',
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(sn=*)'],
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(sn=*)'],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)', u'(sn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(permission1, users_dn, _initial_aci),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_show', [permission1], dict()
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(sn=*)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r with --all' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_show', [permission1], dict(all=True)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(sn=*)'],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)', u'(sn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r with --raw' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_show', [permission1], dict(raw=True)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
aci=[_initial_aci],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)', u'(sn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Retrieve %r with --all and --raw' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_show', [permission1], dict(all=True, raw=True)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
aci=[_initial_aci],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)', u'(sn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Modify extratargetfilter of %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(l=*)'],
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(l=*)'],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)', u'(l=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(cn=*)' +
|
|
|
|
'(l=*)' +
|
|
|
|
'(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Remove raw targetfilter of %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
ipapermtargetfilter=None,
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Set extra targetfilter on %r to restore' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
extratargetfilter=[
|
|
|
|
u'(cn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(cn=*)'],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(cn=*)' +
|
|
|
|
'(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn
|
|
|
|
),
|
|
|
|
|
2014-03-07 11:56:35 -06:00
|
|
|
] + [
|
|
|
|
dict(
|
|
|
|
desc='Search for %r using %s %s' % (permission1, value_name, option_name),
|
|
|
|
command=(
|
|
|
|
'permission_find', [],
|
|
|
|
{option_name: value, 'all': True}
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
summary=u'1 permission matched' if should_find else u'0 permissions matched',
|
|
|
|
truncated=False,
|
|
|
|
count=1 if should_find else 0,
|
|
|
|
result=[dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(cn=*)'],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)'],
|
|
|
|
)] if should_find else [],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
for option_name in (
|
|
|
|
'extratargetfilter',
|
|
|
|
'ipapermtargetfilter',
|
|
|
|
)
|
|
|
|
for value_name, value, should_find in (
|
|
|
|
('"extra"', u'(cn=*)', True),
|
|
|
|
('"non-extra"', u'(objectclass=posixaccount)', True),
|
|
|
|
('non-existing', u'(sn=insert a very improbable last name)', False),
|
|
|
|
)
|
|
|
|
] + [
|
|
|
|
|
2014-03-07 09:29:47 -06:00
|
|
|
dict(
|
|
|
|
desc='Set extra objectclass filter on %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(objectclass=top)'],
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(objectclass=top)'],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=posixaccount)',
|
|
|
|
u'(objectclass=top)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(cn=*)' +
|
|
|
|
'(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=posixaccount)' +
|
|
|
|
'(objectclass=top)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Unset type on %r to verify extra objectclass filter stays' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
type=None,
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(cn=*)', u'(objectclass=top)'],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(cn=*)',
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(objectclass=top)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(cn=*)' +
|
|
|
|
'(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(objectclass=top)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Set wildcard memberof filter on %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
extratargetfilter=u'(memberof=*)',
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
extratargetfilter=[u'(memberof=*)'],
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
u'(memberof=*)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(&' +
|
|
|
|
'(memberOf=%s)' % DN('cn=admins', groups_dn) +
|
|
|
|
'(memberof=*)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Remove --memberof on %r to verify wildcard is still there' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
memberof=[],
|
|
|
|
all=True,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
attrs=[u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
|
|
|
extratargetfilter=[u'(memberof=*)'],
|
|
|
|
ipapermtargetfilter=[u'(memberof=*)'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetattr = "sn")' +
|
|
|
|
'(targetfilter = "(memberof=*)")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn
|
|
|
|
),
|
|
|
|
|
2014-03-06 07:25:36 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
def _make_permission_flag_tests(flags, expected_message):
|
|
|
|
return [
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create %r with flags %s' % (permission1, flags),
|
|
|
|
command=(
|
|
|
|
'permission_add_noaci', [permission1], dict(
|
|
|
|
ipapermissiontype=flags,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.system_permission,
|
|
|
|
ipapermissiontype=flags,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to modify %r' % permission1,
|
|
|
|
command=('permission_mod', [permission1], {'type': u'user'}),
|
|
|
|
expected=errors.ACIError(info=expected_message),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to delete %r' % permission1,
|
|
|
|
command=('permission_del', [permission1], {}),
|
|
|
|
expected=errors.ACIError(info=expected_message),
|
|
|
|
),
|
|
|
|
|
2013-12-13 04:28:22 -06:00
|
|
|
dict(
|
|
|
|
desc='Add %r to %r' % (permission1, privilege1),
|
|
|
|
command=('privilege_add_permission', [privilege1],
|
|
|
|
{'permission': permission1}),
|
|
|
|
expected=dict(
|
|
|
|
completed=1,
|
|
|
|
failed=dict(
|
|
|
|
member=dict(
|
|
|
|
permission=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
result={
|
|
|
|
'dn': privilege1_dn,
|
|
|
|
'cn': [privilege1],
|
|
|
|
'description': [u'privilege desc. 1'],
|
|
|
|
'memberof_permission': [permission1],
|
|
|
|
'objectclass': objectclasses.privilege,
|
|
|
|
}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-11-13 09:31:58 -06:00
|
|
|
dict(
|
|
|
|
desc='Delete %r with --force' % permission1,
|
|
|
|
command=('permission_del', [permission1], {'force': True}),
|
|
|
|
expected=dict(
|
2014-03-27 08:04:00 -05:00
|
|
|
result=dict(failed=[]),
|
|
|
|
value=[permission1],
|
2013-11-13 09:31:58 -06:00
|
|
|
summary=u'Deleted permission "%s"' % permission1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class test_permission_flags(Declarative):
|
|
|
|
"""Test that permission flags are handled correctly"""
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
2013-12-13 04:28:22 -06:00
|
|
|
('privilege_del', [privilege1], {}),
|
2013-11-13 09:31:58 -06:00
|
|
|
]
|
|
|
|
|
2013-12-13 04:28:22 -06:00
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % privilege1,
|
|
|
|
command=('privilege_add', [privilege1],
|
|
|
|
dict(description=u'privilege desc. 1')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=privilege1,
|
|
|
|
summary=u'Added privilege "%s"' % privilege1,
|
|
|
|
result=dict(
|
|
|
|
dn=privilege1_dn,
|
|
|
|
cn=[privilege1],
|
|
|
|
description=[u'privilege desc. 1'],
|
|
|
|
objectclass=objectclasses.privilege,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
] + (
|
2013-11-13 09:31:58 -06:00
|
|
|
_make_permission_flag_tests(
|
|
|
|
[u'SYSTEM'],
|
|
|
|
'A SYSTEM permission may not be modified or removed') +
|
|
|
|
_make_permission_flag_tests(
|
|
|
|
[u'??'],
|
|
|
|
'Permission with unknown flag ?? may not be modified or removed') +
|
|
|
|
_make_permission_flag_tests(
|
|
|
|
[u'SYSTEM', u'??'],
|
|
|
|
'Permission with unknown flag ?? may not be modified or removed'))
|
|
|
|
|
|
|
|
|
|
|
|
class test_permission_legacy(Declarative):
|
|
|
|
"""Tests for non-upgraded permissions"""
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Search for all permissions in $SUFFIX',
|
|
|
|
command=('permission_find', [],
|
|
|
|
{'ipapermlocation': api.env.basedn}),
|
|
|
|
expected=dict(
|
|
|
|
count=lambda n: n > 50,
|
|
|
|
truncated=False,
|
|
|
|
summary=lambda s: True,
|
|
|
|
result=lambda s: True,
|
|
|
|
),
|
|
|
|
),
|
2010-12-01 10:23:52 -06:00
|
|
|
]
|
2013-10-29 11:01:07 -05:00
|
|
|
|
|
|
|
|
|
|
|
class test_permission_bindtype(Declarative):
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
|
|
|
('permission_del', [permission1_renamed], {'force': True}),
|
|
|
|
('privilege_del', [privilege1], {}),
|
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Create anonymous %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermright=u'write',
|
|
|
|
ipapermbindruletype=u'anonymous',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'anonymous'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-10-29 11:01:07 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) userdn = "ldap:///anyone";)',
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create %r' % privilege1,
|
|
|
|
command=('privilege_add', [privilege1],
|
|
|
|
dict(description=u'privilege desc. 1')
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=privilege1,
|
|
|
|
summary=u'Added privilege "%s"' % privilege1,
|
|
|
|
result=dict(
|
|
|
|
dn=privilege1_dn,
|
|
|
|
cn=[privilege1],
|
|
|
|
description=[u'privilege desc. 1'],
|
|
|
|
objectclass=objectclasses.privilege,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to add %r to %r' % (permission1, privilege1),
|
|
|
|
command=(
|
|
|
|
'privilege_add_permission', [privilege1], dict(
|
|
|
|
permission=[permission1],
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='permission',
|
|
|
|
error=u'cannot add permission "%s" with bindtype "%s" to a '
|
|
|
|
'privilege' % (permission1, 'anonymous')),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Change binddn of %r to all' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermbindruletype=u'all',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-10-29 11:01:07 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) userdn = "ldap:///all";)',
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to add %r to %r' % (permission1, privilege1),
|
|
|
|
command=(
|
|
|
|
'privilege_add_permission', [privilege1], dict(
|
|
|
|
permission=[permission1],
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='permission',
|
|
|
|
error=u'cannot add permission "%s" with bindtype "%s" to a '
|
|
|
|
'privilege' % (permission1, 'all')),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r using --bindtype' % permission1,
|
2014-02-21 05:29:39 -06:00
|
|
|
command=('permission_find', [permission1],
|
|
|
|
{'ipapermbindruletype': u'all'}),
|
2013-10-29 11:01:07 -05:00
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[
|
|
|
|
dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2014-02-21 05:29:39 -06:00
|
|
|
dict(
|
|
|
|
desc='Search for %r using bad --bindtype' % permission1,
|
|
|
|
command=('permission_find', [permission1],
|
|
|
|
{'ipapermbindruletype': u'anonymous'}),
|
|
|
|
expected=dict(
|
|
|
|
count=0,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'0 permissions matched',
|
|
|
|
result=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2013-10-29 11:01:07 -05:00
|
|
|
dict(
|
|
|
|
desc='Add zero permissions to %r' % (privilege1),
|
|
|
|
command=('privilege_add_permission', [privilege1], {}),
|
|
|
|
expected=dict(
|
|
|
|
completed=0,
|
|
|
|
failed=dict(member=dict(permission=[])),
|
|
|
|
result=dict(
|
|
|
|
dn=privilege1_dn,
|
|
|
|
cn=[privilege1],
|
|
|
|
description=[u'privilege desc. 1'],
|
|
|
|
objectclass=objectclasses.privilege,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Rename %r to permission %r' % (permission1,
|
|
|
|
permission1_renamed),
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(rename=permission1_renamed)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_renamed_dn,
|
|
|
|
cn=[permission1_renamed],
|
|
|
|
type=[u'user'],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1_renamed, users_dn,
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-10-29 11:01:07 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1_renamed +
|
|
|
|
'allow (write) userdn = "ldap:///all";)',
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Reset binddn of %r to permission' % permission1_renamed,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1_renamed], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermbindruletype=u'permission',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1_renamed,
|
|
|
|
summary=u'Modified permission "%s"' % permission1_renamed,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_renamed_dn,
|
|
|
|
cn=[permission1_renamed],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1_renamed, users_dn,
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-10-29 11:01:07 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1_renamed +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_renamed_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Rename %r back to %r' % (permission1_renamed, permission1),
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1_renamed],
|
|
|
|
dict(rename=permission1)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1_renamed,
|
|
|
|
summary=u'Modified permission "%s"' % permission1_renamed,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
type=[u'user'],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-10-29 11:01:07 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Add %r to %r' % (permission1, privilege1),
|
|
|
|
command=(
|
|
|
|
'privilege_add_permission', [privilege1], dict(
|
|
|
|
permission=[permission1],
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
completed=1,
|
|
|
|
failed=dict(member=dict(permission=[])),
|
|
|
|
result=dict(
|
|
|
|
dn=privilege1_dn,
|
|
|
|
cn=[privilege1],
|
|
|
|
description=[u'privilege desc. 1'],
|
|
|
|
memberof_permission=[permission1],
|
|
|
|
objectclass=objectclasses.privilege,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to change binddn of %r to anonymous' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermbindruletype=u'anonymous',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='ipapermbindruletype',
|
|
|
|
error=u'cannot set bindtype for a permission that is '
|
|
|
|
'assigned to a privilege')
|
|
|
|
),
|
|
|
|
]
|
2013-09-13 09:08:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
class test_managed_permissions(Declarative):
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
|
|
|
('permission_del', [permission2], {'force': True}),
|
|
|
|
]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(test_managed_permissions, cls).setUpClass()
|
|
|
|
|
|
|
|
if not have_ldap2:
|
|
|
|
raise nose.SkipTest('server plugin not available')
|
|
|
|
|
|
|
|
def add_managed_permission(self):
|
|
|
|
"""Add a managed permission and the corresponding ACI"""
|
|
|
|
ldap = ldap2(shared_instance=False)
|
|
|
|
ldap.connect(ccache=krbV.default_context().default_ccache())
|
|
|
|
|
|
|
|
result = api.Command.permission_add(permission1, type=u'user',
|
|
|
|
ipapermright=u'write',
|
|
|
|
attrs=[u'cn'])
|
|
|
|
|
|
|
|
# TODO: This hack relies on the permission internals.
|
|
|
|
# Change as necessary.
|
|
|
|
|
|
|
|
# Add permission DN
|
|
|
|
entry = ldap.get_entry(permission1_dn)
|
|
|
|
entry['ipapermdefaultattr'] = ['l', 'o', 'cn']
|
|
|
|
ldap.update_entry(entry)
|
|
|
|
|
|
|
|
# Update the ACI via the API
|
|
|
|
result = api.Command.permission_mod(permission1,
|
|
|
|
attrs=[u'l', u'o', u'cn'])
|
|
|
|
|
|
|
|
# Set the permission type to MANAGED
|
|
|
|
entry = ldap.get_entry(permission1_dn)
|
|
|
|
entry['ipapermissiontype'].append('MANAGED')
|
|
|
|
ldap.update_entry(entry)
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
add_managed_permission,
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Show pre-created %r' % permission1,
|
|
|
|
command=('permission_show', [permission1], {'all': True}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-09-13 09:08:22 -05:00
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o', u'cn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "cn || l || o")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
] + [
|
|
|
|
# Verify that most permission attributes can't be changed
|
|
|
|
dict(
|
|
|
|
desc='Try to modify %s in %r' % (attr_name, permission1),
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{attr_name: value}),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name=err_attr or attr_name,
|
|
|
|
error='not modifiable on managed permissions'),
|
|
|
|
)
|
|
|
|
for attr_name, err_attr, value in (
|
|
|
|
('ipapermlocation', None, users_dn),
|
|
|
|
('ipapermright', None, u'compare'),
|
|
|
|
('ipapermtarget', None, users_dn),
|
|
|
|
('ipapermtargetfilter', None, u'(ou=engineering)'),
|
|
|
|
|
|
|
|
('memberof', 'ipapermtargetfilter', u'admins'),
|
|
|
|
('targetgroup', 'ipapermtarget', u'admins'),
|
|
|
|
('type', 'ipapermlocation', u'group'),
|
2014-03-06 07:25:36 -06:00
|
|
|
('extratargetfilter', 'extratargetfilter', u'(cn=*)'),
|
2013-09-13 09:08:22 -05:00
|
|
|
)
|
|
|
|
] + [
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to rename %r' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'rename': permission2}),
|
|
|
|
expected=errors.ValidationError(
|
|
|
|
name='rename',
|
|
|
|
error='cannot rename managed permissions'),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "cn || l || o")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Modify included and excluded attrs in %r' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'ipapermincludedattr': [u'dc'],
|
|
|
|
'ipapermexcludedattr': [u'cn'],
|
|
|
|
'all': True}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "testperm"',
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-09-13 09:08:22 -05:00
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o', u'dc'],
|
|
|
|
ipapermincludedattr=[u'dc'],
|
|
|
|
ipapermexcludedattr=[u'cn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "dc || l || o")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Modify included attrs in %r' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'ipapermincludedattr': [u'cn', u'sn'],
|
|
|
|
'all': True}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "testperm"',
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-09-13 09:08:22 -05:00
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o', u'sn'],
|
|
|
|
ipapermincludedattr=[u'cn', u'sn'],
|
|
|
|
ipapermexcludedattr=[u'cn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "l || o || sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Add ineffective included attr to %r' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'ipapermincludedattr': [u'cn', u'sn', u'o'],
|
|
|
|
'all': True}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "testperm"',
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-09-13 09:08:22 -05:00
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o', u'sn'],
|
|
|
|
ipapermincludedattr=[u'cn', u'sn', u'o'],
|
|
|
|
ipapermexcludedattr=[u'cn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "l || o || sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Modify excluded attrs in %r' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'ipapermexcludedattr': [u'cn', u'sn'],
|
|
|
|
'all': True}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "testperm"',
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-09-13 09:08:22 -05:00
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o'],
|
|
|
|
ipapermincludedattr=[u'cn', u'sn', u'o'],
|
|
|
|
ipapermexcludedattr=[u'cn', u'sn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "l || o")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Modify bind rule in %r' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'ipapermbindruletype': u'all'}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "testperm"',
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o'],
|
|
|
|
ipapermincludedattr=[u'cn', u'sn', u'o'],
|
|
|
|
ipapermexcludedattr=[u'cn', u'sn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "l || o")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) userdn = "ldap:///all";)',
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Show %r with no options' % permission1,
|
|
|
|
command=('permission_show', [permission1], {}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o'],
|
|
|
|
ipapermincludedattr=[u'cn', u'sn', u'o'],
|
|
|
|
ipapermexcludedattr=[u'cn', u'sn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Show %r with --all' % permission1,
|
|
|
|
command=('permission_show', [permission1], {'all': True}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-09-13 09:08:22 -05:00
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o'],
|
|
|
|
ipapermincludedattr=[u'cn', u'sn', u'o'],
|
|
|
|
ipapermexcludedattr=[u'cn', u'sn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Show %r with --raw' % permission1,
|
|
|
|
command=('permission_show', [permission1], {'raw': True}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=None,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
aci=['(targetattr = "l || o")'
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")'
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%(name)s";'
|
|
|
|
'allow (write) userdn = "ldap:///all";)' %
|
2014-01-06 08:51:20 -06:00
|
|
|
{'name': permission1}],
|
2013-09-13 09:08:22 -05:00
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-01-06 08:51:20 -06:00
|
|
|
ipapermtargetfilter=[u'(objectclass=posixaccount)'],
|
2013-09-13 09:08:22 -05:00
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
ipapermincludedattr=[u'cn', u'sn', u'o'],
|
|
|
|
ipapermexcludedattr=[u'cn', u'sn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Modify attrs of %r to normalize' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'attrs': [u'l', u'o']}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "testperm"',
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o'],
|
|
|
|
ipapermexcludedattr=[u'cn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "l || o")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) userdn = "ldap:///all";)',
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Modify attrs of %r to add sn' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'attrs': [u'l', u'o', u'sn']}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "testperm"',
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o', u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermexcludedattr=[u'cn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "l || o || sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) userdn = "ldap:///all";)',
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r using all its --attrs' % permission1,
|
|
|
|
command=('permission_find', [permission1],
|
|
|
|
{'cn': permission1, 'attrs': [u'l', u'o', u'sn']}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o', u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermexcludedattr=[u'cn'],
|
|
|
|
)],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r using some --attrs' % permission1,
|
|
|
|
command=('permission_find', [permission1],
|
|
|
|
{'cn': permission1, 'attrs': [u'l', u'sn']}),
|
|
|
|
expected=dict(
|
|
|
|
count=1,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'1 permission matched',
|
|
|
|
result=[dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o', u'sn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
ipapermexcludedattr=[u'cn'],
|
|
|
|
)],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Search for %r using excluded --attrs' % permission1,
|
|
|
|
command=('permission_find', [permission1],
|
|
|
|
{'cn': permission1, 'attrs': [u'sn', u'cn']}),
|
|
|
|
expected=dict(
|
|
|
|
count=0,
|
|
|
|
truncated=False,
|
|
|
|
summary=u'0 permissions matched',
|
|
|
|
result=[],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Modify attrs of %r to allow cn again' % permission1,
|
|
|
|
command=('permission_mod', [permission1],
|
|
|
|
{'attrs': [u'l', u'o', u'sn', u'cn']}),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "testperm"',
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2', u'MANAGED'],
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'all'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
ipapermdefaultattr=[u'l', u'o', u'cn'],
|
|
|
|
attrs=[u'l', u'o', u'sn', u'cn'],
|
|
|
|
ipapermincludedattr=[u'sn'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetattr = "cn || l || o || sn")' +
|
2014-01-06 08:51:20 -06:00
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
2013-09-13 09:08:22 -05:00
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) userdn = "ldap:///all";)',
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Try to delete %r' % permission1,
|
|
|
|
command=('permission_del', [permission1], {}),
|
|
|
|
expected=errors.ACIError(
|
|
|
|
info='cannot delete managed permissions'),
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r with --force' % permission1,
|
|
|
|
command=('permission_del', [permission1], {'force': True}),
|
|
|
|
expected=dict(
|
2014-03-27 08:04:00 -05:00
|
|
|
result=dict(failed=[]),
|
|
|
|
value=[permission1],
|
2013-09-13 09:08:22 -05:00
|
|
|
summary=u'Deleted permission "%s"' % permission1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]
|
2014-01-10 11:12:55 -06:00
|
|
|
|
|
|
|
|
|
|
|
class test_permission_filters(Declarative):
|
|
|
|
"""Test multi-valued filters, type, memberof"""
|
|
|
|
cleanup_commands = [
|
|
|
|
('permission_del', [permission1], {'force': True}),
|
|
|
|
]
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
dict(
|
|
|
|
desc='Create %r with many filters' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
memberof=u'ipausers',
|
|
|
|
ipapermright=u'write',
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(objectclass=top)',
|
|
|
|
u'(memberof=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
memberof=[u'admins', u'ipausers'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-03-04 05:45:24 -06:00
|
|
|
extratargetfilter=[
|
2014-01-10 11:12:55 -06:00
|
|
|
u'(objectclass=top)',
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetfilter = "(&'
|
|
|
|
'(memberOf=%s)' % DN(('cn', 'ipausers'), groups_dn) +
|
|
|
|
'(memberof=%s)' % DN(('cn', 'admins'), groups_dn) +
|
|
|
|
'(objectclass=posixaccount)(objectclass=top)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Remove type from %r while setting other filters' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1],
|
|
|
|
dict(
|
|
|
|
type=None,
|
|
|
|
memberof=u'ipausers',
|
|
|
|
ipapermtargetfilter=[
|
|
|
|
u'(objectclass=ipauser)',
|
|
|
|
u'(memberof=%s)' % DN(('cn', 'admins'), groups_dn),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
memberof=[u'admins', u'ipausers'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
2014-03-04 05:45:24 -06:00
|
|
|
extratargetfilter=[
|
2014-01-10 11:12:55 -06:00
|
|
|
u'(objectclass=ipauser)',
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetfilter = "(&'
|
|
|
|
'(memberOf=%s)' % DN(('cn', 'ipausers'), groups_dn) +
|
|
|
|
'(memberof=%s)' % DN(('cn', 'admins'), groups_dn) +
|
|
|
|
'(objectclass=ipauser)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Remove memberof from %r while adding a filter' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1],
|
|
|
|
dict(
|
|
|
|
memberof=None,
|
|
|
|
addattr=u'ipapermtargetfilter=(cn=xyz)',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
2014-03-04 05:45:24 -06:00
|
|
|
extratargetfilter=[
|
2014-01-10 11:12:55 -06:00
|
|
|
u'(cn=xyz)',
|
|
|
|
u'(objectclass=ipauser)',
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetfilter = "(&'
|
|
|
|
'(cn=xyz)' +
|
|
|
|
'(objectclass=ipauser)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Set memberof, type and filter on %r at once' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1],
|
|
|
|
dict(
|
|
|
|
type=u'user',
|
|
|
|
memberof=u'admins',
|
|
|
|
ipapermtargetfilter=u'(uid=abc)',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
memberof=[u'admins'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
2014-03-04 05:45:24 -06:00
|
|
|
extratargetfilter=[
|
2014-01-10 11:12:55 -06:00
|
|
|
u'(uid=abc)',
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetfilter = "(&'
|
|
|
|
u'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn) +
|
|
|
|
'(objectclass=posixaccount)' +
|
|
|
|
'(uid=abc)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Remove memberof & type from %r at once' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1],
|
|
|
|
dict(
|
|
|
|
type=None,
|
|
|
|
memberof=None,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
2014-03-04 05:45:24 -06:00
|
|
|
extratargetfilter=[
|
2014-01-10 11:12:55 -06:00
|
|
|
u'(uid=abc)',
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetfilter = "(uid=abc)")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
2014-02-27 07:38:16 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Add multiple memberof to %r' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_mod', [permission1],
|
|
|
|
dict(
|
|
|
|
memberof=[u'admins', u'editors'],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Modified permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
memberof=[u'admins', u'editors'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[api.env.basedn],
|
2014-03-04 05:45:24 -06:00
|
|
|
extratargetfilter=[u'(uid=abc)'],
|
2014-02-27 07:38:16 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, api.env.basedn,
|
|
|
|
'(targetfilter = "(&'
|
|
|
|
'(memberOf=%s)' % DN(('cn', 'admins'), groups_dn) +
|
|
|
|
'(memberOf=%s)' % DN(('cn', 'editors'), groups_dn) +
|
|
|
|
'(uid=abc)' +
|
|
|
|
')")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
2014-02-28 05:23:17 -06:00
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Delete %r' % permission1,
|
|
|
|
command=('permission_del', [permission1], {}),
|
|
|
|
expected=dict(
|
2014-03-27 08:04:00 -05:00
|
|
|
result=dict(failed=[]),
|
|
|
|
value=[permission1],
|
2014-02-28 05:23:17 -06:00
|
|
|
summary=u'Deleted permission "%s"' % permission1,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci_missing(permission1, api.env.basedn),
|
|
|
|
|
|
|
|
dict(
|
|
|
|
desc='Create %r with empty filters [#4206]' % permission1,
|
|
|
|
command=(
|
|
|
|
'permission_add', [permission1], dict(
|
|
|
|
type=u'user',
|
|
|
|
ipapermright=u'write',
|
|
|
|
ipapermtargetfilter=u'',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
expected=dict(
|
|
|
|
value=permission1,
|
|
|
|
summary=u'Added permission "%s"' % permission1,
|
|
|
|
result=dict(
|
|
|
|
dn=permission1_dn,
|
|
|
|
cn=[permission1],
|
|
|
|
objectclass=objectclasses.permission,
|
|
|
|
type=[u'user'],
|
|
|
|
ipapermright=[u'write'],
|
|
|
|
ipapermbindruletype=[u'permission'],
|
|
|
|
ipapermissiontype=[u'SYSTEM', u'V2'],
|
|
|
|
ipapermlocation=[users_dn],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
verify_permission_aci(
|
|
|
|
permission1, users_dn,
|
|
|
|
'(targetfilter = "(objectclass=posixaccount)")' +
|
|
|
|
'(version 3.0;acl "permission:%s";' % permission1 +
|
|
|
|
'allow (write) groupdn = "ldap:///%s";)' % permission1_dn,
|
|
|
|
),
|
2014-01-10 11:12:55 -06:00
|
|
|
]
|