Imported Upstream version 4.0.5
This commit is contained in:
35
makeaci
35
makeaci
@@ -24,15 +24,22 @@
|
||||
# to ensure that changes aren't made lightly.
|
||||
# Can either regenerate ACI.txt, or validate against it.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import difflib
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from ipalib import api
|
||||
from ipapython.dn import DN
|
||||
from ipapython.ipaldap import LDAPClient
|
||||
from ipapython.ipaldap import LDAPEntry, IPASimpleLDAPObject, LDAPClient
|
||||
|
||||
|
||||
class FakeLDAPClient(LDAPClient):
|
||||
"""A LDAP client that can't do any LDAP operations
|
||||
|
||||
Used to create and manipulate entries without an LDAP connection.
|
||||
"""
|
||||
def _init_connection(self):
|
||||
self.conn = IPASimpleLDAPObject('', False, no_schema=True)
|
||||
|
||||
|
||||
def parse_options():
|
||||
@@ -50,7 +57,7 @@ def generate_aci_lines(api):
|
||||
"""Yields ACI lines as they appear in ACI.txt, with trailing newline"""
|
||||
update_plugin = api.Updater['update_managed_permissions']
|
||||
perm_plugin = api.Object['permission']
|
||||
fake_ldap = LDAPClient('', force_schema_updates=False, no_schema=True)
|
||||
fake_ldap = FakeLDAPClient('')
|
||||
for name, template, obj in update_plugin.get_templates():
|
||||
dn = perm_plugin.get_dn(name)
|
||||
entry = fake_ldap.make_entry(dn)
|
||||
@@ -86,8 +93,8 @@ def check_member_attrs(name, template):
|
||||
|
||||
def main(options):
|
||||
api.bootstrap(
|
||||
in_server=True,
|
||||
in_tree=True,
|
||||
context='cli',
|
||||
in_server=False,
|
||||
debug=False,
|
||||
verbose=0,
|
||||
validate_api=True,
|
||||
@@ -96,12 +103,10 @@ def main(options):
|
||||
plugins_on_demand=False,
|
||||
basedn=DN('dc=ipa,dc=example'),
|
||||
realm='IPA.EXAMPLE',
|
||||
domain="example.com",
|
||||
)
|
||||
|
||||
from ipaserver.install.plugins import update_managed_permissions
|
||||
api.add_module(update_managed_permissions)
|
||||
|
||||
from ipaserver.install.plugins.update_managed_permissions import (
|
||||
update_managed_permissions)
|
||||
from ipalib.plugins.permission import permission
|
||||
api.finalize()
|
||||
|
||||
output_lines = list(generate_aci_lines(api))
|
||||
@@ -117,10 +122,10 @@ def main(options):
|
||||
tofile='new result',
|
||||
))
|
||||
for line in diff:
|
||||
print(line, end=' ')
|
||||
print(file=sys.stderr)
|
||||
print('Managed permission ACI validation failed.', file=sys.stderr)
|
||||
print('Re-check permission changes and run `makeaci`.', file=sys.stderr)
|
||||
print line,
|
||||
print>>sys.stderr
|
||||
print>>sys.stderr, 'Managed permission ACI validation failed.'
|
||||
print>>sys.stderr, 'Re-check permission changes and run `makeaci`.'
|
||||
exit('%s validation failed' % options.filename)
|
||||
else:
|
||||
with open(options.filename, 'w') as file:
|
||||
|
||||
Reference in New Issue
Block a user