diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py index 643cacd0616..423b434d4d3 100755 --- a/lib/ldb/tests/python/api.py +++ b/lib/ldb/tests/python/api.py @@ -346,7 +346,7 @@ class SimpleLdb(LdbBaseTest): m.dn = ldb.Dn(l, "dc=foo4") m["bla"] = b"bla" self.assertEqual(len(l.search()), 0) - self.assertRaises(ldb.LdbError, lambda: l.add(m,["search_options:1:2"])) + self.assertRaises(ldb.LdbError, lambda: l.add(m, ["search_options:1:2"])) def test_add_dict(self): l = ldb.Ldb(self.url(), flags=self.flags()) @@ -682,7 +682,7 @@ class SimpleLdb(LdbBaseTest): def test_no_crash_broken_expr(self): l = ldb.Ldb(self.url(), flags=self.flags()) - self.assertRaises(ldb.LdbError,lambda: l.search("", ldb.SCOPE_SUBTREE, "&(dc=*)(dn=*)", ["dc"])) + self.assertRaises(ldb.LdbError, lambda: l.search("", ldb.SCOPE_SUBTREE, "&(dc=*)(dn=*)", ["dc"])) # Run the SimpleLdb tests against an lmdb backend class SimpleLdbLmdb(SimpleLdb): diff --git a/python/samba/ms_forest_updates_markdown.py b/python/samba/ms_forest_updates_markdown.py index 1b288e3e74c..bd992474967 100644 --- a/python/samba/ms_forest_updates_markdown.py +++ b/python/samba/ms_forest_updates_markdown.py @@ -217,7 +217,7 @@ def read_ms_markdown(in_file, out_folder=None, out_dict={}): if node.text and node.text.startswith('|Operation'): # Strip first and last | updates = [x[1:len(x) - 1].split('|') for x in - ET.tostring(node,method='text').splitlines()] + ET.tostring(node, method='text').splitlines()] for update in updates[2:]: output = re.match('Operation (\d+): {(.*)}', update[0]) if output: diff --git a/python/samba/ms_schema.py b/python/samba/ms_schema.py index cd7e5fb12f3..109c298cebc 100644 --- a/python/samba/ms_schema.py +++ b/python/samba/ms_schema.py @@ -83,8 +83,8 @@ oMObjectClassBER = { } # separated by commas in docs, and must be broken up -multivalued_attrs = set(["auxiliaryclass","maycontain","mustcontain","posssuperiors", - "systemauxiliaryclass","systemmaycontain","systemmustcontain", +multivalued_attrs = set(["auxiliaryclass", "maycontain", "mustcontain", "posssuperiors", + "systemauxiliaryclass", "systemmaycontain", "systemmustcontain", "systemposssuperiors"]) def __read_folded_line(f, buffer): diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index 556afd71e40..cd1a2373550 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -28,7 +28,7 @@ class Option(optparse.Option): # This help formatter does text wrapping and preserves newlines class PlainHelpFormatter(optparse.IndentedHelpFormatter): - def format_description(self,description=""): + def format_description(self, description=""): desc_width = self.width - self.current_indent indent = " " * self.current_indent paragraphs = description.split('\n') @@ -128,7 +128,7 @@ class Command(object): usage=self.synopsis, description=self.full_description, formatter=PlainHelpFormatter(), - prog=prog,epilog=epilog) + prog=prog, epilog=epilog) parser.add_options(self.takes_options) optiongroups = {} for name, optiongroup in self.takes_optiongroups.items(): diff --git a/python/samba/netcmd/dbcheck.py b/python/samba/netcmd/dbcheck.py index 4e5e78d5668..874b2f990d6 100644 --- a/python/samba/netcmd/dbcheck.py +++ b/python/samba/netcmd/dbcheck.py @@ -108,7 +108,7 @@ class cmd_dbcheck(Command): samdb_schema = SamDB(session_info=system_session(), url=None, credentials=creds, lp=lp) - scope_map = {"SUB": ldb.SCOPE_SUBTREE, "BASE": ldb.SCOPE_BASE, "ONE":ldb.SCOPE_ONELEVEL} + scope_map = {"SUB": ldb.SCOPE_SUBTREE, "BASE": ldb.SCOPE_BASE, "ONE": ldb.SCOPE_ONELEVEL} scope = scope.upper() if not scope in scope_map: raise CommandError("Unknown scope %s" % scope) diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py index cc65c9236df..26c7551bc22 100644 --- a/python/samba/netcmd/dns.py +++ b/python/samba/netcmd/dns.py @@ -549,7 +549,7 @@ class cmd_serverinfo(Command): takes_options = [ Option('--client-version', help='Client Version', default='longhorn', metavar='w2k|dotnet|longhorn', - choices=['w2k','dotnet','longhorn'], dest='cli_ver'), + choices=['w2k', 'dotnet', 'longhorn'], dest='cli_ver'), ] def run(self, server, cli_ver, sambaopts=None, credopts=None, @@ -581,7 +581,7 @@ class cmd_zoneinfo(Command): takes_options = [ Option('--client-version', help='Client Version', default='longhorn', metavar='w2k|dotnet|longhorn', - choices=['w2k','dotnet','longhorn'], dest='cli_ver'), + choices=['w2k', 'dotnet', 'longhorn'], dest='cli_ver'), ] def run(self, server, zone, cli_ver, sambaopts=None, credopts=None, @@ -613,7 +613,7 @@ class cmd_zonelist(Command): takes_options = [ Option('--client-version', help='Client Version', default='longhorn', metavar='w2k|dotnet|longhorn', - choices=['w2k','dotnet','longhorn'], dest='cli_ver'), + choices=['w2k', 'dotnet', 'longhorn'], dest='cli_ver'), Option('--primary', help='List primary zones (default)', action='store_true', dest='primary'), Option('--secondary', help='List secondary zones', @@ -692,7 +692,7 @@ class cmd_zonecreate(Command): takes_options = [ Option('--client-version', help='Client Version', default='longhorn', metavar='w2k|dotnet|longhorn', - choices=['w2k','dotnet','longhorn'], dest='cli_ver') + choices=['w2k', 'dotnet', 'longhorn'], dest='cli_ver') ] def run(self, server, zone, cli_ver, sambaopts=None, credopts=None, @@ -923,7 +923,7 @@ class cmd_add_record(Command): def run(self, server, zone, name, rtype, data, sambaopts=None, credopts=None, versionopts=None): - if rtype.upper() not in ('A','AAAA','PTR','CNAME','NS','MX','SRV','TXT'): + if rtype.upper() not in ('A', 'AAAA', 'PTR', 'CNAME', 'NS', 'MX', 'SRV', 'TXT'): raise CommandError('Adding record of type %s is not supported' % rtype) record_type = dns_type_flag(rtype) @@ -975,7 +975,7 @@ class cmd_update_record(Command): def run(self, server, zone, name, rtype, olddata, newdata, sambaopts=None, credopts=None, versionopts=None): - if rtype.upper() not in ('A','AAAA','PTR','CNAME','NS','MX','SOA','SRV','TXT'): + if rtype.upper() not in ('A', 'AAAA', 'PTR', 'CNAME', 'NS', 'MX', 'SOA', 'SRV', 'TXT'): raise CommandError('Updating record of type %s is not supported' % rtype) record_type = dns_type_flag(rtype) @@ -1044,7 +1044,7 @@ class cmd_delete_record(Command): def run(self, server, zone, name, rtype, data, sambaopts=None, credopts=None, versionopts=None): - if rtype.upper() not in ('A','AAAA','PTR','CNAME','NS','MX','SRV','TXT'): + if rtype.upper() not in ('A', 'AAAA', 'PTR', 'CNAME', 'NS', 'MX', 'SRV', 'TXT'): raise CommandError('Deleting record of type %s is not supported' % rtype) record_type = dns_type_flag(rtype) diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py index 19d522064e8..40117251450 100644 --- a/python/samba/netcmd/domain.py +++ b/python/samba/netcmd/domain.py @@ -148,7 +148,7 @@ def get_testparm_var(testparm, smbconf, varname): p = subprocess.Popen([testparm, '-s', '-l', '--parameter-name=%s' % varname, smbconf], stdout=subprocess.PIPE, stderr=errfile) - (out,err) = p.communicate() + (out, err) = p.communicate() errfile.close() lines = out.split('\n') if lines: @@ -303,7 +303,7 @@ class cmd_domain_provision(Command): ] ntvfs_options = [ - Option("--use-xattrs", type="choice", choices=["yes","no","auto"], + Option("--use-xattrs", type="choice", choices=["yes", "no", "auto"], metavar="[yes|no|auto]", help="Define if we should use the native fs capabilities or a tdb file for " "storing attributes likes ntacl when --use-ntvfs is set. " @@ -1365,9 +1365,9 @@ class cmd_domain_passwordsettings_set(Command): Option("-H", "--URL", help="LDB URL for database or target server", type=str, metavar="URL", dest="H"), Option("-q", "--quiet", help="Be quiet", action="store_true"), # unused - Option("--complexity", type="choice", choices=["on","off","default"], + Option("--complexity", type="choice", choices=["on", "off", "default"], help="The password complexity (on | off | default). Default is 'on'"), - Option("--store-plaintext", type="choice", choices=["on","off","default"], + Option("--store-plaintext", type="choice", choices=["on", "off", "default"], help="Store plaintext passwords where account have 'store passwords with reversible encryption' set (on | off | default). Default is 'off'"), Option("--history-length", help="The password history length ( | default). Default is 24.", type=str), @@ -1581,7 +1581,7 @@ class cmd_domain_classicupgrade(Command): ] ntvfs_options = [ - Option("--use-xattrs", type="choice", choices=["yes","no","auto"], + Option("--use-xattrs", type="choice", choices=["yes", "no", "auto"], metavar="[yes|no|auto]", help="Define if we should use the native fs capabilities or a tdb file for " "storing attributes likes ntacl when --use-ntvfs is set. " diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py index 2d4ad9cd501..e8dbdd432f6 100644 --- a/python/samba/netcmd/drs.py +++ b/python/samba/netcmd/drs.py @@ -617,7 +617,7 @@ class cmd_drs_bind(Command): ("DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2", "DRS_EXT_ADDENTRY_V2"), ("DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION", "DRS_EXT_LINKED_VALUE_REPLICATION"), ("DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2", "DRS_EXT_DCINFO_V2"), - ("DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD","DRS_EXT_INSTANCE_TYPE_NOT_REQ_ON_MOD"), + ("DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD", "DRS_EXT_INSTANCE_TYPE_NOT_REQ_ON_MOD"), ("DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND", "DRS_EXT_CRYPTO_BIND"), ("DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO", "DRS_EXT_GET_REPL_INFO"), ("DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION", "DRS_EXT_STRONG_ENCRYPTION"), diff --git a/python/samba/netcmd/dsacl.py b/python/samba/netcmd/dsacl.py index 7522736b125..4ca15cdc99d 100644 --- a/python/samba/netcmd/dsacl.py +++ b/python/samba/netcmd/dsacl.py @@ -87,7 +87,7 @@ class cmd_dsacl_set(Command): res = samdb.search(base=trusteedn, expression="(objectClass=*)", scope=SCOPE_BASE) assert(len(res) == 1) - return ndr_unpack(security.dom_sid,res[0]["objectSid"][0]) + return ndr_unpack(security.dom_sid, res[0]["objectSid"][0]) def modify_descriptor(self, samdb, object_dn, desc, controls=None): assert(isinstance(desc, security.descriptor)) @@ -109,7 +109,7 @@ class cmd_dsacl_set(Command): def get_domain_sid(self, samdb): res = samdb.search(base=samdb.domain_dn(), expression="(objectClass=*)", scope=SCOPE_BASE) - return ndr_unpack(security.dom_sid,res[0]["objectSid"][0]) + return ndr_unpack(security.dom_sid, res[0]["objectSid"][0]) def add_ace(self, samdb, object_dn, new_ace): """Add new ace explicitly.""" diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index c5e322342ad..06b4fe508b9 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -432,7 +432,7 @@ class cmd_list(Command): try: msg = self.samdb.search(expression='(&(|(samAccountName=%s)(samAccountName=%s$))(objectClass=User))' % - (ldb.binary_encode(username),ldb.binary_encode(username))) + (ldb.binary_encode(username), ldb.binary_encode(username))) user_dn = msg[0].dn except Exception: raise CommandError("Failed to find account %s" % username) diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index ea2c2ae4cca..3f4d63d989f 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -97,7 +97,7 @@ class LDAPBase(object): def find_domain_sid(self): res = self.ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE) - return ndr_unpack(security.dom_sid,res[0]["objectSid"][0]) + return ndr_unpack(security.dom_sid, res[0]["objectSid"][0]) def find_servers(self): """ @@ -492,19 +492,19 @@ class LDAPObject(object): # Attributes that contain the Domain name e.g. 'samba.org' self.domain_attributes = [ "proxyAddresses", "mail", "userPrincipalName", "msExchSmtpFullyQualifiedDomainName", - "dnsHostName", "networkAddress", "dnsRoot", "servicePrincipalName",] + "dnsHostName", "networkAddress", "dnsRoot", "servicePrincipalName", ] self.domain_attributes = [x.upper() for x in self.domain_attributes] # # May contain DOMAIN_NETBIOS and SERVER_NAME self.servername_attributes = ["distinguishedName", "name", "CN", "sAMAccountName", "dNSHostName", "servicePrincipalName", "rIDSetReferences", "serverReference", "serverReferenceBL", - "msDS-IsDomainFor", "interSiteTopologyGenerator",] + "msDS-IsDomainFor", "interSiteTopologyGenerator", ] self.servername_attributes = [x.upper() for x in self.servername_attributes] # - self.netbios_attributes = ["servicePrincipalName", "CN", "distinguishedName", "nETBIOSName", "name",] + self.netbios_attributes = ["servicePrincipalName", "CN", "distinguishedName", "nETBIOSName", "name", ] self.netbios_attributes = [x.upper() for x in self.netbios_attributes] # - self.other_attributes = ["name", "DC",] + self.other_attributes = ["name", "DC", ] self.other_attributes = [x.upper() for x in self.other_attributes] # self.ignore_attributes = [x.upper() for x in self.ignore_attributes] @@ -968,7 +968,7 @@ class cmd_ldapcmp(Command): con1 = LDAPBase(URL1, creds, lp, two=two, quiet=quiet, descriptor=descriptor, sort_aces=sort_aces, - verbose=verbose,view=view, base=base, scope=scope, + verbose=verbose, view=view, base=base, scope=scope, outf=self.outf, errf=self.errf) assert len(con1.base_dn) > 0 diff --git a/python/samba/netcmd/ntacl.py b/python/samba/netcmd/ntacl.py index 3957a726689..e7f410382c4 100644 --- a/python/samba/netcmd/ntacl.py +++ b/python/samba/netcmd/ntacl.py @@ -19,7 +19,7 @@ from samba.credentials import DONT_USE_KERBEROS import samba.getopt as options from samba.dcerpc import security, idmap -from samba.ntacls import setntacl, getntacl,getdosinfo +from samba.ntacls import setntacl, getntacl, getdosinfo from samba import Ldb from samba.ndr import ndr_unpack, ndr_print from samba.samdb import SamDB @@ -53,17 +53,17 @@ class cmd_ntacl_set(Command): takes_options = [ Option("-q", "--quiet", help="Be quiet", action="store_true"), Option("--xattr-backend", type="choice", help="xattr backend type (native fs or tdb)", - choices=["native","tdb"]), + choices=["native", "tdb"]), Option("--eadb-file", help="Name of the tdb file where attributes are stored", type="string"), Option("--use-ntvfs", help="Set the ACLs directly to the TDB or xattr for use with the ntvfs file server", action="store_true"), Option("--use-s3fs", help="Set the ACLs for use with the default s3fs file server via the VFS layer", action="store_true"), Option("--service", help="Name of the smb.conf service to use when applying the ACLs", type="string") ] - takes_args = ["acl","file"] + takes_args = ["acl", "file"] def run(self, acl, file, use_ntvfs=False, use_s3fs=False, - quiet=False,xattr_backend=None,eadb_file=None, + quiet=False, xattr_backend=None, eadb_file=None, credopts=None, sambaopts=None, versionopts=None, service=None): logger = self.get_logger() @@ -129,7 +129,7 @@ class cmd_ntacl_get(Command): takes_options = [ Option("--as-sddl", help="Output ACL in the SDDL format", action="store_true"), Option("--xattr-backend", type="choice", help="xattr backend type (native fs or tdb)", - choices=["native","tdb"]), + choices=["native", "tdb"]), Option("--eadb-file", help="Name of the tdb file where attributes are stored", type="string"), Option("--use-ntvfs", help="Get the ACLs directly from the TDB or xattr used with the ntvfs file server", action="store_true"), Option("--use-s3fs", help="Get the ACLs for use via the VFS layer used by the default s3fs file server", action="store_true"), @@ -223,10 +223,10 @@ class cmd_ntacl_sysvolreset(Command): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) if (LA_type != idmap.ID_TYPE_UID and LA_type != idmap.ID_TYPE_BOTH): raise CommandError("SID %s is not mapped to a UID" % LA_sid) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) if (BA_type != idmap.ID_TYPE_GID and BA_type != idmap.ID_TYPE_BOTH): raise CommandError("SID %s is not mapped to a GID" % BA_sid) diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index d83a7db7ecd..677e0a91559 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -1857,7 +1857,7 @@ samba-tool user syncpasswords --terminate \\ self.samdb_url = H self.dirsync_filter = dirsync_filter self.dirsync_attrs = dirsync_attrs - self.dirsync_controls = ["dirsync:1:0:0","extended_dn:1:0"]; + self.dirsync_controls = ["dirsync:1:0:0", "extended_dn:1:0"]; self.password_attrs = password_attrs self.decrypt_samba_gpg = decrypt_samba_gpg self.sync_command = sync_command @@ -1881,7 +1881,7 @@ samba-tool user syncpasswords --terminate \\ self.current_pid = None self.outf.write("Initialized cache_ldb[%s]\n" % (cache_ldb)) msgs = self.cache.parse_ldif(add_ldif) - changetype,msg = next(msgs) + changetype, msg = next(msgs) ldif = self.cache.write_ldif(msg, ldb.CHANGETYPE_NONE) self.outf.write("%s" % ldif) else: @@ -2079,7 +2079,7 @@ samba-tool user syncpasswords --terminate \\ assert len(res_controls) > 0 assert res_controls[0].oid == "1.2.840.113556.1.4.841" res_controls[0].critical = True - self.dirsync_controls = [str(res_controls[0]),"extended_dn:1:0"] + self.dirsync_controls = [str(res_controls[0]), "extended_dn:1:0"] log_msg("dirsyncControls: %r\n" % self.dirsync_controls) modify_ldif = "dn: %s\n" % (self.cache_dn) diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py index a4f808ccd4a..5af894d4791 100644 --- a/python/samba/provision/__init__.py +++ b/python/samba/provision/__init__.py @@ -204,9 +204,9 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, # netbiosname # Get the netbiosname first (could be obtained from smb.conf in theory) res = secretsdb.search(expression="(flatname=%s)" % - names.domain,base="CN=Primary Domains", + names.domain, base="CN=Primary Domains", scope=ldb.SCOPE_SUBTREE, attrs=["sAMAccountName"]) - names.netbiosname = str(res[0]["sAMAccountName"]).replace("$","") + names.netbiosname = str(res[0]["sAMAccountName"]).replace("$", "") names.smbconf = smbconf @@ -215,7 +215,7 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, current = samdb.search(expression="(objectClass=*)", base="", scope=ldb.SCOPE_BASE, attrs=["defaultNamingContext", "schemaNamingContext", - "configurationNamingContext","rootDomainNamingContext", + "configurationNamingContext", "rootDomainNamingContext", "namingContexts"]) names.configdn = current[0]["configurationNamingContext"][0] @@ -275,7 +275,7 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, # domain guid/sid res6 = samdb.search(expression="(objectClass=*)", base=basedn, scope=ldb.SCOPE_BASE, attrs=["objectGUID", - "objectSid","msDS-Behavior-Version"]) + "objectSid", "msDS-Behavior-Version"]) names.domainguid = str(ndr_unpack(misc.GUID, res6[0]["objectGUID"][0])) names.domainsid = ndr_unpack(security.dom_sid, res6[0]["objectSid"][0]) names.forestsid = ndr_unpack(security.dom_sid, res6[0]["objectSid"][0]) @@ -288,15 +288,15 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, # policy guid res7 = samdb.search(expression="(name={%s})" % DEFAULT_POLICY_GUID, base="CN=Policies,CN=System," + basedn, - scope=ldb.SCOPE_ONELEVEL, attrs=["cn","displayName"]) - names.policyid = str(res7[0]["cn"]).replace("{","").replace("}","") + scope=ldb.SCOPE_ONELEVEL, attrs=["cn", "displayName"]) + names.policyid = str(res7[0]["cn"]).replace("{", "").replace("}", "") # dc policy guid res8 = samdb.search(expression="(name={%s})" % DEFAULT_DC_POLICY_GUID, base="CN=Policies,CN=System," + basedn, scope=ldb.SCOPE_ONELEVEL, - attrs=["cn","displayName"]) + attrs=["cn", "displayName"]) if len(res8) == 1: - names.policyid_dc = str(res8[0]["cn"]).replace("{","").replace("}","") + names.policyid_dc = str(res8[0]["cn"]).replace("{", "").replace("}", "") else: names.policyid_dc = None @@ -407,7 +407,7 @@ def set_provision_usn(samdb, low, high, id): samdb.add(delta) -def get_max_usn(samdb,basedn): +def get_max_usn(samdb, basedn): """ This function return the biggest USN present in the provision :param samdb: A LDB object pointing to the sam.ldb @@ -415,8 +415,8 @@ def get_max_usn(samdb,basedn): (ie. DC=foo, DC=bar) :return: The biggest USN in the provision""" - res = samdb.search(expression="objectClass=*",base=basedn, - scope=ldb.SCOPE_SUBTREE,attrs=["uSNChanged"], + res = samdb.search(expression="objectClass=*", base=basedn, + scope=ldb.SCOPE_SUBTREE, attrs=["uSNChanged"], controls=["search_options:1:2", "server_sort:1:1:uSNChanged", "paged_results:1:1"]) @@ -1264,10 +1264,10 @@ def create_default_gpo(sysvolpath, dnsdomain, policyguid, policyguid_dc): :param policyguid: GUID of the default domain policy :param policyguid_dc: GUID of the default domain controler policy """ - policy_path = getpolicypath(sysvolpath,dnsdomain,policyguid) + policy_path = getpolicypath(sysvolpath, dnsdomain, policyguid) create_gpo_struct(policy_path) - policy_path = getpolicypath(sysvolpath,dnsdomain,policyguid_dc) + policy_path = getpolicypath(sysvolpath, dnsdomain, policyguid_dc) create_gpo_struct(policy_path) diff --git a/python/samba/provision/backend.py b/python/samba/provision/backend.py index d85072a8723..e2e372e8b59 100644 --- a/python/samba/provision/backend.py +++ b/python/samba/provision/backend.py @@ -403,7 +403,7 @@ class OpenLDAPBackend(LDAPBackend): # For now, make these equal mmr_pass = self.ldapadminpass - url_list = filter(None,self.ol_mmr_urls.split(',')) + url_list = filter(None, self.ol_mmr_urls.split(',')) for url in url_list: self.logger.info("Using LDAP-URL: " + url) if len(url_list) == 1: @@ -512,7 +512,7 @@ class OpenLDAPBackend(LDAPBackend): "REFINT_CONFIG": refint_config, "INDEX_CONFIG": index_config, "ADMIN_UID": str(os.getuid()), - "NOSYNC": nosync_config,}) + "NOSYNC": nosync_config, }) self.setup_db_dir(os.path.join(self.ldapdir, "db", "forestdns")) self.setup_db_dir(os.path.join(self.ldapdir, "db", "domaindns")) diff --git a/python/samba/provision/common.py b/python/samba/provision/common.py index 03e22789515..2f95492d33a 100644 --- a/python/samba/provision/common.py +++ b/python/samba/provision/common.py @@ -42,7 +42,7 @@ def setup_path(file): return os.path.join(setup_dir(), file) -def setup_add_ldif(ldb, ldif_path, subst_vars=None,controls=["relax:0"]): +def setup_add_ldif(ldb, ldif_path, subst_vars=None, controls=["relax:0"]): """Setup a ldb in the private dir. :param ldb: LDB file to import data into @@ -55,7 +55,7 @@ def setup_add_ldif(ldb, ldif_path, subst_vars=None,controls=["relax:0"]): ldb.add_ldif(data, controls) -def setup_modify_ldif(ldb, ldif_path, subst_vars=None,controls=["relax:0"]): +def setup_modify_ldif(ldb, ldif_path, subst_vars=None, controls=["relax:0"]): """Modify a ldb in the private dir. :param ldb: LDB object. diff --git a/python/samba/schema.py b/python/samba/schema.py index 0958808cc88..55cb52e0fc4 100644 --- a/python/samba/schema.py +++ b/python/samba/schema.py @@ -219,7 +219,7 @@ def get_linked_attributes(schemadn, schemaldb): return attributes -def get_dnsyntax_attributes(schemadn,schemaldb): +def get_dnsyntax_attributes(schemadn, schemaldb): res = schemaldb.search( expression="(&(!(linkID=*))(objectclass=attributeSchema)(attributeSyntax=2.5.5.1))", base=schemadn, scope=SCOPE_ONELEVEL, diff --git a/python/samba/sd_utils.py b/python/samba/sd_utils.py index aebb2cabc4b..26e80ee2f4a 100644 --- a/python/samba/sd_utils.py +++ b/python/samba/sd_utils.py @@ -66,7 +66,7 @@ class SDUtils(object): def dacl_add_ace(self, object_dn, ace): """Add an ACE to an objects security descriptor """ - desc = self.read_sd_on_dn(object_dn,["show_deleted:1"]) + desc = self.read_sd_on_dn(object_dn, ["show_deleted:1"]) desc_sddl = desc.as_sddl(self.domain_sid) if ace in desc_sddl: return diff --git a/python/samba/tests/common.py b/python/samba/tests/common.py index 49ae2b07a78..146c6a8de9d 100644 --- a/python/samba/tests/common.py +++ b/python/samba/tests/common.py @@ -50,13 +50,13 @@ class CommonTests(samba.tests.TestCaseInTempDir): dn4 = dsdb_Dn(sam, "B:8:00000000:;OU=dn4,DC=samba,DC=example,DC=com") dn5 = dsdb_Dn(sam, ";OU=dn5,DC=samba,DC=example,DC=com") dn6 = dsdb_Dn(sam, ";OU=dn6,DC=samba,DC=example,DC=com") - unsorted_links14 = [dn1,dn2,dn3,dn4] + unsorted_links14 = [dn1, dn2, dn3, dn4] sorted_vals14 = [str(dn) for dn in sorted(unsorted_links14)] self.assertEquals(sorted_vals14[0], str(dn3)) self.assertEquals(sorted_vals14[1], str(dn2)) self.assertEquals(sorted_vals14[2], str(dn1)) self.assertEquals(sorted_vals14[3], str(dn4)) - unsorted_links56 = [dn5,dn6] + unsorted_links56 = [dn5, dn6] sorted_vals56 = [str(dn) for dn in sorted(unsorted_links56)] self.assertEquals(sorted_vals56[0], str(dn6)) self.assertEquals(sorted_vals56[1], str(dn5)) diff --git a/python/samba/tests/dcerpc/raw_protocol.py b/python/samba/tests/dcerpc/raw_protocol.py index 3f6e05b0ae0..2659b755ef7 100755 --- a/python/samba/tests/dcerpc/raw_protocol.py +++ b/python/samba/tests/dcerpc/raw_protocol.py @@ -800,7 +800,7 @@ class TestDCERPC_BIND(RawDCERPCTest): # With a known but wrong syntax we get a protocol error # see test_no_auth_presentation_ctx_valid2 - tsf1b_list = [zero_syntax,samba.dcerpc.epmapper.abstract_syntax(),ndr64] + tsf1b_list = [zero_syntax, samba.dcerpc.epmapper.abstract_syntax(), ndr64] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -862,7 +862,7 @@ class TestDCERPC_BIND(RawDCERPCTest): # With a unknown but wrong syntaxes we get NO protocol error # see test_no_auth_presentation_ctx_invalid4 - tsf1b_list = [zero_syntax,samba.dcerpc.epmapper.abstract_syntax()] + tsf1b_list = [zero_syntax, samba.dcerpc.epmapper.abstract_syntax()] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -977,7 +977,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - tsf1_list = [zero_syntax,ndr32] + tsf1_list = [zero_syntax, ndr32] ctx1 = dcerpc.ctx_list() ctx1.context_id = 1 ctx1.num_transfer_syntaxes = len(tsf1_list) @@ -1016,7 +1016,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - tsf2_list = [ndr32,ndr32] + tsf2_list = [ndr32, ndr32] ctx2 = dcerpc.ctx_list() ctx2.context_id = 2 ctx2.num_transfer_syntaxes = len(tsf2_list) @@ -1069,7 +1069,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx4.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx4.transfer_syntaxes = tsf4_list - req = self.generate_alter(call_id=34, ctx_list=[ctx3,ctx4]) + req = self.generate_alter(call_id=34, ctx_list=[ctx3, ctx4]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1106,7 +1106,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - req = self.generate_alter(call_id=43, ctx_list=[ctx4,ctx3]) + req = self.generate_alter(call_id=43, ctx_list=[ctx4, ctx3]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1156,7 +1156,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - req = self.generate_alter(call_id=44, ctx_list=[ctx4,ctx4]) + req = self.generate_alter(call_id=44, ctx_list=[ctx4, ctx4]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1220,7 +1220,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx5epm.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx5epm.transfer_syntaxes = tsf5epm_list - req = self.generate_alter(call_id=55, ctx_list=[ctx5mgmt,ctx5epm]) + req = self.generate_alter(call_id=55, ctx_list=[ctx5mgmt, ctx5epm]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1257,7 +1257,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - req = self.generate_alter(call_id=55, ctx_list=[ctx5mgmt,ctx5epm]) + req = self.generate_alter(call_id=55, ctx_list=[ctx5mgmt, ctx5epm]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1337,7 +1337,7 @@ class TestDCERPC_BIND(RawDCERPCTest): zero_syntax = misc.ndr_syntax_id() ndr64 = base.transfer_syntax_ndr64() - tsf1_list = [btf1,btf2,zero_syntax] + tsf1_list = [btf1, btf2, zero_syntax] ctx1 = dcerpc.ctx_list() ctx1.context_id = 1 ctx1.num_transfer_syntaxes = len(tsf1_list) @@ -1372,7 +1372,7 @@ class TestDCERPC_BIND(RawDCERPCTest): zero_syntax = misc.ndr_syntax_id() - tsf1_list = [zero_syntax,btf1,btf2,zero_syntax] + tsf1_list = [zero_syntax, btf1, btf2, zero_syntax] ctx1 = dcerpc.ctx_list() ctx1.context_id = 1 ctx1.num_transfer_syntaxes = len(tsf1_list) @@ -1422,7 +1422,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx2.abstract_syntax = zero_syntax ctx2.transfer_syntaxes = tsf2_list - req = self.generate_bind(call_id=0, ctx_list=[ctx1,ctx2]) + req = self.generate_bind(call_id=0, ctx_list=[ctx1, ctx2]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_BIND_NAK, req.call_id, @@ -1482,7 +1482,7 @@ class TestDCERPC_BIND(RawDCERPCTest): zero_syntax = misc.ndr_syntax_id() ndr64 = base.transfer_syntax_ndr64() - tsf1_list = [btf1,btf2,zero_syntax] + tsf1_list = [btf1, btf2, zero_syntax] ctx1 = dcerpc.ctx_list() ctx1.context_id = 1 ctx1.num_transfer_syntaxes = len(tsf1_list) @@ -1760,8 +1760,8 @@ class TestDCERPC_BIND(RawDCERPCTest): opnum=0, alloc_hint=0xffffffff, stub="\00" * chunk_size) - self.send_pdu(req,ndr_print=True,hexdump=True) - rep = self.recv_pdu(ndr_print=True,hexdump=True) + self.send_pdu(req, ndr_print=True, hexdump=True) + rep = self.recv_pdu(ndr_print=True, hexdump=True) self.verify_pdu(rep, dcerpc.DCERPC_PKT_RESPONSE, req.call_id, auth_length=0) self.assertNotEquals(rep.u.alloc_hint, 0) @@ -1985,7 +1985,7 @@ class TestDCERPC_BIND(RawDCERPCTest): alloc_hint -= thistime else: alloc_hint = 0 - self.send_pdu(req,hexdump=False) + self.send_pdu(req, hexdump=False) if fault_first is not None: rep = self.recv_pdu() # We get a fault back @@ -3545,7 +3545,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx1.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx1.transfer_syntaxes = tsf1_list - tsf1b_list = [ndr32,ndr64] + tsf1b_list = [ndr32, ndr64] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -3714,7 +3714,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx1.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx1.transfer_syntaxes = tsf1_list - tsf1b_list = [ndr32,ndr64] + tsf1b_list = [ndr32, ndr64] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -3802,7 +3802,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx1.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx1.transfer_syntaxes = tsf1_list - tsf1b_list = [ndr32,ndr64] + tsf1b_list = [ndr32, ndr64] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -4935,7 +4935,7 @@ class TestDCERPC_BIND(RawDCERPCTest): time.sleep(0.5) self.connect() - ack2 = self.do_generic_bind(ctx=ctx,assoc_group_id=ack.u.assoc_group_id, + ack2 = self.do_generic_bind(ctx=ctx, assoc_group_id=ack.u.assoc_group_id, nak_reason=dcerpc.DCERPC_BIND_NAK_REASON_NOT_SPECIFIED) return diff --git a/python/samba/tests/dcerpc/raw_testcase.py b/python/samba/tests/dcerpc/raw_testcase.py index c7809ee2bc0..b6bba02bbb7 100644 --- a/python/samba/tests/dcerpc/raw_testcase.py +++ b/python/samba/tests/dcerpc/raw_testcase.py @@ -478,7 +478,7 @@ class RawDCERPCTest(TestCase): floor5.lhs = lhs5 floor5.rhs.ipaddr = "0.0.0.0" - floors = [floor1,floor2,floor3,floor4,floor5] + floors = [floor1, floor2, floor3, floor4, floor5] req_tower = samba.dcerpc.epmapper.epm_tower() req_tower.num_floors = len(floors) req_tower.floors = floors @@ -572,7 +572,7 @@ class RawDCERPCTest(TestCase): try: rep_pdu = self.recv_raw(hexdump=hexdump, timeout=timeout) if rep_pdu is None: - return (None,None) + return (None, None) rep = ndr_unpack(samba.dcerpc.dcerpc.ncacn_packet, rep_pdu, allow_remaining=True) if ndr_print: sys.stderr.write("recv_pdu: %s" % samba.ndr.ndr_print(rep)) diff --git a/python/samba/tests/dcerpc/rpcecho.py b/python/samba/tests/dcerpc/rpcecho.py index 33cb867f09c..0711ae41546 100644 --- a/python/samba/tests/dcerpc/rpcecho.py +++ b/python/samba/tests/dcerpc/rpcecho.py @@ -40,7 +40,7 @@ class RpcEchoTests(RpcInterfaceTestCase): self.assertEquals(2, self.conn.AddOne(1)) def test_echodata(self): - self.assertEquals([1,2,3], self.conn.EchoData([1, 2, 3])) + self.assertEquals([1, 2, 3], self.conn.EchoData([1, 2, 3])) def test_call(self): self.assertEquals(u"foobar", self.conn.TestCall(u"foobar")) @@ -48,7 +48,7 @@ class RpcEchoTests(RpcInterfaceTestCase): def test_surrounding(self): surrounding_struct = echo.Surrounding() surrounding_struct.x = 4 - surrounding_struct.surrounding = [1,2,3,4] + surrounding_struct.surrounding = [1, 2, 3, 4] y = self.conn.TestSurrounding(surrounding_struct) self.assertEquals(8 * [0], y.surrounding) diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py index e02ed8b7a4b..7dacfb2cbc3 100644 --- a/python/samba/tests/docs.py +++ b/python/samba/tests/docs.py @@ -103,7 +103,7 @@ class SmbDotConfTests(TestCase): 'panic action', 'homedir map', 'NIS homedir', 'server string', 'netbios name', 'socket options', 'use mmap', 'ctdbd socket', 'printing', 'printcap name', 'queueresume command', - 'queuepause command','lpresume command', 'lppause command', + 'queuepause command', 'lpresume command', 'lppause command', 'lprm command', 'lpq command', 'print command', 'template homedir', 'max open files', 'include system krb5 conf', 'rpc server dynamic port range', @@ -258,14 +258,14 @@ class SmbDotConfTests(TestCase): 'bytes': '10', 'octal': '0123', 'ustring': 'ustring', - 'enum':'', 'boolean-auto': '', 'char': 'a', 'list': 'a, b, c'} + 'enum': '', 'boolean-auto': '', 'char': 'a', 'list': 'a, b, c'} opposite_arbitrary = {'string': 'string2', 'boolean': 'no', 'integer': '6', 'boolean-rev': 'no', 'cmdlist': 'd e f', 'bytes': '11', 'octal': '0567', 'ustring': 'ustring2', - 'enum':'', 'boolean-auto': '', 'char': 'b', 'list': 'd, e, f'} + 'enum': '', 'boolean-auto': '', 'char': 'b', 'list': 'd, e, f'} failset = set() count = 0 diff --git a/python/samba/tests/dsdb_lock.py b/python/samba/tests/dsdb_lock.py index cd3851e2f40..332526ed795 100644 --- a/python/samba/tests/dsdb_lock.py +++ b/python/samba/tests/dsdb_lock.py @@ -235,7 +235,7 @@ class DsdbLockTestCase(SamDBTestCase): backenddb.transaction_start() - backenddb.add({"dn":"@DSDB_LOCK_TEST"}) + backenddb.add({"dn": "@DSDB_LOCK_TEST"}) backenddb.delete("@DSDB_LOCK_TEST") # Obtain a write lock @@ -335,7 +335,7 @@ class DsdbLockTestCase(SamDBTestCase): os.write(w1, b"started") self.assertEqual(os.read(r2, 3), b"add") - backenddb.add({"dn":"@DSDB_LOCK_TEST"}) + backenddb.add({"dn": "@DSDB_LOCK_TEST"}) backenddb.delete("@DSDB_LOCK_TEST") os.write(w1, b"added") diff --git a/python/samba/tests/dsdb_schema_attributes.py b/python/samba/tests/dsdb_schema_attributes.py index dbfafc4122d..d5ad336b13c 100644 --- a/python/samba/tests/dsdb_schema_attributes.py +++ b/python/samba/tests/dsdb_schema_attributes.py @@ -74,7 +74,7 @@ objectClass: attributeSchema adminDescription: """ + attr_name + """ adminDisplayName: """ + attr_name + """ cn: """ + attr_name + """ -attributeId: 1.3.6.1.4.1.7165.4.6.1.8.%d.""" % sub_oid + str(random.randint(1,100000)) + """ +attributeId: 1.3.6.1.4.1.7165.4.6.1.8.%d.""" % sub_oid + str(random.randint(1, 100000)) + """ attributeSyntax: 2.5.5.12 omSyntax: 64 instanceType: 4 diff --git a/python/samba/tests/hostconfig.py b/python/samba/tests/hostconfig.py index 526dc0fe4e3..94f511ccf3f 100644 --- a/python/samba/tests/hostconfig.py +++ b/python/samba/tests/hostconfig.py @@ -56,10 +56,10 @@ class ShareTests(TestCase): def test_iter(self): self.assertEquals([], list(self._get_shares({}))) - self.assertEquals([], list(self._get_shares({"global":{}}))) + self.assertEquals([], list(self._get_shares({"global": {}}))) self.assertEquals( ["bla"], - list(self._get_shares({"global":{}, "bla":{}}))) + list(self._get_shares({"global": {}, "bla": {}}))) def test_len(self): shares = self._get_shares({"global": {}}) diff --git a/python/samba/tests/password_hash_fl2003.py b/python/samba/tests/password_hash_fl2003.py index e1a7ec94452..bcf17f8f227 100644 --- a/python/samba/tests/password_hash_fl2003.py +++ b/python/samba/tests/password_hash_fl2003.py @@ -197,5 +197,5 @@ class PassWordHashFl2003Tests(PassWordHashTests): # up = ndr_unpack(drsblobs.package_PrimaryUserPasswordBlob, binascii.a2b_hex(up_package.data)) - self.checkUserPassword(up, [("{CRYPT}", "6",10000)]) + self.checkUserPassword(up, [("{CRYPT}", "6", 10000)]) self.checkNtHash(USER_PASS, up.current_nt_hash.hash) diff --git a/python/samba/tests/password_hash_fl2008.py b/python/samba/tests/password_hash_fl2008.py index 70455a6e9d8..91064b4f11b 100644 --- a/python/samba/tests/password_hash_fl2008.py +++ b/python/samba/tests/password_hash_fl2008.py @@ -112,7 +112,7 @@ class PassWordHashFl2008Tests(PassWordHashTests): # up = ndr_unpack(drsblobs.package_PrimaryUserPasswordBlob, binascii.a2b_hex(up_package.data)) - self.checkUserPassword(up, [("{CRYPT}", "6",None)]) + self.checkUserPassword(up, [("{CRYPT}", "6", None)]) self.checkNtHash(USER_PASS, up.current_nt_hash.hash) def test_supplementalCredentials_cleartext(self): @@ -206,5 +206,5 @@ class PassWordHashFl2008Tests(PassWordHashTests): # up = ndr_unpack(drsblobs.package_PrimaryUserPasswordBlob, binascii.a2b_hex(up_package.data)) - self.checkUserPassword(up, [("{CRYPT}", "5",100)]) + self.checkUserPassword(up, [("{CRYPT}", "5", 100)]) self.checkNtHash(USER_PASS, up.current_nt_hash.hash) diff --git a/python/samba/tests/posixacl.py b/python/samba/tests/posixacl.py index 97ce6bb4a6f..5926c11b158 100644 --- a/python/samba/tests/posixacl.py +++ b/python/samba/tests/posixacl.py @@ -80,7 +80,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf, direct_db_access=True) anysid = security.dom_sid(security.SID_NT_SELF) - self.assertEquals(facl.as_sddl(anysid),acl) + self.assertEquals(facl.as_sddl(anysid), acl) def test_setntacl_smbd_setposixacl_getntacl(self): acl = ACL @@ -147,7 +147,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf, direct_db_access=False) anysid = security.dom_sid(security.SID_NT_SELF) - self.assertEquals(facl.as_sddl(anysid),acl) + self.assertEquals(facl.as_sddl(anysid), acl) def test_setntacl_smbd_getntacl_smbd(self): acl = ACL @@ -155,7 +155,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf, direct_db_access=False) anysid = security.dom_sid(security.SID_NT_SELF) - self.assertEquals(facl.as_sddl(anysid),acl) + self.assertEquals(facl.as_sddl(anysid), acl) def test_setntacl_smbd_setposixacl_getntacl_smbd(self): acl = ACL @@ -176,11 +176,11 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) # This invalidates the hash of the NT acl just set because there is a hook in the posix ACL set code s4_passdb = passdb.PDB(self.lp.get("passdb backend")) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) smbd.set_simple_acl(self.tempf, 0o640, BA_gid) # This should re-calculate an ACL based on the posix details - facl = getntacl(self.lp,self.tempf, direct_db_access=False) + facl = getntacl(self.lp, self.tempf, direct_db_access=False) anysid = security.dom_sid(security.SID_NT_SELF) self.assertEquals(simple_acl_from_posix, facl.as_sddl(anysid)) @@ -190,7 +190,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf, direct_db_access=False) domsid = security.dom_sid(DOM_SID) - self.assertEquals(facl.as_sddl(domsid),acl) + self.assertEquals(facl.as_sddl(domsid), acl) def test_setntacl_getposixacl(self): acl = ACL @@ -198,7 +198,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf) anysid = security.dom_sid(security.SID_NT_SELF) - self.assertEquals(facl.as_sddl(anysid),acl) + self.assertEquals(facl.as_sddl(anysid), acl) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) def test_setposixacl_getntacl(self): @@ -221,10 +221,10 @@ class PosixAclMappingTests(TestCaseInTempDir): user_SID = s4_passdb.uid_to_sid(os.stat(self.tempdir).st_uid) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) - (BA_id,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_id, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS) - (SO_id,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_id, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) smbd.chown(self.tempdir, BA_id, SO_id) smbd.set_simple_acl(self.tempdir, 0o750) @@ -237,7 +237,7 @@ class PosixAclMappingTests(TestCaseInTempDir): def test_setposixacl_group_getntacl_smbd(self): BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) group_SID = s4_passdb.gid_to_sid(os.stat(self.tempf).st_gid) user_SID = s4_passdb.uid_to_sid(os.stat(self.tempf).st_uid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) @@ -285,7 +285,7 @@ class PosixAclMappingTests(TestCaseInTempDir): def test_setposixacl_group_getposixacl(self): BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) smbd.set_simple_acl(self.tempf, 0o670, BA_gid) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) @@ -315,7 +315,7 @@ class PosixAclMappingTests(TestCaseInTempDir): setntacl(self.lp, self.tempf, acl, str(domsid), use_ntvfs=False, session_info=session_info) facl = getntacl(self.lp, self.tempf) - self.assertEquals(facl.as_sddl(domsid),acl) + self.assertEquals(facl.as_sddl(domsid), acl) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) nwrap_module_so_path = os.getenv('NSS_WRAPPER_MODULE_SO_PATH') @@ -335,15 +335,15 @@ class PosixAclMappingTests(TestCaseInTempDir): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) - (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_gid, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) + (SY_gid, SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) + (AU_gid, AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 13, self.print_posix_acl(posix_acl)) @@ -463,7 +463,7 @@ class PosixAclMappingTests(TestCaseInTempDir): setntacl(self.lp, self.tempdir, acl, str(domsid), use_ntvfs=False, session_info=session_info) facl = getntacl(self.lp, self.tempdir) - self.assertEquals(facl.as_sddl(domsid),acl) + self.assertEquals(facl.as_sddl(domsid), acl) posix_acl = smbd.get_sys_acl(self.tempdir, smb_acl.SMB_ACL_TYPE_ACCESS) LA_sid = security.dom_sid(str(domsid) + "-" + str(security.DOMAIN_RID_ADMINISTRATOR)) @@ -477,15 +477,15 @@ class PosixAclMappingTests(TestCaseInTempDir): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) - (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_gid, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) + (SY_gid, SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) + (AU_gid, AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 13, self.print_posix_acl(posix_acl)) @@ -558,7 +558,7 @@ class PosixAclMappingTests(TestCaseInTempDir): setntacl(self.lp, self.tempdir, acl, str(domsid), use_ntvfs=False, session_info=session_info) facl = getntacl(self.lp, self.tempdir) - self.assertEquals(facl.as_sddl(domsid),acl) + self.assertEquals(facl.as_sddl(domsid), acl) posix_acl = smbd.get_sys_acl(self.tempdir, smb_acl.SMB_ACL_TYPE_ACCESS) LA_sid = security.dom_sid(str(domsid) + "-" + str(security.DOMAIN_RID_ADMINISTRATOR)) @@ -573,17 +573,17 @@ class PosixAclMappingTests(TestCaseInTempDir): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) - (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_gid, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) + (SY_gid, SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) + (AU_gid, AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) - (PA_gid,PA_type) = s4_passdb.sid_to_id(PA_sid) + (PA_gid, PA_type) = s4_passdb.sid_to_id(PA_sid) self.assertEquals(PA_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 15, self.print_posix_acl(posix_acl)) @@ -667,7 +667,7 @@ class PosixAclMappingTests(TestCaseInTempDir): setntacl(self.lp, self.tempf, acl, str(domsid), use_ntvfs=False, session_info=session_info) facl = getntacl(self.lp, self.tempf) - self.assertEquals(facl.as_sddl(domsid),acl) + self.assertEquals(facl.as_sddl(domsid), acl) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) nwrap_module_so_path = os.getenv('NSS_WRAPPER_MODULE_SO_PATH') @@ -688,17 +688,17 @@ class PosixAclMappingTests(TestCaseInTempDir): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) - (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_gid, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) + (SY_gid, SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) + (AU_gid, AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) - (PA_gid,PA_type) = s4_passdb.sid_to_id(PA_sid) + (PA_gid, PA_type) = s4_passdb.sid_to_id(PA_sid) self.assertEquals(PA_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 15, self.print_posix_acl(posix_acl)) diff --git a/python/samba/tests/samba3sam.py b/python/samba/tests/samba3sam.py index a5e39eebe59..1221435fcbc 100644 --- a/python/samba/tests/samba3sam.py +++ b/python/samba/tests/samba3sam.py @@ -203,7 +203,7 @@ class Samba3SamTestCase(MapBaseTestCase): # msg = self.ldb.search(expression="(cn=Foo)", base="cn=Foo", scope=SCOPE_BASE, - attrs=['foo','blah','cn','showInAdvancedViewOnly']) + attrs=['foo', 'blah', 'cn', 'showInAdvancedViewOnly']) self.assertEquals(len(msg), 1) self.assertEquals(str(msg[0]["showInAdvancedViewOnly"]), "TRUE") self.assertEquals(str(msg[0]["foo"]), "bar") @@ -218,14 +218,14 @@ class Samba3SamTestCase(MapBaseTestCase): # Checking for existence of record (remote) msg = self.ldb.search(expression="(unixName=bin)", - attrs=['unixName','cn','dn', 'sambaUnicodePwd']) + attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd']) self.assertEquals(len(msg), 1) self.assertEquals(str(msg[0]["cn"]), "Niemand") self.assertEquals(str(msg[0]["sambaUnicodePwd"]), "geheim") # Checking for existence of record (local && remote) msg = self.ldb.search(expression="(&(unixName=bin)(sambaUnicodePwd=geheim))", - attrs=['unixName','cn','dn', 'sambaUnicodePwd']) + attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd']) self.assertEquals(len(msg), 1) # TODO: should check with more records self.assertEquals(str(msg[0]["cn"]), "Niemand") self.assertEquals(str(msg[0]["unixName"]), "bin") @@ -233,7 +233,7 @@ class Samba3SamTestCase(MapBaseTestCase): # Checking for existence of record (local || remote) msg = self.ldb.search(expression="(|(unixName=bin)(sambaUnicodePwd=geheim))", - attrs=['unixName','cn','dn', 'sambaUnicodePwd']) + attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd']) #print "got %d replies" % len(msg) self.assertEquals(len(msg), 1) # TODO: should check with more records self.assertEquals(str(msg[0]["cn"]), "Niemand") @@ -806,7 +806,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(str(res[4]["lastLogon"]), "z") # Clean up - dns = [self.samba4.dn("cn=%s" % n) for n in ["A","B","C","X","Y","Z"]] + dns = [self.samba4.dn("cn=%s" % n) for n in ["A", "B", "C", "X", "Y", "Z"]] for dn in dns: self.ldb.delete(dn) diff --git a/python/samba/tests/samba_tool/dnscmd.py b/python/samba/tests/samba_tool/dnscmd.py index 5c27c80f783..bc0e133c81c 100644 --- a/python/samba/tests/samba_tool/dnscmd.py +++ b/python/samba/tests/samba_tool/dnscmd.py @@ -88,12 +88,12 @@ class DnsCmdTestCase(SambaToolCmdTest): "::1", "::", "1:1:1:1:1:1:1:1"], - "PTR":good_dns, - "CNAME":good_dns, - "NS":good_dns, - "MX":good_mx, - "SRV":good_srv, - "TXT":["text", "", "@#!", "\n"] + "PTR": good_dns, + "CNAME": good_dns, + "NS": good_dns, + "MX": good_mx, + "SRV": good_srv, + "TXT": ["text", "", "@#!", "\n"] } self.bad_records = { @@ -105,11 +105,11 @@ class DnsCmdTestCase(SambaToolCmdTest): "1234:5678:9ABC:DEF0:1234:5678:9ABC:DEF0:1234", "1234:5678:9ABC:DEF0:1234:5678:9ABC", "1111::1111::1111"], - "PTR":bad_dns, - "CNAME":bad_dns, - "NS":bad_dns, - "MX":bad_mx, - "SRV":bad_srv + "PTR": bad_dns, + "CNAME": bad_dns, + "NS": bad_dns, + "MX": bad_mx, + "SRV": bad_srv } def tearDown(self): diff --git a/python/samba/tests/samba_tool/forest.py b/python/samba/tests/samba_tool/forest.py index 1f2194671e9..11c77e6105e 100644 --- a/python/samba/tests/samba_tool/forest.py +++ b/python/samba/tests/samba_tool/forest.py @@ -49,7 +49,7 @@ class ForestCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("dsheuristics: ", out) def test_modify_dsheuristics(self): @@ -62,5 +62,5 @@ class ForestCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("set dsheuristics: 0000002", out) diff --git a/python/samba/tests/samba_tool/fsmo.py b/python/samba/tests/samba_tool/fsmo.py index dcef4e5209b..51b735ebcfb 100644 --- a/python/samba/tests/samba_tool/fsmo.py +++ b/python/samba/tests/samba_tool/fsmo.py @@ -26,7 +26,7 @@ class FsmoCmdTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd("fsmo", "show") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") # Check that the output is sensible samdb = self.getSamDB("-H", "ldap://%s" % os.environ["SERVER"], diff --git a/python/samba/tests/samba_tool/group.py b/python/samba/tests/samba_tool/group.py index bc966ff3e22..8b6fc889cf1 100644 --- a/python/samba/tests/samba_tool/group.py +++ b/python/samba/tests/samba_tool/group.py @@ -88,7 +88,7 @@ class GroupCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","There shouldn't be any error message") + self.assertEquals(err, "", "There shouldn't be any error message") self.assertIn("Added group %s" % group["name"], out) found = self._find_group(group["name"]) @@ -177,7 +177,7 @@ class GroupCmdTestCase(SambaToolCmdTest): "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("dn: CN=Domain Users,CN=Users,DC=samba,DC=example,DC=com", out) def _randomGroup(self, base={}): diff --git a/python/samba/tests/samba_tool/join.py b/python/samba/tests/samba_tool/join.py index 1cc688f75dd..bfb534cd297 100644 --- a/python/samba/tests/samba_tool/join.py +++ b/python/samba/tests/samba_tool/join.py @@ -26,4 +26,4 @@ class JoinCmdTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd("domain", "join", os.environ["REALM"], "dc", "-U%s%%%s" % (os.environ["USERNAME"], os.environ["PASSWORD"])) self.assertCmdFail(result) - self.assertTrue("Not removing account" in err,"Should fail with exception") + self.assertTrue("Not removing account" in err, "Should fail with exception") diff --git a/python/samba/tests/samba_tool/ntacl.py b/python/samba/tests/samba_tool/ntacl.py index 3da75065548..4078c271d98 100644 --- a/python/samba/tests/samba_tool/ntacl.py +++ b/python/samba/tests/samba_tool/ntacl.py @@ -32,7 +32,7 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd("ntacl", "sysvolreset", "--use-ntvfs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(out, "", "Shouldn't be any output messages") self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err) def test_s3fs(self): @@ -40,34 +40,34 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest): "--use-s3fs") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") def test_ntvfs_check(self): (result, out, err) = self.runsubcmd("ntacl", "sysvolreset", "--use-ntvfs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(out, "", "Shouldn't be any output messages") self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err) # Now check they were set correctly (result, out, err) = self.runsubcmd("ntacl", "sysvolcheck") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") def test_s3fs_check(self): (result, out, err) = self.runsubcmd("ntacl", "sysvolreset", "--use-s3fs") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") # Now check they were set correctly (result, out, err) = self.runsubcmd("ntacl", "sysvolcheck") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") class NtACLCmdGetSetTestCase(SambaToolCmdTest): """Tests for samba-tool ntacl get/set subcommands""" @@ -77,59 +77,59 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest): def test_ntvfs(self): path = os.environ['SELFTEST_PREFIX'] - tempf = os.path.join(path,"pytests" +str(int(100000 * random.random()))) + tempf = os.path.join(path, "pytests" + str(int(100000 * random.random()))) open(tempf, 'w').write("empty") (result, out, err) = self.runsubcmd("ntacl", "set", self.acl, tempf, "--use-ntvfs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(out, "", "Shouldn't be any output messages") self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err) def test_s3fs(self): path = os.environ['SELFTEST_PREFIX'] - tempf = os.path.join(path,"pytests" +str(int(100000 * random.random()))) + tempf = os.path.join(path, "pytests" + str(int(100000 * random.random()))) open(tempf, 'w').write("empty") (result, out, err) = self.runsubcmd("ntacl", "set", self.acl, tempf, "--use-s3fs") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") def test_ntvfs_check(self): path = os.environ['SELFTEST_PREFIX'] - tempf = os.path.join(path,"pytests" +str(int(100000 * random.random()))) + tempf = os.path.join(path, "pytests" + str(int(100000 * random.random()))) open(tempf, 'w').write("empty") (result, out, err) = self.runsubcmd("ntacl", "set", self.acl, tempf, "--use-ntvfs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(out, "", "Shouldn't be any output messages") self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err) # Now check they were set correctly (result, out, err) = self.runsubcmd("ntacl", "get", tempf, "--use-ntvfs", "--as-sddl") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertEquals(self.acl + "\n", out, "Output should be the ACL") def test_s3fs_check(self): path = os.environ['SELFTEST_PREFIX'] - tempf = os.path.join(path,"pytests" + str(int(100000 *random.random()))) + tempf = os.path.join(path, "pytests" + str(int(100000 * random.random()))) open(tempf, 'w').write("empty") (result, out, err) = self.runsubcmd("ntacl", "set", self.acl, tempf, "--use-s3fs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") # Now check they were set correctly (result, out, err) = self.runsubcmd("ntacl", "get", tempf, "--use-s3fs", "--as-sddl") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(self.acl + "\n", out,"Output should be the ACL") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(self.acl + "\n", out, "Output should be the ACL") diff --git a/python/samba/tests/samba_tool/rodc.py b/python/samba/tests/samba_tool/rodc.py index 3ae52449890..2259f06aa7d 100644 --- a/python/samba/tests/samba_tool/rodc.py +++ b/python/samba/tests/samba_tool/rodc.py @@ -35,7 +35,7 @@ class RodcCmdTestCase(SambaToolCmdTest): self.creds.guess(self.lp) self.session = system_session() self.ldb = SamDB("ldap://" + os.environ["DC_SERVER"], - session_info=self.session, credentials=self.creds,lp=self.lp) + session_info=self.session, credentials=self.creds, lp=self.lp) self.base_dn = self.ldb.domain_dn() diff --git a/python/samba/tests/samba_tool/schema.py b/python/samba/tests/samba_tool/schema.py index 56d09a78de7..ae095994e53 100644 --- a/python/samba/tests/samba_tool/schema.py +++ b/python/samba/tests/samba_tool/schema.py @@ -40,7 +40,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("dn: CN=uid,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) def test_modify_attribute_searchflags(self): @@ -60,7 +60,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("modified cn=uid,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) (result, out, err) = self.runsublevelcmd("schema", ("attribute", @@ -71,7 +71,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("modified cn=uid,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) (result, out, err) = self.runsublevelcmd("schema", ("attribute", @@ -82,7 +82,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("modified cn=uid,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) def test_show_oc_attribute(self): @@ -94,7 +94,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("--- MAY contain ---", out) self.assertIn("--- MUST contain ---", out) @@ -107,7 +107,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("dn: CN=Person,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py index 4d264b4027d..4d39e822720 100644 --- a/python/samba/tests/samba_tool/user.py +++ b/python/samba/tests/samba_tool/user.py @@ -52,7 +52,7 @@ class UserCmdTestCase(SambaToolCmdTest): (result, out, err) = user["createUserFn"](user) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("User '%s' created successfully" % user["name"], out) user["checkUserFn"](user) @@ -94,7 +94,7 @@ class UserCmdTestCase(SambaToolCmdTest): "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("User '%s' created successfully" % user["name"], out) found = self._find_user(user["name"]) @@ -194,7 +194,7 @@ class UserCmdTestCase(SambaToolCmdTest): "-H", "ldap://%s" % os.environ["DC_SERVER"], "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err, "Ensure setpassword runs") - self.assertEquals(err,"","setpassword with url") + self.assertEquals(err, "", "setpassword with url") self.assertMatch(out, "Changed password OK", "setpassword with url") attributes = "sAMAccountName,unicodePwd,supplementalCredentials,virtualClearTextUTF8,virtualClearTextUTF16,virtualSSHA,virtualSambaGPG" @@ -203,7 +203,7 @@ class UserCmdTestCase(SambaToolCmdTest): "--attributes=%s" % attributes, "--decrypt-samba-gpg") self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --cache-ldb-initialize runs") - self.assertEqual(err,"","getpassword without url") + self.assertEqual(err, "", "getpassword without url") cache_attrs = { "objectClass": {"value": "userSyncPasswords"}, "samdbUrl": {}, @@ -221,7 +221,7 @@ class UserCmdTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd("user", "syncpasswords", "--no-wait") self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --no-wait runs") - self.assertEqual(err,"","syncpasswords --no-wait") + self.assertEqual(err, "", "syncpasswords --no-wait") self.assertMatch(out, "dirsync_loop(): results 0", "syncpasswords --no-wait: 'dirsync_loop(): results 0': out[%s]" % (out)) for user in self.users: @@ -242,12 +242,12 @@ class UserCmdTestCase(SambaToolCmdTest): user["name"], "--newpassword=%s" % newpasswd) self.assertCmdSuccess(result, out, err, "Ensure setpassword runs") - self.assertEquals(err,"","setpassword without url") + self.assertEquals(err, "", "setpassword without url") self.assertMatch(out, "Changed password OK", "setpassword without url") (result, out, err) = self.runsubcmd("user", "syncpasswords", "--no-wait") self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --no-wait runs") - self.assertEqual(err,"","syncpasswords --no-wait") + self.assertEqual(err, "", "syncpasswords --no-wait") self.assertMatch(out, "dirsync_loop(): results 0", "syncpasswords --no-wait: 'dirsync_loop(): results 0': out[%s]" % (out)) self.assertMatch(out, "sAMAccountName: %s" % (user["name"]), @@ -273,7 +273,7 @@ class UserCmdTestCase(SambaToolCmdTest): "--attributes=%s" % attributes, "--decrypt-samba-gpg") self.assertCmdSuccess(result, out, err, "Ensure getpassword runs") - self.assertEqual(err,"","getpassword without url") + self.assertEqual(err, "", "getpassword without url") self.assertMatch(out, "Got password OK", "getpassword without url") self.assertMatch(out, "sAMAccountName: %s" % (user["name"]), "getpassword: 'sAMAccountName': %s out[%s]" % (user["name"], out)) @@ -299,7 +299,7 @@ class UserCmdTestCase(SambaToolCmdTest): "-H", "ldap://%s" % os.environ["DC_SERVER"], "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err, "Ensure setpassword runs") - self.assertEquals(err,"","setpassword with forced change") + self.assertEquals(err, "", "setpassword with forced change") self.assertMatch(out, "Changed password OK", "setpassword with forced change") @@ -464,7 +464,7 @@ sAMAccountName: %s "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("User '%s' created successfully" % user["name"], out) self._check_posix_user(user) @@ -493,7 +493,7 @@ sAMAccountName: %s "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("User '%s' created successfully" % user["name"], out) self._check_posix_user(user) diff --git a/python/samba/tests/security.py b/python/samba/tests/security.py index 02c1e8897f6..ed959ee5499 100644 --- a/python/samba/tests/security.py +++ b/python/samba/tests/security.py @@ -66,10 +66,10 @@ class SecurityDescriptorTests(samba.tests.TestCase): self.assertEquals(desc.type, 0x8004) def test_from_sddl_invalidsddl(self): - self.assertRaises(TypeError,security.descriptor.from_sddl, "foo",security.dom_sid("S-2-0-0")) + self.assertRaises(TypeError, security.descriptor.from_sddl, "foo", security.dom_sid("S-2-0-0")) def test_from_sddl_invalidtype1(self): - self.assertRaises(TypeError, security.descriptor.from_sddl, security.dom_sid('S-2-0-0-512'),security.dom_sid("S-2-0-0")) + self.assertRaises(TypeError, security.descriptor.from_sddl, security.dom_sid('S-2-0-0-512'), security.dom_sid("S-2-0-0")) def test_from_sddl_invalidtype2(self): sddl = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)" @@ -90,7 +90,7 @@ class SecurityDescriptorTests(samba.tests.TestCase): text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)" dom = security.dom_sid("S-2-0-0") desc1 = security.descriptor.from_sddl(text, dom) - self.assertRaises(TypeError, desc1.as_sddl,text) + self.assertRaises(TypeError, desc1.as_sddl, text) def test_as_sddl_no_domainsid(self): diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py index 296815f3a97..59fd6ed9d41 100644 --- a/python/samba/tests/smb.py +++ b/python/samba/tests/smb.py @@ -25,7 +25,7 @@ utf_contents = u'Süßigkeiten Äpfel ' * 128 test_literal_bytes_embed_nulls = b'\xff\xfe\x14\x61\x00\x00\x62\x63\x64' * 256 binary_contents = b'\xff\xfe' binary_contents = binary_contents + "Hello cruel world of python3".encode('utf8') * 128 -test_dir = os.path.join(addom, 'testing_%d' % random.randint(0,0xFFFF)) +test_dir = os.path.join(addom, 'testing_%d' % random.randint(0, 0xFFFF)) test_file = os.path.join(test_dir, 'testing').replace('/', '\\') class SMBTests(samba.tests.TestCase): @@ -50,7 +50,7 @@ class SMBTests(samba.tests.TestCase): ls = [f['name'] for f in self.conn.list(addom)] self.assertIn('scripts', ls, msg='"scripts" directory not found in sysvol') - self.assertIn('Policies',ls, + self.assertIn('Policies', ls, msg='"Policies" directory not found in sysvol') def test_unlink(self): diff --git a/python/samba/tests/upgradeprovisionneeddc.py b/python/samba/tests/upgradeprovisionneeddc.py index 9e523961691..73a3152ca46 100644 --- a/python/samba/tests/upgradeprovisionneeddc.py +++ b/python/samba/tests/upgradeprovisionneeddc.py @@ -24,7 +24,7 @@ import shutil from samba import param from samba.credentials import Credentials from samba.auth import system_session -from samba.provision import getpolicypath,find_provision_key_parameters +from samba.provision import getpolicypath, find_provision_key_parameters from samba.upgradehelpers import (get_paths, get_ldbs, identic_rename, updateOEMInfo, getOEMInfo, update_gpo, diff --git a/python/samba/upgrade.py b/python/samba/upgrade.py index 18c8afd3f1b..fe3309af166 100644 --- a/python/samba/upgrade.py +++ b/python/samba/upgrade.py @@ -665,7 +665,7 @@ Please fix this account before attempting to upgrade again creds.guess(samba3.lp) creds.set_bind_dn(ldapuser) creds.set_password(ldappass) - urls = samba3.lp.get("passdb backend").split(":",1)[1].strip('"') + urls = samba3.lp.get("passdb backend").split(":", 1)[1].strip('"') for url in urls.split(): try: ldb_object = Ldb(url, credentials=creds) diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py index 2e6ed1cfdbc..262f664fc10 100644 --- a/python/samba/upgradehelpers.py +++ b/python/samba/upgradehelpers.py @@ -62,8 +62,8 @@ hashAttrNotCopied = set(["dn", "whenCreated", "whenChanged", "objectGUID", "objectCategory", "distinguishedName", "nTMixedDomain", "showInAdvancedViewOnly", "instanceType", "msDS-Behavior-Version", "nextRid", "cn", "versionNumber", "lmPwdHistory", "pwdLastSet", - "ntPwdHistory", "unicodePwd","dBCSPwd", "supplementalCredentials", - "gPCUserExtensionNames", "gPCMachineExtensionNames","maxPwdAge", "secret", + "ntPwdHistory", "unicodePwd", "dBCSPwd", "supplementalCredentials", + "gPCUserExtensionNames", "gPCMachineExtensionNames", "maxPwdAge", "secret", "possibleInferiors", "privilege", "sAMAccountType"]) @@ -221,15 +221,15 @@ def update_policyids(names, samdb): # policy guid res = samdb.search(expression="(displayName=Default Domain Policy)", base="CN=Policies,CN=System," + str(names.rootdn), - scope=SCOPE_ONELEVEL, attrs=["cn","displayName"]) - names.policyid = str(res[0]["cn"]).replace("{","").replace("}","") + scope=SCOPE_ONELEVEL, attrs=["cn", "displayName"]) + names.policyid = str(res[0]["cn"]).replace("{", "").replace("}", "") # dc policy guid res2 = samdb.search(expression="(displayName=Default Domain Controllers" " Policy)", base="CN=Policies,CN=System," + str(names.rootdn), - scope=SCOPE_ONELEVEL, attrs=["cn","displayName"]) + scope=SCOPE_ONELEVEL, attrs=["cn", "displayName"]) if len(res2) == 1: - names.policyid_dc = str(res2[0]["cn"]).replace("{","").replace("}","") + names.policyid_dc = str(res2[0]["cn"]).replace("{", "").replace("}", "") else: names.policyid_dc = None @@ -290,7 +290,7 @@ def dn_sort(x, y): return ret else: if i == minimum - 1: - assert len1 != len2,"PB PB PB" + " ".join(tab1) + " / " + " ".join(tab2) + assert len1 != len2, "PB PB PB" + " ".join(tab1) + " / " + " ".join(tab2) if len1 > len2: return 1 else: @@ -480,7 +480,7 @@ def increment_calculated_keyversion_number(samdb, rootdn, hashDns): have """ entry = samdb.search(expression='(objectClass=user)', - base=ldb.Dn(samdb,str(rootdn)), + base=ldb.Dn(samdb, str(rootdn)), scope=SCOPE_SUBTREE, attrs=["msDs-KeyVersionNumber"], controls=["search_options:1:2"]) done = 0 @@ -560,7 +560,7 @@ def construct_existor_expr(attrs): if len(attrs) > 0: expr = "(|" for att in attrs: - expr = "%s(%s=*)" %(expr,att) + expr = "%s(%s=*)" %(expr, att) expr = "%s)" %expr return expr @@ -681,7 +681,7 @@ def search_constructed_attrs_stored(samdb, rootdn, attrs): return hashAtt entry = samdb.search(expression=expr, base=ldb.Dn(samdb, str(rootdn)), scope=SCOPE_SUBTREE, attrs=attrs, - controls=["search_options:1:2","bypassoperational:0"]) + controls=["search_options:1:2", "bypassoperational:0"]) if len(entry) == 0: # Nothing anymore return hashAtt @@ -809,9 +809,9 @@ def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid): print("To track the USNs modified/created by provision and upgrade proivsion,") print(" the following ranges are proposed to be added to your provision sam.ldb: \n%s" % ldif) print("We recommend to review them, and if it's correct to integrate the following ldif: %s in your sam.ldb" % file) - print("You can load this file like this: ldbadd -H %s %s\n" %(str(samdb_path),file)) + print("You can load this file like this: ldbadd -H %s %s\n" %(str(samdb_path), file)) ldif = "dn: @PROVISION\nprovisionnerID: %s\n%s" % (invocationid, ldif) - open(file,'w').write(ldif) + open(file, 'w').write(ldif) def int64range2str(value): """Display the int64 range stored in value as xxx-yyy diff --git a/python/samba/web_server/__init__.py b/python/samba/web_server/__init__.py index 6aa0872953f..4344fccfaa7 100644 --- a/python/samba/web_server/__init__.py +++ b/python/samba/web_server/__init__.py @@ -61,7 +61,7 @@ def __call__(environ, start_response): if name == "": if have_swat: start_response('301 Redirect', - [('Location', urljoin(application_uri(environ), 'swat')),]) + [('Location', urljoin(application_uri(environ), 'swat')), ]) return [] else: return render_placeholder(environ, start_response) diff --git a/script/autobuild.py b/script/autobuild.py index 13671900997..3a7abeea744 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -4,7 +4,7 @@ # released under GNU GPL v3 or later from __future__ import print_function -from subprocess import call, check_call,Popen, PIPE +from subprocess import call, check_call, Popen, PIPE import os, tarfile, sys, time from optparse import OptionParser import smtplib @@ -159,7 +159,7 @@ tasks = { "samba-test-only": [("configure", "./configure.developer --with-selftest-prefix=./bin/ab --abi-check-disable" + samba_configure_params, "text/plain"), ("make", "make -j", "text/plain"), - ("test", 'make test FAIL_IMMEDIATELY=1 TESTS="${TESTS}"',"text/plain")], + ("test", 'make test FAIL_IMMEDIATELY=1 TESTS="${TESTS}"', "text/plain")], # Test cross-compile infrastructure "samba-xc": [("random-sleep", "script/random-sleep.sh 60 600", "text/plain"), diff --git a/script/bisect-test.py b/script/bisect-test.py index 71c68b0d727..e06d7834117 100755 --- a/script/bisect-test.py +++ b/script/bisect-test.py @@ -13,7 +13,7 @@ parser.add_option("", "--good", help="known good revision (default HEAD~100)", d parser.add_option("", "--bad", help="known bad revision (default HEAD)", default='HEAD') parser.add_option("", "--skip-build-errors", help="skip revision where make fails", action='store_true', default=False) -parser.add_option("", "--autogen", help="run autogen before each build",action="store_true", default=False) +parser.add_option("", "--autogen", help="run autogen before each build", action="store_true", default=False) parser.add_option("", "--autogen-command", help="command to use for autogen (default ./autogen.sh)", type='str', default="./autogen.sh") parser.add_option("", "--configure", help="run configure.developer before each build", diff --git a/script/compare_cc_results.py b/script/compare_cc_results.py index 17b43f08d43..a3a9d113741 100755 --- a/script/compare_cc_results.py +++ b/script/compare_cc_results.py @@ -34,7 +34,7 @@ for fname in sys.argv[1:]: lines.append(line) f.close() if base_fname: - diff = list(difflib.unified_diff(base_lines,lines,base_fname,fname)) + diff = list(difflib.unified_diff(base_lines, lines, base_fname, fname)) if diff: print('configuration files %s and %s do not match' % (base_fname, fname)) for l in diff: diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index cfdaab69789..2955d80011c 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -199,7 +199,7 @@ def parse_results(msg_ops, statistics, fh): return exitcode -class SubunitOps(TestProtocolClient,TestsuiteEnabledTestResult): +class SubunitOps(TestProtocolClient, TestsuiteEnabledTestResult): def progress(self, count, whence): if whence == subunit.PROGRESS_POP: diff --git a/source3/script/tests/test_wbinfo_sids2xids_int.py b/source3/script/tests/test_wbinfo_sids2xids_int.py index 8e2be886c97..fe488300d4c 100755 --- a/source3/script/tests/test_wbinfo_sids2xids_int.py +++ b/source3/script/tests/test_wbinfo_sids2xids_int.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from __future__ import print_function -import sys,os,subprocess +import sys, os, subprocess if len(sys.argv) != 3: diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 889d49dd405..09711ce76a6 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -101,7 +101,7 @@ plantestsuite("samba3.smbtorture_s3.plain.%s(ad_dc)" % t, "ad_dc", [os.path.join # # RENAME-ACCESS needs to run against a special share - acl_xattr_ign_sysacl_windows # -plantestsuite("samba3.smbtorture_s3.plain(nt4_dc).%s" % "RENAME-ACCESS","nt4_dc", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), "RENAME-ACCESS", '//$SERVER_IP/acl_xattr_ign_sysacl_windows', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"]) +plantestsuite("samba3.smbtorture_s3.plain(nt4_dc).%s" % "RENAME-ACCESS", "nt4_dc", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), "RENAME-ACCESS", '//$SERVER_IP/acl_xattr_ign_sysacl_windows', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"]) plantestsuite("samba3.smbtorture_s3.crypt_client(nt4_dc).%s" % "RENAME-ACCESS", "nt4_dc", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), "RENAME-ACCESS", '//$SERVER_IP/acl_xattr_ign_sysacl_windows', '$USERNAME', '$PASSWORD', smbtorture3, "-e", "-l $LOCAL_PATH"]) # non-crypt only diff --git a/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py b/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py index 24dcb1c321a..6eb0b67cb85 100755 --- a/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py +++ b/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py @@ -53,7 +53,7 @@ else: def uniq_list(alist): """return a unique list""" set = {} - return [set.setdefault(e,e) for e in alist if e not in set] + return [set.setdefault(e, e) for e in alist if e not in set] lp_ctx = sambaopts.get_loadparm() @@ -108,7 +108,7 @@ def supclasses(classinfo, oc): res = classinfo[oc]["subClassOf"] for r in res: list.append(r) - list.extend(supclasses(classinfo,r)) + list.extend(supclasses(classinfo, r)) classinfo[oc]["SUPCLASSES"] = list return list @@ -231,7 +231,7 @@ def test_class(db, classinfo, oc): print("Returned incorrect list for objectclass %s" % oc) print("search: %s" % poss1) print("constructed: %s" % poss2) - for i in range(0,min(len(poss1),len(poss2))): + for i in range(0, min(len(poss1), len(poss2))): print("%30s %30s" % (poss1[i], poss2[i])) print("]") sys.exit(1) @@ -249,8 +249,8 @@ classinfo = pull_classinfo(db) if objectclass is None: for oc in get_object_classes(db): - test_class(db,classinfo,oc) + test_class(db, classinfo, oc) else: - test_class(db,classinfo,objectclass) + test_class(db, classinfo, objectclass) print("Lists match OK") diff --git a/source4/dsdb/tests/python/acl.py b/source4/dsdb/tests/python/acl.py index 92e0a1a7fe4..c6703ca56e4 100755 --- a/source4/dsdb/tests/python/acl.py +++ b/source4/dsdb/tests/python/acl.py @@ -1758,7 +1758,7 @@ class AclExtendedTests(AclTests): #u3 is member of administrators group, should be able to read sd res = self.ldb_user3.search("CN=ext_group1,OU=ext_ou1," + self.base_dn, SCOPE_BASE, None, ["nTSecurityDescriptor"]) - self.assertEqual(len(res),1) + self.assertEqual(len(res), 1) self.assertTrue("nTSecurityDescriptor" in res[0].keys()) class AclUndeleteTests(AclTests): diff --git a/source4/dsdb/tests/python/deletetest.py b/source4/dsdb/tests/python/deletetest.py index ca416e642ac..01e7a1d2378 100755 --- a/source4/dsdb/tests/python/deletetest.py +++ b/source4/dsdb/tests/python/deletetest.py @@ -63,7 +63,7 @@ class BaseDeleteTests(samba.tests.TestCase): self.assertEquals(len(res), 1) return res[0] - def search_dn(self,dn): + def search_dn(self, dn): print("SEARCH by DN %s" % dn) res = self.ldb.search(expression="(objectClass=*)", @@ -83,7 +83,7 @@ class BasicDeleteTests(BaseDeleteTests): def del_attr_values(self, delObj): print("Checking attributes for %s" % delObj["dn"]) - self.assertEquals(delObj["isDeleted"][0],"TRUE") + self.assertEquals(delObj["isDeleted"][0], "TRUE") self.assertTrue(not("objectCategory" in delObj)) self.assertTrue(not("sAMAccountType" in delObj)) diff --git a/source4/dsdb/tests/python/dirsync.py b/source4/dsdb/tests/python/dirsync.py index ca3a1e936f6..71ea23f05e8 100755 --- a/source4/dsdb/tests/python/dirsync.py +++ b/source4/dsdb/tests/python/dirsync.py @@ -554,7 +554,7 @@ class SimpleDirsyncTests(DirsyncBaseTests): guid = None for e in res: if str(e["name"]) == "testou3": - guid = str(ndr_unpack(misc.GUID,e.get("objectGUID")[0])) + guid = str(ndr_unpack(misc.GUID, e.get("objectGUID")[0])) ctl = str(res.controls[0]).split(":") ctl[1] = "1" @@ -570,7 +570,7 @@ class SimpleDirsyncTests(DirsyncBaseTests): expression="(objectClass=organizationalUnit)", controls=[control1]) self.assertEqual(len(res), 1) - guid2 = str(ndr_unpack(misc.GUID,res[0].get("objectGUID")[0])) + guid2 = str(ndr_unpack(misc.GUID, res[0].get("objectGUID")[0])) self.assertEqual(guid2, guid) self.assertTrue(res[0].get("isDeleted")) self.assertTrue(res[0].get("name") != None) @@ -674,7 +674,7 @@ class ExtendedDirsyncTests(SimpleDirsyncTests): guid = None for e in res: if str(e["name"]) == "testou3": - guid = str(ndr_unpack(misc.GUID,e.get("objectGUID")[0])) + guid = str(ndr_unpack(misc.GUID, e.get("objectGUID")[0])) self.assertTrue(guid != None) ctl = str(res.controls[0]).split(":") @@ -692,7 +692,7 @@ class ExtendedDirsyncTests(SimpleDirsyncTests): expression="(objectClass=organizationalUnit)", controls=[control1]) self.assertEqual(len(res), 1) - guid2 = str(ndr_unpack(misc.GUID,res[0].get("objectGUID")[0])) + guid2 = str(ndr_unpack(misc.GUID, res[0].get("objectGUID")[0])) self.assertEqual(guid2, guid) self.assertEqual(str(res[0].dn), "") diff --git a/source4/dsdb/tests/python/dsdb_schema_info.py b/source4/dsdb/tests/python/dsdb_schema_info.py index 648ee45b22f..a1eba2c0557 100755 --- a/source4/dsdb/tests/python/dsdb_schema_info.py +++ b/source4/dsdb/tests/python/dsdb_schema_info.py @@ -112,7 +112,7 @@ objectClass: attributeSchema adminDescription: """ + attr_name + """ adminDisplayName: """ + attr_name + """ cn: """ + attr_name + """ -attributeId: 1.3.6.1.4.1.7165.4.6.1.7.%d.""" % sub_oid + str(random.randint(1,100000)) + """ +attributeId: 1.3.6.1.4.1.7165.4.6.1.7.%d.""" % sub_oid + str(random.randint(1, 100000)) + """ attributeSyntax: 2.5.5.12 omSyntax: 64 instanceType: 4 @@ -158,7 +158,7 @@ objectClass: classSchema adminDescription: """ + class_name + """ adminDisplayName: """ + class_name + """ cn: """ + class_name + """ -governsId: 1.3.6.1.4.1.7165.4.6.2.7.%d.""" % sub_oid + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.7.%d.""" % sub_oid + str(random.randint(1, 100000)) + """ instanceType: 4 objectClassCategory: 1 subClassOf: organizationalPerson diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index 9d14e037eb3..6e4d3e3e39b 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -728,7 +728,7 @@ class BasicTests(samba.tests.TestCase): m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) - m["sAMAccountName"] = MessageElement(["nam1","nam2"], FLAG_MOD_REPLACE, + m["sAMAccountName"] = MessageElement(["nam1", "nam2"], FLAG_MOD_REPLACE, "sAMAccountName") try: ldb.modify(m) @@ -1378,7 +1378,7 @@ class BasicTests(samba.tests.TestCase): rdn = "CN=a012345678901234567890123456789012345678901234567890123456789012" delete_force(self.ldb, "%s,%s" % (rdn, self.base_dn)) ldif = """ -dn: %s,%s""" % (rdn,self.base_dn) + """ +dn: %s,%s""" % (rdn, self.base_dn) + """ objectClass: container """ self.ldb.add_ldif(ldif) @@ -1388,7 +1388,7 @@ objectClass: container delete_force(self.ldb, "%s,%s" % (rdn, self.base_dn)) try: ldif = """ -dn: %s,%s""" % (rdn,self.base_dn) + """ +dn: %s,%s""" % (rdn, self.base_dn) + """ objectClass: container """ self.ldb.add_ldif(ldif) @@ -1575,11 +1575,11 @@ objectGUID: bd3480c9-58af-4cd8-92df-bc4a18b6e44d """Test parentGUID behaviour""" self.ldb.add({ "dn": "cn=parentguidtest,cn=users," + self.base_dn, - "objectclass":"user", - "samaccountname":"parentguidtest"}) + "objectclass": "user", + "samaccountname": "parentguidtest"}) res1 = ldb.search(base="cn=parentguidtest,cn=users," + self.base_dn, scope=SCOPE_BASE, attrs=["parentGUID", "samaccountname"]) - res2 = ldb.search(base="cn=users," + self.base_dn,scope=SCOPE_BASE, + res2 = ldb.search(base="cn=users," + self.base_dn, scope=SCOPE_BASE, attrs=["objectGUID"]) res3 = ldb.search(base=self.base_dn, scope=SCOPE_BASE, attrs=["parentGUID"]) @@ -1630,8 +1630,8 @@ objectGUID: bd3480c9-58af-4cd8-92df-bc4a18b6e44d self.ldb.add({ "dn": "cn=testotherusers," + self.base_dn, - "objectclass":"container"}) - res1 = ldb.search(base="cn=testotherusers," + self.base_dn,scope=SCOPE_BASE, + "objectclass": "container"}) + res1 = ldb.search(base="cn=testotherusers," + self.base_dn, scope=SCOPE_BASE, attrs=["objectGUID"]) ldb.rename("cn=parentguidtest,cn=users," + self.base_dn, "cn=parentguidtest,cn=testotherusers," + self.base_dn) @@ -3072,7 +3072,7 @@ nTSecurityDescriptor:: """ + desc_base64 # there does not seem to be another limitation. try: dshstr = "" - for i in range(1,11): + for i in range(1, 11): # This is in the range self.ldb.set_dsheuristics(dshstr + "x") self.ldb.set_dsheuristics(dshstr + "xxxxx") diff --git a/source4/dsdb/tests/python/ldap_schema.py b/source4/dsdb/tests/python/ldap_schema.py index e98ab4a5656..3d4a9d9f039 100755 --- a/source4/dsdb/tests/python/ldap_schema.py +++ b/source4/dsdb/tests/python/ldap_schema.py @@ -99,7 +99,7 @@ class SchemaTests(samba.tests.TestCase): def test_schemaUpdateNow(self): """Testing schemaUpdateNow""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") @@ -131,7 +131,7 @@ schemaUpdateNow: 1 # Search for created attribute res = [] res = self.ldb.search("cn=%s,%s" % (attr_name, self.schema_dn), scope=SCOPE_BASE, - attrs=["lDAPDisplayName","schemaIDGUID", "msDS-IntID"]) + attrs=["lDAPDisplayName", "schemaIDGUID", "msDS-IntID"]) self.assertEquals(len(res), 1) self.assertEquals(res[0]["lDAPDisplayName"][0], attr_ldap_display_name) self.assertTrue("schemaIDGUID" in res[0]) @@ -154,7 +154,7 @@ defaultObjectCategory: CN=_ adminDescription: """ + class_name + """ adminDisplayName: """ + class_name + """ cn: """ + class_name + """ -governsId: 1.3.6.1.4.1.7165.4.6.2.6.1.""" + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.6.1.""" + str(random.randint(1, 100000)) + """ instanceType: 4 objectClassCategory: 1 subClassOf: organizationalPerson @@ -178,7 +178,7 @@ objectClass: classSchema adminDescription: """ + class_name + """ adminDisplayName: """ + class_name + """ cn: """ + class_name + """ -governsId: 1.3.6.1.4.1.7165.4.6.2.6.2.""" + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.6.2.""" + str(random.randint(1, 100000)) + """ instanceType: 4 objectClassCategory: 1 subClassOf: organizationalPerson @@ -260,7 +260,7 @@ objectClass: classSchema adminDescription: """ + class_name + """ adminDisplayName: """ + class_name + """ cn: """ + class_name + """ -governsId: 1.3.6.1.4.1.7165.4.6.2.6.3.""" + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.6.3.""" + str(random.randint(1, 100000)) + """ instanceType: 4 objectClassCategory: 1 subClassOf: organizationalUnit @@ -307,7 +307,7 @@ instanceType: 4 def test_duplicate_attributeID(self): """Testing creating a duplicate attribute""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.2." + rand @@ -351,7 +351,7 @@ systemOnly: FALSE def test_duplicate_attributeID_governsID(self): """Testing creating a duplicate attribute and class""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.3." + rand @@ -396,7 +396,7 @@ systemOnly: FALSE def test_duplicate_cn(self): """Testing creating a duplicate attribute""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.4." + rand @@ -439,7 +439,7 @@ systemOnly: FALSE def test_duplicate_implicit_ldapdisplayname(self): """Testing creating a duplicate attribute ldapdisplayname""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.5." + rand @@ -484,7 +484,7 @@ systemOnly: FALSE def test_duplicate_explicit_ldapdisplayname(self): """Testing creating a duplicate attribute ldapdisplayname""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.6." + rand @@ -531,7 +531,7 @@ systemOnly: FALSE def test_duplicate_explicit_ldapdisplayname_with_class(self): """Testing creating a duplicate attribute ldapdisplayname between and attribute and a class""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.7." + rand @@ -579,7 +579,7 @@ systemOnly: FALSE def test_duplicate_via_rename_ldapdisplayname(self): """Testing creating a duplicate attribute ldapdisplayname""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.8." + rand @@ -634,7 +634,7 @@ ldapDisplayName: """ + attr_ldap_display_name + """ def test_duplicate_via_rename_attributeID(self): """Testing creating a duplicate attributeID""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.9." + rand @@ -688,7 +688,7 @@ attributeId: """ + attributeID + """ def test_remove_ldapdisplayname(self): """Testing removing the ldapdisplayname""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.10." + rand @@ -724,7 +724,7 @@ replace: ldapDisplayName def test_rename_ldapdisplayname(self): """Testing renaming ldapdisplayname""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.11." + rand @@ -757,7 +757,7 @@ ldapDisplayName: """ + attr_ldap_display_name + """2 def test_change_attributeID(self): """Testing change the attributeID""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.12." + rand @@ -795,7 +795,7 @@ attributeId: """ + attributeID + """.1 def test_change_attributeID_same(self): """Testing change the attributeID to the same value""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name = "test-Attr" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name = attr_name.replace("-", "") attributeID = "1.3.6.1.4.1.7165.4.6.1.6.13." + rand @@ -849,7 +849,7 @@ attributeId: """ + attributeID + """ if dc_level < DS_DOMAIN_FUNCTION_2003: return - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name_1 = "test-generated-linkID" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name_1 = attr_name_1.replace("-", "") @@ -1130,7 +1130,7 @@ systemOnly: FALSE duplicate mAPIIDs. """ - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) attr_name_1 = "test-generated-mAPIID" + time.strftime("%s", time.gmtime()) + "-" + rand attr_ldap_display_name_1 = attr_name_1.replace("-", "") @@ -1203,7 +1203,7 @@ systemOnly: FALSE def test_change_governsID(self): """Testing change the governsID""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) class_name = "test-Class" + time.strftime("%s", time.gmtime()) + "-" + rand class_ldap_display_name = class_name.replace("-", "") governsID = "1.3.6.1.4.1.7165.4.6.2.6.5." + rand @@ -1242,7 +1242,7 @@ governsId: """ + governsID + """.1 def test_change_governsID_same(self): """Testing change the governsID""" - rand = str(random.randint(1,100000)) + rand = str(random.randint(1, 100000)) class_name = "test-Class" + time.strftime("%s", time.gmtime()) + "-" + rand class_ldap_display_name = class_name.replace("-", "") governsID = "1.3.6.1.4.1.7165.4.6.2.6.6." + rand @@ -1293,7 +1293,7 @@ objectClass: classSchema adminDescription: """ + class_name + """ adminDisplayName: """ + class_name + """ cn: """ + class_name + """ -governsId: 1.3.6.1.4.1.7165.4.6.2.6.7.""" + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.6.7.""" + str(random.randint(1, 100000)) + """ instanceType: 4 objectClassCategory: 1 subClassOf: organizationalUnit @@ -1382,7 +1382,7 @@ objectClass: attributeSchema adminDescription: """ + attr_name + """ adminDisplayName: """ + attr_name + """ cn: """ + attr_name + """ -attributeId: 1.3.6.1.4.1.7165.4.6.1.6.14.""" + str(random.randint(1,100000)) + """ +attributeId: 1.3.6.1.4.1.7165.4.6.1.6.14.""" + str(random.randint(1, 100000)) + """ attributeSyntax: 2.5.5.12 omSyntax: 64 instanceType: 4 @@ -1502,7 +1502,7 @@ objectClass: classSchema adminDescription: """ + class_name + """ adminDisplayName: """ + class_name + """ cn: """ + class_name + """ -governsId: 1.3.6.1.4.1.7165.4.6.2.6.%d.""" % sub_oid + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.6.%d.""" % sub_oid + str(random.randint(1, 100000)) + """ instanceType: 4 objectClassCategory: 1 subClassOf: organizationalPerson @@ -1654,7 +1654,7 @@ class SchemaTests_msDS_isRODC(samba.tests.TestCase): def test_objectClass_computer(self): res = self.ldb.search(self.base_dn, expression="objectClass=computer", - attrs=["serverReferenceBL","msDS-isRODC"], controls=["search_options:1:2"]) + attrs=["serverReferenceBL", "msDS-isRODC"], controls=["search_options:1:2"]) for ldb_msg in res: if "serverReferenceBL" not in ldb_msg: print("Computer entry %s doesn't have a serverReferenceBL attribute" % ldb_msg['dn']) diff --git a/source4/dsdb/tests/python/ldap_syntaxes.py b/source4/dsdb/tests/python/ldap_syntaxes.py index ab6bc7c9b60..932d3d8d00c 100755 --- a/source4/dsdb/tests/python/ldap_syntaxes.py +++ b/source4/dsdb/tests/python/ldap_syntaxes.py @@ -65,7 +65,7 @@ ldapDisplayName: """ + attr_ldap_display_name + """ objectClass: top objectClass: attributeSchema cn: """ + attr_name + """ -attributeId: 1.3.6.1.4.1.7165.4.6.1.1.""" + str(random.randint(1,100000)) + """ +attributeId: 1.3.6.1.4.1.7165.4.6.1.1.""" + str(random.randint(1, 100000)) + """ attributeSyntax: 2.5.5.14 omSyntax: 127 omObjectClass: \x2A\x86\x48\x86\xF7\x14\x01\x01\x01\x0C @@ -92,7 +92,7 @@ objectClass: classSchema adminDescription: """ + class_name + """ adminDisplayName: """ + class_name + """ cn: """ + class_name + """ -governsId: 1.3.6.1.4.1.7165.4.6.2.1.""" + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.1.""" + str(random.randint(1, 100000)) + """ schemaIdGuid: """ + str(uuid.uuid4()) + """ objectClassCategory: 1 subClassOf: organizationalPerson @@ -125,7 +125,7 @@ ldapDisplayName: """ + attr_ldap_display_name + """ objectClass: top objectClass: attributeSchema cn: """ + attr_name + """ -attributeId: 1.3.6.1.4.1.7165.4.6.1.2.""" + str(random.randint(1,100000)) + """ +attributeId: 1.3.6.1.4.1.7165.4.6.1.2.""" + str(random.randint(1, 100000)) + """ attributeSyntax: 2.5.5.7 omSyntax: 127 omObjectClass: \x2A\x86\x48\x86\xF7\x14\x01\x01\x01\x0B @@ -152,7 +152,7 @@ objectClass: classSchema adminDescription: """ + class_name + """ adminDisplayName: """ + class_name + """ cn: """ + class_name + """ -governsId: 1.3.6.1.4.1.7165.4.6.2.2.""" + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.2.""" + str(random.randint(1, 100000)) + """ schemaIdGuid: """ + str(uuid.uuid4()) + """ objectClassCategory: 1 subClassOf: organizationalPerson diff --git a/source4/dsdb/tests/python/linked_attributes.py b/source4/dsdb/tests/python/linked_attributes.py index 58876680d86..83910c784a8 100644 --- a/source4/dsdb/tests/python/linked_attributes.py +++ b/source4/dsdb/tests/python/linked_attributes.py @@ -331,7 +331,7 @@ class LATests(samba.tests.TestCase): # removing a duplicate link in the same message should fail self.add_linked_attribute(g2, [u1, u2]) self.assertRaises(ldb.LdbError, - self.remove_linked_attribute,g2, [u1, u1]) + self.remove_linked_attribute, g2, [u1, u1]) def _test_la_links_delete_link_reveal(self): u1, u2 = self.add_objects(2, 'user', 'u_del_link_reveal') diff --git a/source4/dsdb/tests/python/rodc_rwdc.py b/source4/dsdb/tests/python/rodc_rwdc.py index 716bcdda1fa..50f722d57b5 100644 --- a/source4/dsdb/tests/python/rodc_rwdc.py +++ b/source4/dsdb/tests/python/rodc_rwdc.py @@ -97,7 +97,7 @@ def preload_rodc_user(user_dn): 'rodc', 'preload', user_dn, credstring, - '--server', RWDC,] + '--server', RWDC, ] print(' '.join(cmd)) subprocess.check_call(cmd) diff --git a/source4/dsdb/tests/python/sam.py b/source4/dsdb/tests/python/sam.py index a1806f9bae3..77fd8f5b659 100755 --- a/source4/dsdb/tests/python/sam.py +++ b/source4/dsdb/tests/python/sam.py @@ -3451,7 +3451,7 @@ class SamTests(samba.tests.TestCase): m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) - m["description"] = MessageElement(["desc1","desc2"], FLAG_MOD_REPLACE, + m["description"] = MessageElement(["desc1", "desc2"], FLAG_MOD_REPLACE, "description") try: ldb.modify(m) @@ -3462,7 +3462,7 @@ class SamTests(samba.tests.TestCase): m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) - m["description"] = MessageElement(["desc1","desc2"], FLAG_MOD_DELETE, + m["description"] = MessageElement(["desc1", "desc2"], FLAG_MOD_DELETE, "description") ldb.modify(m) @@ -3518,7 +3518,7 @@ class SamTests(samba.tests.TestCase): m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) - m["description"] = MessageElement(["desc1","desc2"], FLAG_MOD_DELETE, + m["description"] = MessageElement(["desc1", "desc2"], FLAG_MOD_DELETE, "description") try: ldb.modify(m) @@ -3539,7 +3539,7 @@ class SamTests(samba.tests.TestCase): m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) - m["description"] = MessageElement(["desc1","desc2"], FLAG_MOD_REPLACE, + m["description"] = MessageElement(["desc1", "desc2"], FLAG_MOD_REPLACE, "description") try: ldb.modify(m) @@ -3673,11 +3673,11 @@ class SamTests(samba.tests.TestCase): # a list of some well-known sids # objects in Builtin are aready covered by objectclass protected_list = [ - ["CN=Domain Admins","CN=Users,"], - ["CN=Schema Admins","CN=Users,"], - ["CN=Enterprise Admins","CN=Users,"], - ["CN=Administrator","CN=Users,"], - ["CN=Domain Controllers","CN=Users,"], + ["CN=Domain Admins", "CN=Users,"], + ["CN=Schema Admins", "CN=Users,"], + ["CN=Enterprise Admins", "CN=Users,"], + ["CN=Administrator", "CN=Users,"], + ["CN=Domain Controllers", "CN=Users,"], ] @@ -3720,7 +3720,7 @@ class SamTests(samba.tests.TestCase): "logonCount": MessageElement(["0"]), "cn": MessageElement([user_name]), "countryCode": MessageElement(["0"]), - "objectClass": MessageElement(["top","person","organizationalPerson","user"]), + "objectClass": MessageElement(["top", "person", "organizationalPerson", "user"]), "instanceType": MessageElement(["4"]), "distinguishedName": MessageElement([user_dn]), "sAMAccountType": MessageElement(["805306368"]), diff --git a/source4/dsdb/tests/python/sec_descriptor.py b/source4/dsdb/tests/python/sec_descriptor.py index b35529bd9b5..7b9f6083f82 100755 --- a/source4/dsdb/tests/python/sec_descriptor.py +++ b/source4/dsdb/tests/python/sec_descriptor.py @@ -67,7 +67,7 @@ class DescriptorTests(samba.tests.TestCase): def create_schema_class(self, _ldb, desc=None): while True: - class_id = random.randint(0,65535) + class_id = random.randint(0, 65535) class_name = "descriptor-test-class%s" % class_id class_dn = "CN=%s,%s" % (class_name, self.schema_dn) try: @@ -212,10 +212,10 @@ class OwnerGroupDescriptorTests(DescriptorTests): ["testuser1", "testuser5", "testuser6", "testuser8"], add_members_operation=True) self.ldb_admin.add_remove_group_members("Domain Admins", - ["testuser2","testuser5","testuser6","testuser7"], + ["testuser2", "testuser5", "testuser6", "testuser7"], add_members_operation=True) self.ldb_admin.add_remove_group_members("Schema Admins", - ["testuser3","testuser6","testuser7","testuser8"], + ["testuser3", "testuser6", "testuser7", "testuser8"], add_members_operation=True) self.results = { @@ -2082,7 +2082,7 @@ class SdAutoInheritTests(DescriptorTests): sd_sddl = "O:BAG:BAD:P(A;CI;0x000f01ff;;;AU)" sd = security.descriptor.from_sddl(sd_sddl, self.domain_sid) - self.ldb_admin.create_ou(self.ou_dn,sd=sd) + self.ldb_admin.create_ou(self.ou_dn, sd=sd) self.ldb_admin.create_ou(self.sub_dn) ou_res0 = self.sd_utils.ldb.search(self.ou_dn, SCOPE_BASE, diff --git a/source4/dsdb/tests/python/urgent_replication.py b/source4/dsdb/tests/python/urgent_replication.py index 191df0d2996..5d8282ba9ad 100755 --- a/source4/dsdb/tests/python/urgent_replication.py +++ b/source4/dsdb/tests/python/urgent_replication.py @@ -54,9 +54,9 @@ class UrgentReplicationTests(samba.tests.TestCase): """Test if the urgent replication is not activated when handling a non urgent object.""" self.ldb.add({ "dn": "cn=nonurgenttest,cn=users," + self.base_dn, - "objectclass":"user", - "samaccountname":"nonurgenttest", - "description":"nonurgenttest description"}) + "objectclass": "user", + "samaccountname": "nonurgenttest", + "description": "nonurgenttest description"}) # urgent replication should not be enabled when creating res = self.ldb.load_partition_usn(self.base_dn) @@ -81,10 +81,10 @@ class UrgentReplicationTests(samba.tests.TestCase): self.ldb.add({ "dn": "cn=test server,cn=Servers,cn=Default-First-Site-Name,cn=Sites,%s" % self.ldb.get_config_basedn(), - "objectclass":"server", - "cn":"test server", - "name":"test server", - "systemFlags":"50000000"}, ["relax:0"]) + "objectclass": "server", + "cn": "test server", + "name": "test server", + "systemFlags": "50000000"}, ["relax:0"]) self.ldb.add_ldif( """dn: cn=NTDS Settings test,cn=test server,cn=Servers,cn=Default-First-Site-Name,cn=Sites,cn=Configuration,%s""" % (self.base_dn) + """ @@ -156,7 +156,7 @@ cn: test attributeSchema instanceType: 4 isSingleValued: FALSE showInAdvancedViewOnly: FALSE -attributeID: 1.3.6.1.4.1.7165.4.6.1.4.""" + str(random.randint(1,100000)) + """ +attributeID: 1.3.6.1.4.1.7165.4.6.1.4.""" + str(random.randint(1, 100000)) + """ attributeSyntax: 2.5.5.12 adminDisplayName: test attributeSchema adminDescription: test attributeSchema @@ -188,7 +188,7 @@ objectClass: classSchema cn: test classSchema instanceType: 4 subClassOf: top -governsId: 1.3.6.1.4.1.7165.4.6.2.4.""" + str(random.randint(1,100000)) + """ +governsId: 1.3.6.1.4.1.7165.4.6.2.4.""" + str(random.randint(1, 100000)) + """ rDNAttID: cn showInAdvancedViewOnly: TRUE adminDisplayName: test classSchema @@ -225,10 +225,10 @@ defaultHidingValue: TRUE""") self.ldb.add({ "dn": "cn=test secret,cn=System," + self.base_dn, - "objectClass":"secret", - "cn":"test secret", - "name":"test secret", - "currentValue":"xxxxxxx"}) + "objectClass": "secret", + "cn": "test secret", + "name": "test secret", + "currentValue": "xxxxxxx"}) # urgent replication should be enabled when creating res = self.ldb.load_partition_usn(self.base_dn) @@ -284,12 +284,12 @@ rIDAvailablePool: 133001-1073741823""", ["relax:0"]) self.ldb.add({ "dn": "cn=user UrgAttr test,cn=users," + self.base_dn, - "objectclass":"user", - "samaccountname":"user UrgAttr test", - "userAccountControl":str(dsdb.UF_NORMAL_ACCOUNT), - "lockoutTime":"0", - "pwdLastSet":"0", - "description":"urgent attributes test description"}) + "objectclass": "user", + "samaccountname": "user UrgAttr test", + "userAccountControl": str(dsdb.UF_NORMAL_ACCOUNT), + "lockoutTime": "0", + "pwdLastSet": "0", + "description": "urgent attributes test description"}) # urgent replication should NOT be enabled when creating res = self.ldb.load_partition_usn(self.base_dn) diff --git a/source4/dsdb/tests/python/user_account_control.py b/source4/dsdb/tests/python/user_account_control.py index c60e0854344..6a53e5bef6b 100755 --- a/source4/dsdb/tests/python/user_account_control.py +++ b/source4/dsdb/tests/python/user_account_control.py @@ -34,7 +34,7 @@ from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError from ldb import Message, MessageElement, Dn from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE from samba.dsdb import UF_SCRIPT, UF_ACCOUNTDISABLE, UF_00000004, UF_HOMEDIR_REQUIRED, \ - UF_LOCKOUT,UF_PASSWD_NOTREQD, UF_PASSWD_CANT_CHANGE, UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED,\ + UF_LOCKOUT, UF_PASSWD_NOTREQD, UF_PASSWD_CANT_CHANGE, UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED,\ UF_TEMP_DUPLICATE_ACCOUNT, UF_NORMAL_ACCOUNT, UF_00000400, UF_INTERDOMAIN_TRUST_ACCOUNT, \ UF_WORKSTATION_TRUST_ACCOUNT, UF_SERVER_TRUST_ACCOUNT, UF_00004000, \ UF_00008000, UF_DONT_EXPIRE_PASSWD, UF_MNS_LOGON_ACCOUNT, UF_SMARTCARD_REQUIRED, \ @@ -70,7 +70,7 @@ creds = credopts.get_credentials(lp) creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) bits = [UF_SCRIPT, UF_ACCOUNTDISABLE, UF_00000004, UF_HOMEDIR_REQUIRED, - UF_LOCKOUT,UF_PASSWD_NOTREQD, UF_PASSWD_CANT_CHANGE, + UF_LOCKOUT, UF_PASSWD_NOTREQD, UF_PASSWD_CANT_CHANGE, UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED, UF_TEMP_DUPLICATE_ACCOUNT, UF_NORMAL_ACCOUNT, UF_00000400, UF_INTERDOMAIN_TRUST_ACCOUNT, diff --git a/source4/lib/wmi/wmi.py b/source4/lib/wmi/wmi.py index c552c06ad57..bdb0dd12461 100644 --- a/source4/lib/wmi/wmi.py +++ b/source4/lib/wmi/wmi.py @@ -10,25 +10,25 @@ try: _swig_property = property except NameError: pass # Python < 2.2 doesn't have 'property'. -def _swig_setattr_nondynamic(self,class_type,name,value,static=1): +def _swig_setattr_nondynamic(self, class_type, name, value, static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): if type(value).__name__ == 'PySwigObject': self.__dict__[name] = value return - method = class_type.__swig_setmethods__.get(name,None) - if method: return method(self,value) - if (not static) or hasattr(self,name): + method = class_type.__swig_setmethods__.get(name, None) + if method: return method(self, value) + if (not static) or hasattr(self, name): self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self) -def _swig_setattr(self,class_type,name,value): - return _swig_setattr_nondynamic(self,class_type,name,value,0) +def _swig_setattr(self, class_type, name, value): + return _swig_setattr_nondynamic(self, class_type, name, value, 0) -def _swig_getattr(self,class_type,name): +def _swig_getattr(self, class_type, name): if (name == "thisown"): return self.this.own() - method = class_type.__swig_getmethods__.get(name,None) + method = class_type.__swig_getmethods__.get(name, None) if method: return method(self) raise AttributeError(name) @@ -48,10 +48,10 @@ del types def _swig_setattr_nondynamic_method(set): - def set_attr(self,name,value): + def set_attr(self, name, value): if (name == "thisown"): return self.this.own(value) - if hasattr(self,name) or (name == "this"): - set(self,name,value) + if hasattr(self, name) or (name == "this"): + set(self, name, value) else: raise AttributeError("You cannot add attributes to %s" % self) return set_attr @@ -62,9 +62,9 @@ class IUnknown(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args, **kwargs): - _wmi.IUnknown_swiginit(self,_wmi.new_IUnknown(*args, **kwargs)) + _wmi.IUnknown_swiginit(self, _wmi.new_IUnknown(*args, **kwargs)) __swig_destroy__ = _wmi.delete_IUnknown -IUnknown.Release = new_instancemethod(_wmi.IUnknown_Release,None,IUnknown) +IUnknown.Release = new_instancemethod(_wmi.IUnknown_Release, None, IUnknown) IUnknown_swigregister = _wmi.IUnknown_swigregister IUnknown_swigregister(IUnknown) @@ -72,11 +72,11 @@ class IWbemServices(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args, **kwargs): - _wmi.IWbemServices_swiginit(self,_wmi.new_IWbemServices(*args, **kwargs)) + _wmi.IWbemServices_swiginit(self, _wmi.new_IWbemServices(*args, **kwargs)) __swig_destroy__ = _wmi.delete_IWbemServices -IWbemServices.ExecQuery = new_instancemethod(_wmi.IWbemServices_ExecQuery,None,IWbemServices) -IWbemServices.ExecNotificationQuery = new_instancemethod(_wmi.IWbemServices_ExecNotificationQuery,None,IWbemServices) -IWbemServices.CreateInstanceEnum = new_instancemethod(_wmi.IWbemServices_CreateInstanceEnum,None,IWbemServices) +IWbemServices.ExecQuery = new_instancemethod(_wmi.IWbemServices_ExecQuery, None, IWbemServices) +IWbemServices.ExecNotificationQuery = new_instancemethod(_wmi.IWbemServices_ExecNotificationQuery, None, IWbemServices) +IWbemServices.CreateInstanceEnum = new_instancemethod(_wmi.IWbemServices_CreateInstanceEnum, None, IWbemServices) IWbemServices_swigregister = _wmi.IWbemServices_swigregister IWbemServices_swigregister(IWbemServices) @@ -84,9 +84,9 @@ class IEnumWbemClassObject(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args, **kwargs): - _wmi.IEnumWbemClassObject_swiginit(self,_wmi.new_IEnumWbemClassObject(*args, **kwargs)) + _wmi.IEnumWbemClassObject_swiginit(self, _wmi.new_IEnumWbemClassObject(*args, **kwargs)) __swig_destroy__ = _wmi.delete_IEnumWbemClassObject -IEnumWbemClassObject.Reset = new_instancemethod(_wmi.IEnumWbemClassObject_Reset,None,IEnumWbemClassObject) +IEnumWbemClassObject.Reset = new_instancemethod(_wmi.IEnumWbemClassObject_Reset, None, IEnumWbemClassObject) IEnumWbemClassObject_swigregister = _wmi.IEnumWbemClassObject_swigregister IEnumWbemClassObject_swigregister(IEnumWbemClassObject) diff --git a/source4/scripting/devel/repl_cleartext_pwd.py b/source4/scripting/devel/repl_cleartext_pwd.py index e8acb90c90f..1c5100b629c 100755 --- a/source4/scripting/devel/repl_cleartext_pwd.py +++ b/source4/scripting/devel/repl_cleartext_pwd.py @@ -72,7 +72,7 @@ class globals: continue self.global_objs = {} -def attid_equal(a1,a2): +def attid_equal(a1, a2): return (a1 & 0xffffffff) == (a2 & 0xffffffff) ########### main code ########### diff --git a/source4/scripting/devel/speedtest.py b/source4/scripting/devel/speedtest.py index 86d3520c0d9..fbbf67e3122 100755 --- a/source4/scripting/devel/speedtest.py +++ b/source4/scripting/devel/speedtest.py @@ -76,7 +76,7 @@ class SpeedTest(samba.tests.TestCase): def find_domain_sid(self, ldb): res = ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE) - return ndr_unpack(security.dom_sid,res[0]["objectSid"][0]) + return ndr_unpack(security.dom_sid, res[0]["objectSid"][0]) def setUp(self): super(SpeedTest, self).setUp() diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 89acae305e0..c92c8b1805e 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -204,7 +204,7 @@ for transport in ["ncacn_np", "ncacn_ip_tcp"]: bindoptions = '' if t == 'rpc.cracknames': bindoptions = 'seal' - plansmbtorture4testsuite(t, env, ["%s:$SERVER[%s]" % (transport,bindoptions), '-U$USERNAME%$PASSWORD', '--workgroup=$DOMAIN'], "samba4.%s on %s with %s" % (t, transport, bindoptions)) + plansmbtorture4testsuite(t, env, ["%s:$SERVER[%s]" % (transport, bindoptions), '-U$USERNAME%$PASSWORD', '--workgroup=$DOMAIN'], "samba4.%s on %s with %s" % (t, transport, bindoptions)) # Tests for the DFS referral calls implementation for t in smbtorture4_testsuites("dfs."): @@ -557,7 +557,7 @@ for env in ["s4member_dflt_domain", "s4member"]: if env == "s4member": users = ["$DOMAIN/$DC_USERNAME", "$DC_USERNAME@$REALM"] for usr in users: - plantestsuite("samba4.winbind.dom_name_parse.cmd", env, "%s/dom_parse.sh %s %s" % (bbdir,cmd,usr)) + plantestsuite("samba4.winbind.dom_name_parse.cmd", env, "%s/dom_parse.sh %s %s" % (bbdir, cmd, usr)) nsstest4 = binpath("nsstest") for env in ["ad_dc:local", "s4member:local", "nt4_dc:local", "ad_member:local", "nt4_member:local"]: diff --git a/source4/torture/drs/python/delete_object.py b/source4/torture/drs/python/delete_object.py index 4cbe2e858d7..5cc0c2877c8 100644 --- a/source4/torture/drs/python/delete_object.py +++ b/source4/torture/drs/python/delete_object.py @@ -74,7 +74,7 @@ class DrsDeleteObjectTestCase(drs_base.DrsBaseTestCase): name_orig = obj_orig["name"][0] name_cur = user_cur["name"][0] if is_deleted: - self.assertEquals(user_cur["isDeleted"][0],"TRUE") + self.assertEquals(user_cur["isDeleted"][0], "TRUE") self.assertFalse("objectCategory" in user_cur) self.assertFalse("sAMAccountType" in user_cur) self.assertFalse("description" in user_cur) diff --git a/source4/torture/drs/python/drs_base.py b/source4/torture/drs/python/drs_base.py index c84e819fc21..45308e451fe 100644 --- a/source4/torture/drs/python/drs_base.py +++ b/source4/torture/drs/python/drs_base.py @@ -141,7 +141,7 @@ class DrsBaseTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd(*samba_tool_cmdline) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") def _enable_inbound_repl(self, DC): # make base command line @@ -150,7 +150,7 @@ class DrsBaseTestCase(SambaToolCmdTest): samba_tool_cmd += [DC, "--dsa-option=-DISABLE_INBOUND_REPL"] (result, out, err) = self.runsubcmd(*samba_tool_cmd) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") def _disable_inbound_repl(self, DC): # make base command line @@ -159,7 +159,7 @@ class DrsBaseTestCase(SambaToolCmdTest): samba_tool_cmd += [DC, "--dsa-option=+DISABLE_INBOUND_REPL"] (result, out, err) = self.runsubcmd(*samba_tool_cmd) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") def _enable_all_repl(self, DC): self._enable_inbound_repl(DC) @@ -169,7 +169,7 @@ class DrsBaseTestCase(SambaToolCmdTest): samba_tool_cmd += [DC, "--dsa-option=-DISABLE_OUTBOUND_REPL"] (result, out, err) = self.runsubcmd(*samba_tool_cmd) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") def _disable_all_repl(self, DC): self._disable_inbound_repl(DC) @@ -179,7 +179,7 @@ class DrsBaseTestCase(SambaToolCmdTest): samba_tool_cmd += [DC, "--dsa-option=+DISABLE_OUTBOUND_REPL"] (result, out, err) = self.runsubcmd(*samba_tool_cmd) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") def _get_highest_hwm_utdv(self, ldb_conn): res = ldb_conn.search("", scope=ldb.SCOPE_BASE, attrs=["highestCommittedUSN"]) diff --git a/source4/torture/drs/python/fsmo.py b/source4/torture/drs/python/fsmo.py index 67b8331614d..c74bb9d1ec1 100644 --- a/source4/torture/drs/python/fsmo.py +++ b/source4/torture/drs/python/fsmo.py @@ -67,7 +67,7 @@ class DrsFsmoTestCase(drs_base.DrsBaseTestCase): cmd_line_auth) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") if noop == False: self.assertTrue("FSMO transfer of '%s' role successful" % role in out) else: diff --git a/source4/torture/drs/python/getnc_exop.py b/source4/torture/drs/python/getnc_exop.py index 21c7a1853dc..111264b36bc 100644 --- a/source4/torture/drs/python/getnc_exop.py +++ b/source4/torture/drs/python/getnc_exop.py @@ -263,17 +263,17 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): }) dc3_id = self._get_identifier(self.ldb_dc1, dc3) - (hwm1, utdv1) = self._check_replication([ou1,ou2,dc3], + (hwm1, utdv1) = self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_WRIT_REP) - self._check_replication([ou1,ou2,dc3], + self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC) self._check_replication([dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY) - self._check_replication([ou1,ou2,dc3], + self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC) @@ -282,17 +282,17 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): m["displayName"] = ldb.MessageElement("OU1", ldb.FLAG_MOD_ADD, "displayName") self.ldb_dc1.modify(m) - (hwm2, utdv2) = self._check_replication([ou2,dc3,ou1], + (hwm2, utdv2) = self._check_replication([ou2, dc3, ou1], drsuapi.DRSUAPI_DRS_WRIT_REP) - self._check_replication([ou1,ou2,dc3], + self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC) self._check_replication([dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY) - self._check_replication([ou1,ou2,dc3], + self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC) @@ -315,30 +315,30 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): m["displayName"] = ldb.MessageElement("OU2", ldb.FLAG_MOD_ADD, "displayName") self.ldb_dc1.modify(m) - (hwm3, utdv3) = self._check_replication([dc3,ou1,ou2], + (hwm3, utdv3) = self._check_replication([dc3, ou1, ou2], drsuapi.DRSUAPI_DRS_WRIT_REP) - self._check_replication([ou1,ou2,dc3], + self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC) self._check_replication([dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY) - self._check_replication([ou1,ou2,dc3], + self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC) - self._check_replication([ou1,ou2], + self._check_replication([ou1, ou2], drsuapi.DRSUAPI_DRS_WRIT_REP, highwatermark=hwm1) - self._check_replication([ou1,ou2], + self._check_replication([ou1, ou2], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC, highwatermark=hwm1) - self._check_replication([ou1,ou2], + self._check_replication([ou1, ou2], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC, uptodateness_vector=utdv1) @@ -348,21 +348,21 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): m["displayName"] = ldb.MessageElement("OU", ldb.FLAG_MOD_ADD, "displayName") self.ldb_dc1.modify(m) - (hwm4, utdv4) = self._check_replication([dc3,ou1,ou2,self.ou], + (hwm4, utdv4) = self._check_replication([dc3, ou1, ou2, self.ou], drsuapi.DRSUAPI_DRS_WRIT_REP) - self._check_replication([self.ou,ou1,ou2,dc3], + self._check_replication([self.ou, ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC) self._check_replication([dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY) - self._check_replication([self.ou,ou1,ou2,dc3], + self._check_replication([self.ou, ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC) - self._check_replication([self.ou,ou2], + self._check_replication([self.ou, ou2], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC, uptodateness_vector=utdv2) @@ -374,17 +374,17 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): }) cn3_id = self._get_identifier(self.ldb_dc1, cn3) - (hwm5, utdv5) = self._check_replication([dc3,ou1,ou2,self.ou,cn3], + (hwm5, utdv5) = self._check_replication([dc3, ou1, ou2, self.ou, cn3], drsuapi.DRSUAPI_DRS_WRIT_REP) - self._check_replication([self.ou,ou1,ou2,dc3,cn3], + self._check_replication([self.ou, ou1, ou2, dc3, cn3], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC) self._check_replication([dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY) - self._check_replication([self.ou,ou1,ou2,dc3], + self._check_replication([self.ou, ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC) @@ -396,12 +396,12 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): drsuapi.DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE, ou2_id.guid, dc3_id.guid) - (hwm6, utdv6) = self._check_replication([dc3,ou1,self.ou,cn3,ou2], + (hwm6, utdv6) = self._check_replication([dc3, ou1, self.ou, cn3, ou2], drsuapi.DRSUAPI_DRS_WRIT_REP, expected_links=[ou2_managedBy_dc3]) # Can fail against Windows due to equal precedence of dc3, cn3 - self._check_replication([self.ou,ou1,ou2,dc3,cn3], + self._check_replication([self.ou, ou1, ou2, dc3, cn3], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC, expected_links=[ou2_managedBy_dc3]) @@ -409,7 +409,7 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): self._check_replication([dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY) - self._check_replication([self.ou,ou1,ou2,dc3], + self._check_replication([self.ou, ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC) @@ -434,9 +434,9 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): drsuapi.DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE, dc3_id.guid, ou1_id.guid) - (hwm7, utdv7) = self._check_replication([ou1,self.ou,cn3,ou2,dc3], + (hwm7, utdv7) = self._check_replication([ou1, self.ou, cn3, ou2, dc3], drsuapi.DRSUAPI_DRS_WRIT_REP, - expected_links=[ou2_managedBy_dc3,dc3_managedBy_ou1]) + expected_links=[ou2_managedBy_dc3, dc3_managedBy_ou1]) # Can fail against Windows due to equal precedence of dc3, cn3 #self._check_replication([self.ou,ou1,ou2,dc3,cn3], @@ -452,7 +452,7 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, expected_links=[dc3_managedBy_ou1]) - self._check_replication([self.ou,ou1,ou2,dc3], + self._check_replication([self.ou, ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC, expected_links=[dc3_managedBy_ou1]) @@ -476,9 +476,9 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): drsuapi.DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE, dc3_id.guid, ou2_id.guid) - (hwm8, utdv8) = self._check_replication([ou1,self.ou,cn3,ou2,dc3], + (hwm8, utdv8) = self._check_replication([ou1, self.ou, cn3, ou2, dc3], drsuapi.DRSUAPI_DRS_WRIT_REP, - expected_links=[ou2_managedBy_dc3,dc3_managedBy_ou1,dc3_managedBy_ou2]) + expected_links=[ou2_managedBy_dc3, dc3_managedBy_ou1, dc3_managedBy_ou2]) # Can fail against Windows due to equal precedence of dc3, cn3 #self._check_replication([self.ou,ou1,ou2,dc3,cn3], @@ -488,79 +488,79 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): self._check_replication([dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2]) + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2]) - self._check_replication([self.ou,ou1,ou2,dc3], + self._check_replication([self.ou, ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2]) + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2]) # GET_TGT will also return any DNs referenced by the linked attributes # (including the Tombstone attribute) self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, more_flags=drsuapi.DRSUAPI_DRS_GET_TGT, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], dn_ordered=False) + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], dn_ordered=False) # Use the highwater-mark prior to changing ManagedBy - this should # only return the old/Tombstone and new linked attributes (we already # know all the DNs) self._check_replication([], drsuapi.DRSUAPI_DRS_WRIT_REP, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], highwatermark=hwm7) self._check_replication([], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], highwatermark=hwm7) self._check_replication([], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], highwatermark=hwm7) self._check_replication([], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], highwatermark=hwm7) self._check_replication([], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, more_flags=drsuapi.DRSUAPI_DRS_GET_TGT, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], highwatermark=hwm7) # Repeat the above set of tests using the uptodateness_vector # instead of the highwater-mark self._check_replication([], drsuapi.DRSUAPI_DRS_WRIT_REP, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], uptodateness_vector=utdv7) self._check_replication([], drsuapi.DRSUAPI_DRS_WRIT_REP | drsuapi.DRSUAPI_DRS_GET_ANC, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], uptodateness_vector=utdv7) self._check_replication([], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], uptodateness_vector=utdv7) self._check_replication([], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY | drsuapi.DRSUAPI_DRS_GET_ANC, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], uptodateness_vector=utdv7) self._check_replication([], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, more_flags=drsuapi.DRSUAPI_DRS_GET_TGT, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], + expected_links=[dc3_managedBy_ou1, dc3_managedBy_ou2], uptodateness_vector=utdv7) def test_FSMONotOwner(self): diff --git a/source4/torture/drs/python/repl_schema.py b/source4/torture/drs/python/repl_schema.py index ef1da38f82f..f66938cca2f 100644 --- a/source4/torture/drs/python/repl_schema.py +++ b/source4/torture/drs/python/repl_schema.py @@ -121,7 +121,7 @@ class DrsReplSchemaTestCase(drs_base.DrsBaseTestCase): "cn": class_name, "lDAPDisplayName": class_ldn, "governsId": "1.3.6.1.4.1.7165.4.6.2.5." \ - + str((100000 * base_int) + random.randint(1,100000)) + ".1.5.13", + + str((100000 * base_int) + random.randint(1, 100000)) + ".1.5.13", "instanceType": "4", "objectClassCategory": "%d" % oc_cat, "subClassOf": "top", @@ -146,7 +146,7 @@ class DrsReplSchemaTestCase(drs_base.DrsBaseTestCase): "cn": attr_name, "lDAPDisplayName": attr_ldn, "attributeId": "1.3.6.1.4.1.7165.4.6.1.5." \ - + str((100000 * base_int) + random.randint(1,100000)) + ".1.5.13", + + str((100000 * base_int) + random.randint(1, 100000)) + ".1.5.13", "attributeSyntax": "2.5.5.12", "omSyntax": "64", "instanceType": "4", @@ -244,7 +244,7 @@ class DrsReplSchemaTestCase(drs_base.DrsBaseTestCase): AttributeID_id in Schema cache""" # add new attributeSchema object (a_ldn, a_dn) = self._schema_new_attr(self.ldb_dc1, "attr-Link-X", 10, - attrs={'linkID':"1.2.840.113556.1.2.50", + attrs={'linkID': "1.2.840.113556.1.2.50", "attributeSyntax": "2.5.5.1", "omSyntax": "127"}) # add a base classSchema class so we can use our new diff --git a/source4/torture/drs/python/replica_sync.py b/source4/torture/drs/python/replica_sync.py index 258af696c72..b3b5d0835ca 100644 --- a/source4/torture/drs/python/replica_sync.py +++ b/source4/torture/drs/python/replica_sync.py @@ -137,8 +137,8 @@ objectClass: organizationalUnit # Deleted Object base DN dodn = self._deleted_objects_dn(sam_ldb) # now check properties of the user - name_cur = ou_cur["ou"][0] - self.assertEquals(ou_cur["isDeleted"][0],"TRUE") + name_cur = ou_cur["ou"][0] + self.assertEquals(ou_cur["isDeleted"][0], "TRUE") self.assertTrue(not("objectCategory" in ou_cur)) self.assertTrue(dodn in str(ou_cur["dn"]), "OU %s is deleted but it is not located under %s!" % (name_cur, dodn)) diff --git a/source4/torture/drs/python/replica_sync_rodc.py b/source4/torture/drs/python/replica_sync_rodc.py index d93c4549647..4930a3b5254 100644 --- a/source4/torture/drs/python/replica_sync_rodc.py +++ b/source4/torture/drs/python/replica_sync_rodc.py @@ -73,8 +73,8 @@ objectClass: organizationalUnit # Deleted Object base DN dodn = self._deleted_objects_dn(sam_ldb) # now check properties of the user - name_cur = ou_cur["ou"][0] - self.assertEquals(ou_cur["isDeleted"][0],"TRUE") + name_cur = ou_cur["ou"][0] + self.assertEquals(ou_cur["isDeleted"][0], "TRUE") self.assertTrue(not("objectCategory" in ou_cur)) self.assertTrue(dodn in str(ou_cur["dn"]), "OU %s is deleted but it is not located under %s!" % (name_cur, dodn)) diff --git a/source4/torture/drs/python/ridalloc_exop.py b/source4/torture/drs/python/ridalloc_exop.py index 68713b49e39..cbeaec99155 100644 --- a/source4/torture/drs/python/ridalloc_exop.py +++ b/source4/torture/drs/python/ridalloc_exop.py @@ -292,7 +292,7 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): (result, out, err) = self.runsubcmd("fsmo", "seize", "--role", "rid", "-H", ldb_url, "-s", smbconf, "--force") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") # 3. Assert we get the RID Set res = new_ldb.search(base=server_ref_dn, @@ -621,7 +621,7 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): # 4. Seize the RID Manager role (result, out, err) = self.runsubcmd("fsmo", "seize", "--role", "rid", "-H", ldb_url, "-s", smbconf, "--force") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") # 5. Add a new user (triggers RID set work) new_ldb.newuser("ridalloctestuser", "P@ssword!") diff --git a/wintest/wintest.py b/wintest/wintest.py index 1f385fc5929..b3ef09066d8 100644 --- a/wintest/wintest.py +++ b/wintest/wintest.py @@ -53,9 +53,9 @@ class wintest(): for v in ['VM', 'HOSTNAME', 'USER', 'PASS', 'SNAPSHOT', 'REALM', 'DOMAIN', 'IP']: vname = '%s_%s' % (vm, v) if vname in self.vars: - self.setvar("%s_%s" % (prefix,v), self.substitute("${%s}" % vname)) + self.setvar("%s_%s" % (prefix, v), self.substitute("${%s}" % vname)) else: - self.vars.pop("%s_%s" % (prefix,v), None) + self.vars.pop("%s_%s" % (prefix, v), None) if self.getvar("WIN_REALM"): self.setvar("WIN_REALM", self.getvar("WIN_REALM").upper())