summaryrefslogtreecommitdiff
path: root/lib/ldb/tests/python
AgeCommit message (Collapse)AuthorFilesLines
2019-06-21lib ldb tests: remove deprecation warning from api.pyGary Lockyer1-15/+15
Remove the "DeprecationWarning: Please use assertEqual instead." warnings from api.py Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-06-21lib ldb tests: Test nested transactionsGary Lockyer1-0/+103
Add a test to document that ldb does not currently support nested transactions. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-05-29ldb: python test for repackAaron Haslett1-0/+204
Python test to confirm that after enabling or disabling GUID indexing, the database is repacked on the next transaction with V1 if GUID indexing was disabled, or V2 if it was enabled. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2019-04-08ldb: tests for <= and >= integer indexing with duplicatesGarming Sam1-0/+39
We need to make sure that duplicates are correctly returned (uSNChanged for instance is UNIQUE but, we should be able to index on attributes which are not unique). Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-04-08ldb: tests for <= and >= integer indexingAaron Haslett1-0/+83
Testing max, min and negative values for indexed 32 and 64 bit types. This has to be done in two different files because the 64 bit type is LDB_SYNTAX_INTEGER which is implemented at the ldb level, while the 32 bit is added in the ldb-samba module. Schema syntax binding added for ldb-samba. We also need to make sure that full scans are not invoked for LMDB. Pair-programmed-with: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-26Fix tests whithout lmdbMathieu Parent1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13630 Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-06Enable make test even without lmdbMathieu Parent2-0/+45
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13630 Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2019-01-29ldb: The test api.py should not rely on order of entries in dictLukas Slebodnik1-6/+8
Test failed on s390x but there is a simple reproducer for any architecture. The built-in function repr returns the canonical string representation of the object. We needn't care about order attributes in string representation. Therefore test should pass for any order. for i in {1..30}; do PYTHONHASHSEED=random \ python2 -c 'import ldb; msg = ldb.Message(); msg.dn = ldb.Dn(ldb.Ldb(), "dc=foo29"); msg["dc"] = b"foo"; print(repr(msg)) ' done ====================================================================== FAIL: test_repr (__main__.LdbMsgTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "tests/python/api.py", line 2322, in test_repr "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})") AssertionError: "Message({'dc': MessageElement(['foo']), 'dn': Dn('dc=foo29')})" != "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})" ---------------------------------------------------------------------- Ran 1025 tests in 29.146s FAILED (failures=1) Signed-off-by: Lukas Slebodnik <lslebodn@fedoraproject.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-01-13lib/ldb/tests/python: Add test to pass utf8 encoded bytes to ldb.DnNoel Power1-0/+15
This test should demonstrate an error with the 'es' format in python where a 'str' byte-string is passed (containing utf8 encoded bytes) with some characters that cannot be decoded as ascii. The same code if run in python3 should generate an error (needs string not bytes) Also Add knownfail for ldb.Dn passed utf8 encoded byte string Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-12-14PY3: change shebang to python3 in lib dirJoe Guo2-2/+2
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-11-01ldb/tests/py/index: remove dup value in dictionaryDouglas Bagnall1-1/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-11-01ldb/tests/py/api: use proper name for ldb.LdbErrorDouglas Bagnall1-2/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-10-25ldb/tests/py/api: reveal shadowed casefold testDouglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-09-27lib/ldb/tests: add test for ldb.Dn passed utf8 unicodeNoel Power1-0/+4
object dn format should be a utf8 encoded string Note: Currently this fails in python2 as the c python binding for the dn string param uses PyArg_ParseTupleAndKeywords() with 's' format, this will accept str *or* unicode in the default encoding. The default encoding in python2 is... ascii. Also adding here a knownfail to squash the error produced by the test. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-06PEP8: fix E128: continuation line under-indented for visual indentJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-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): Thu Sep 6 15:50:17 CEST 2018 on sn-devel-144
2018-08-24PEP8: fix E502: the backslash is redundant between bracketsJoe Guo1-1/+1
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-08-24PEP8: fix E306: expected 1 blank line before a nested definition, found 0Joe Guo1-0/+2
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-08-24PEP8: fix E305: expected 2 blank lines after class or function definition, ↵Joe Guo1-0/+1
found 1 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-08-24PEP8: fix E303: too many blank lines (2)Joe Guo1-7/+0
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-08-24PEP8: fix E302: expected 2 blank lines, found 1Joe Guo1-0/+21
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-08-24PEP8: fix E301: expected 1 blank line, found 0Joe Guo2-0/+17
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-08-24PEP8: fix E231: missing whitespace after ','Joe Guo1-2/+2
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-08-24PEP8: fix E226: missing whitespace around arithmetic operatorJoe Guo1-1/+1
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-08-24PEP8: fix E203: whitespace before ':'Joe Guo1-6/+6
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-08-24PEP8: fix E128: continuation line under-indented for visual indentJoe Guo2-14/+14
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-08-24PEP8: fix E127: continuation line over-indented for visual indentJoe Guo1-1/+1
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-08-24PEP8: fix E124: closing bracket does not match visual indentationJoe Guo1-1/+1
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-08-15ldb: extend API testsAndrew Bartlett1-3/+44
These additional API tests just check that an invalid base DN is never accepted. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-14CVE-2018-1140 ldb: Add tests for search add and rename with a bad dn= DNAndrew Bartlett1-0/+156
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374
2018-05-30ldb: Add tests for when we should expect a full scanAndrew Bartlett1-1/+99
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13448 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-05-23ldb: Reject a possible future ldb_mdb with the index in a sub-databaseAndrew Bartlett1-0/+32
This ensures we do not corrupt such an index by making changes to the main database without knowing that the index values are now in a sub-database. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-05-23ldb_mdb/tests: Run api and index test also on lmdbGary Lockyer2-1/+107
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-05-12Bulk: enclose .keys() method with list where list (from python2) expectedNoel Power1-2/+2
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-03ldb: Prepare to allow tests to operate on ldb_mdb (by using the GUID index)Gary Lockyer1-55/+111
The LMDB backend requires the GUID index mode, so prepare for it by setting a unique objectGUID on each record. Also prepare for the index list to be optionally set as an attribute on the test object, allowing the GUID index mode to be set later when LMDB is configured. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu May 3 11:08:12 CEST 2018 on sn-devel-144
2018-05-03ldb tests: api ensure database correctly populatedGary Lockyer1-0/+13
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-04-06ldb index: Add tests for truncated base 64 index keysGary Lockyer1-1/+36
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-04-06ldb index: Fix truncation key length calculationGary Lockyer1-2/+5
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-04-05ldb: Add test to show a reindex failure must not leave the DB corruptAndrew Bartlett1-0/+160
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13335 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Apr 5 07:53:10 CEST 2018 on sn-devel-144
2018-04-05lib ldb tests: Prepare to run api and index test on tdb and lmdbGary Lockyer2-60/+114
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13335 Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-06ldb: Remove python warning in tests/python/index.pyGary Lockyer1-1/+1
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-03ldb_tdb: Add tests for truncated index keysGary Lockyer1-0/+1222
Tests for the index truncation code as well as the GUID index format in general. Covers truncation of both the DN and equality search keys. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-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): Sat Mar 3 09:58:40 CET 2018 on sn-devel-144
2018-02-08pyldb: extend dn.is_child_of() test: dn is child of itselfBjörn Baumbach1-0/+4
Add this test so ensure that this (unclear) behaviour does not change silently. Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-12-20ldb: Intersect the index from SCOPE_ONELEVEL with the index for the search ↵Andrew Bartlett1-1/+133
expression This helps ensure we do not have to scan all objects at this level which could be very many (one per DNS zone entry). However, due to the O(n*m) behaviour in list_intersect() for older databases, we only do this in the GUID index mode, leaving the behaviour unchanged for existing callers that do not specify the GUID index mode. NOTE WELL: the behaviour of disallowDNFilter is enforced in the index code, so this fixes SCOPE_ONELEVEL to also honour disallowDNFilter, hence the additional tests. The change to select the SUBTREE index in the absense of the ONELEVEL index enforces this. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-09-22ldb: Ensure we do not run out of File descriptors in autobuildAndrew Bartlett1-0/+16
The python TestCase API will keep a reference to the test object until the end of the tests, long after we need the actual LDB or the fd. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-09-22ldb: Do not make an ldb file for API testsAndrew Bartlett1-23/+11
An ldb context is valid without a backing file for tests of ldb.Message and ldb.MessageElement Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-09-22ldb: Add test showing a search against the index is not possibleAndrew Bartlett1-0/+16
This is not actually a great test, as the filter would fail to match these anyway, but it at least checks the codepath is safe. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-09-22ldb: Add more tests covering in-transaction GUID index and unique index ↵Andrew Bartlett1-12/+176
behaviour Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-09-22ldb: Add tests for base DN of a different caseAndrew Bartlett1-0/+26
This ensures we cover the case where the DN does not match the DB exactly Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-09-22ldb_tdb: Add tests for add/modify with the GUID indexAndrew Bartlett1-0/+84
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-09-22ldb: Also test the new GUID index modeAndrew Bartlett1-0/+11
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>