summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)AuthorFilesLines
2018-04-05selftest: enable py3 for samba.tests.samdb_apiJoe Guo1-10/+10
Fix bytes and string. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.kcc.graph_utilsJoe Guo1-1/+1
zip will not return a list in Python 3. Convert to list. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.kcc.graphJoe Guo1-3/+3
In Python 3, range() will not return a list any more. So `range(7) * 4` will not work. Convert range to list to fix. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.upgradeprovisionJoe Guo2-9/+10
1. `has_key` was removed from dict in Python 3, use `in` instead. 2. `cmp` was removed in Python 3, define it ourselves. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.hostconfigJoe Guo1-2/+2
Fix relative import. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.commonJoe Guo1-0/+27
fix dsdb_Dn comparison for Python 3 In Python 3, the builtin `cmp` funtion was dropped. And the `__cmp__` magic method in object is no longer honored, which is replaced by 6 new methods: __eq__, __ne__, __lt__, __le__, __gt__, __ge__. This caused `tests.CommonTests` failed with `py3_compatiable=True`. Fixed by adding the above methods. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.upgradeJoe Guo1-1/+3
`os.tempname` is removed in Python 3. Use `tempfile` instead. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.blackbox.check_outputJoe Guo1-1/+3
convert bytes to str for Python 3 `BlackboxTestCase.check_output` will return bytes since it uses `subprocess.communicate` underneath. Convert expected string result to bytes for comparing. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.xattrJoe Guo1-3/+3
Fix bytes and str issue. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest: enable py3 for samba.tests.posixaclJoe Guo1-3/+3
Fix bytes and str issue. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05samba3: work around bytes formatting for Python 3.4Joe Guo1-4/+4
b'%s\x00' % key The above % formatting for bytes is only available since Python 3.5, however we need to support Python 3.4 so far. Work around this with `+`. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05get make test TESTS=samba.tests.provision to workNoel Power2-8/+8
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05selftest python: get samba.tests.s3idmapdb to run with py3Noel Power2-17/+17
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05python selftest: enabled samba.tests.s3registry to run with py3Noel Power2-12/+12
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05python selftest: enable samba.tests.s3passdb to run with python3Noel Power1-1/+1
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05python selftest: enable samba.tests.s3param to run with python3Noel Power1-3/+2
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-05python selftest: split samba3 test into separate testsNoel Power5-83/+207
This patch splits the tests contained in samba3.py into separate tests s3idmapdb.py, s3param.py, s3passdb.py, s3registry.py, s3windb.py This allows test of associated python c-modules to be done independently. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23Add tests for dckeytab python moduleDavid Mulder1-0/+56
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23Add python tests for samba.gpo moduleDavid Mulder1-0/+70
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23tests/dcerpc/misc.GUID: improve testsJoe Guo1-19/+34
1. Merge tests for different formats into a for loop, make it easy to read and extend. 2. Add test for invalid formats. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23tests/dcerpc/misc.GUID: test that long-form py3 bytes worksDouglas Bagnall1-2/+7
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-23samba python tests: Ensure GUIDTests cover all input formatsNoel Power1-0/+15
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-23python: Add compatability helpers to determine if type is really bytesNoel Power1-0/+24
py3compat has PyBytes_Check macro which evalates to PyString_Check in python2. To help switch behaviour based on whether you are dealing with the bytes type the following macros have been added. IsPy3Bytes IsPy3BytesOrString IsPy3Bytes will evaluate to false in python2 and will return the expected result in python3. IsPy3BytesOrString will test for string type alone in python2 or bytes and string in python3. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-23s4/selftest: Add simple python netbios test python2 only for the momentNoel Power1-0/+52
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23samba python libs: convert print func to be py2/py3 compatibleNoel Power11-99/+126
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23samba-tool: convert print func to be py2/py3 compatibleNoel Power2-4/+6
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23samba python tests: convert print func to be py2/py3 compatibleNoel Power11-50/+60
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21samba-tool visualize: fix python2.6 incompatibilityBjörn Baumbach1-1/+5
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13337 Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Wed Mar 21 09:25:51 CET 2018 on sn-devel-144
2018-03-21samba-tool ldapcmp: remove duplicate takes_optiongroups attributeDouglas Bagnall1-6/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-21tests/samba_dnsupdate: Add a trivial test of automatic site coverageGarming Sam1-0/+54
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21tests/kcc_util: Add unit tests for automatic site coverageGarming Sam1-0/+352
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21kcc_utils: Use lower name in automatic sites coveredGarming Sam1-1/+1
This allows easier testing, as well as some consistency in the DNS record creation. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21kcc_utils: Prevent multiple sites attached to a sitelink covering a siteGarming Sam1-3/+34
This avoids trivial duplicates in a similar manner as mentioned in: https://blogs.technet.microsoft.com/askds/2011/04/29/sites-sites-everywhere/ It prefers the largest sites then the earliest alphabetically, so that only a single site ever covers an uncovered site (within a site link). Note that this isn't applicable over multiple site links (like Windows presumably) and is only a simple mechanism to avoid excessive registering. DCs within the site will also still register for each. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21kcc_utils: Keep a count of the DCs in each siteGarming Sam1-2/+3
This is useful for ranking which sites are preferable within the same site link. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21kcc_utils: Add a routine for automatic site coverageGarming Sam1-0/+80
This allows double-coverage if two links exist with the same cost. Administrators should only connect an DC-less site via a single site link. This also allows unnecessary coverage by all sites in the adjoining site link (to be resolved in the later patches). Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21join.py: Add missing NTSTATUSError importGarming Sam1-1/+1
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-19samba-tool: allow sid strings for 'group {add,remove}members'Stefan Metzmacher1-4/+20
This makes it possible to add foreign SIDS as group members. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13300 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-03-19tests/dsdb.py: test creation of foreignSecurityPrincipal via 'attr: <SID=...>'Stefan Metzmacher1-0/+226
[MS-ADTS] 3.1.1.5.2.3 Special Classes and Attributes claims: FPO-enabled attributes: member, msDS-MembersForAzRole, msDS-NeverRevealGroup, msDS-NonMembers, msDS-RevealOnDemandGroup, msDS-ServiceAccount. 'msDS-NonMembers' always generates NOT_SUPPORTED. 'msDS-ServiceAccount' is not defined in any schema (only msDS-HostServiceAccount). 'msDS-HostServiceAccount' is not an FPO-enabled attribute and behaves as the 'manager' attribute. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13300 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-03-19tests/dsdb.py: verify that foreignSecurityPrincipal objects require the ↵Stefan Metzmacher1-4/+42
provision control Windows rejects creating foreignSecurityPrincipal objects directly. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13300 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-03-19provision: use the provision control when adding foreignSecurityPrincipalsStefan Metzmacher1-2/+2
The next commits will require this. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13300 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-03-19tests/dsdb.py: prove the difference between linked and non-linked DN referencesStefan Metzmacher1-1/+146
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13307 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-03-19Update help text for dbcheckJonathan Hunter1-1/+1
Update the help text for dbcheck, to make its behaviour clear (in particular with reference to the difference between specifying "--yes" on the command line, and answering "yes"/"all" to each individual question) Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Mar 19 12:39:12 CET 2018 on sn-devel-144
2018-03-16ms_schema: fix python2.6 incompatibilityBjörn Baumbach1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13337 Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-06selftest: Change name to sam.ldb to align with new partition module assumptionsGary Lockyer1-1/+1
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-05remove_dc.py: Abort transaction before throwing an exceptionGary Lockyer1-0/+3
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-05tests/smbcontrol: reduce ping test false positive rateDouglas Bagnall1-4/+36
The ping test was failing when a transient ldap_server process died between the time it was listed and the time it was pinged. We stop treating that as failure. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Mar 5 01:33:46 CET 2018 on sn-devel-144
2018-03-01domain.py: Give some advice if the schema upgrade command failsGarming Sam1-3/+8
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-03-01py3compat: add strings describing bytes/unicode in both versionsDouglas Bagnall1-0/+8
What Python 3 calls "bytes", Python 2 calls "string"; What Python 3 calls "string", Python 2 calls "unicode". This can cause confusion in e.g. help strings where the precise type matters. These macros can be used to construct accurate messages for both versions. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Thu Mar 1 04:36:15 CET 2018 on sn-devel-144
2018-02-28samba python tests: convert 'except X, (tuple)' to 'except X as e'Noel Power4-6/+12
In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-28samba-tool: convert 'except X, (tuple)' to 'except X as e'Noel Power5-25/+50
In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>