summaryrefslogtreecommitdiff
path: root/lib/ldb/tests/python/api.py
AgeCommit message (Collapse)AuthorFilesLines
2018-08-24PEP8: fix E128: continuation line under-indented for visual indentJoe Guo1-9/+9
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-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_mdb/tests: Run api and index test also on lmdbGary Lockyer1-1/+96
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-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 Lockyer1-58/+87
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-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>
2017-09-22ldb: Add an unused objectGUID to each record in SearchTestsAndrew Bartlett1-25/+56
This will then be used by the GUID index tests. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-08-30ldb: Add tests for indexed and unindexed search expressionsAndrew Bartlett1-0/+299
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Aug 30 14:58:32 CEST 2017 on sn-devel-144
2017-08-30ldb: Fix tests to call the parent tearDown(), not setUp in tearDownAndrew Bartlett1-2/+2
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-07-02ldb:tests: Extend api.py testsuite to show transaction_commit() blocks ↵Andrew Bartlett1-10/+8
against the whole-db read lock The new ldb whole-db lock behaviour now allows this test Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-07-02ldb:tests: Extend api.py testsuite to show transaction contents can not be ↵Andrew Bartlett1-0/+66
seen outside the transaction Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-05-06ldb: Do not use mktemp() nor leak files into /tmp during api.py testAndrew Bartlett1-69/+96
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-05-06ldb: Add some tests to clarify the current iterator behaviourAndrew Bartlett1-6/+109
search_iterator() is no more memory efficient than search() because all the results come back at the first res.next() call Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-02-17pyldb: eliminate warnings from python api testMichael Adam1-4/+4
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-02-17pyldb: add api tests for search_iterator()Stefan Metzmacher1-0/+100
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-12-04ldb: Fix bug triggered by having an empty message in database during search.Adrian Cochrane1-4/+25
Previously if the message had 0 elements, Talloc would reallocate the projected array to NULL, fooling LDB into thinking that it failed to reallocate. This fix corrects LDB to be able to handle the case where the message has no attributes in common with the filter. Also the realloc call resized the array to the number of elements in the message, not the number of elements in common with the filter -- it essentially did nothing. Unlike talloc_realloc, talloc_array always returns a non-null pointer. This would help protect against possible errors. Signed-off-by: Adrian Cochrane <adrianc@catalyst.net.nz> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-11-05pyldb: Improve test coveragePetr Viktorin1-0/+82
Add tests for: - ldb.Dn.{get,set}_{extended_,}component_{name,value} - ldb.Dn.{get,set}_rdn_{name,value} - ldb.Dn.get_casefold - ldb.Dn.get_linearized - ldb.Dn.canonical_str Add negative test for Dn.__contains__ Add a helper function to register a dummy DN extension for testing. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-11-05pyldb: Prevent segfault when first module is NULLPetr Viktorin1-0/+9
Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-11-05pyldb: Adapt tests to Python 3Petr Viktorin1-75/+330
Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-11-05pyldb: Modernize test suitePetr Viktorin1-116/+116
This gets rid of deprecation warnings for the old method names. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-11-05pyldb: Add Python 3 compatibility (except strings)Petr Viktorin1-7/+10
- Use a macro for adding constants to module (This also ensures that the Python constants have the same name as the C ones. One existing misspelling is retained.) - Use new module initialization for Python 3 - Use rich comparison for ldb objects - Prepare tests for Python 3 Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-10-26ldb: Fix python bindings to accept a string as a DNldb-1.1.22Andrew Bartlett1-0/+29
This fixes add_base(), add_child() and is_child_of(). This removes a toally incorrect cast of struct ldb_dn to struct ldb_context. A helper routine is used instead Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-03-04pyldb: Add tests for type errorsPetr Viktorin1-0/+42
Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Mar 4 01:49:02 CET 2015 on sn-devel-104
2014-11-25lib-ldb-test: Test copying message element from a message to a new messageKamen Mazdrashki1-0/+14
Change-Id: Iefcafb418a170ee410aec900bb36eb8e01e946b1 Signed-off-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2012-07-06pyldb: Add bindings for ldb_dn_remove_base_componentsAndrew Bartlett1-0/+5
2012-07-06pyldb: Fix dn concat operation to be the other way aroundAndrew Bartlett1-1/+1
This now concatonates Dn(ldb, "cn=config") + Dn(ldb, "dc=samba,dc=org") as "cn=config,dc=samba,dc=org" Andrew Bartlett
2012-06-12ldb:tests: fix use of a non-existent word (existant)Michael Adam1-1/+1
2011-11-10ldb: Re-apply pyldb fixes from Tridge and Amity, using unittest ratherJelmer Vernooij1-33/+37
than samba.tests.
2011-11-10Revert "pyldb: fixed ldb API test"Jelmer Vernooij1-36/+39
This reverts commit 333248f08c83cc5b18f8e7e84cb19d79a8309d6e. This commit made the pyldb tests depend on the Samba testsuite.
2011-11-10pyldb: fixed ldb API testAndrew Tridgell1-39/+36
it was failing previously, but the failure wasn't being noticed
2011-07-29pyldb: added binary_encode() and binary_decode() methodsAndrew Tridgell1-0/+4
this gives access to RFC2254 encoding from python Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>
2011-07-21pyldb: use dn.is_child_of() instead of dn.compare_base()Andrew Tridgell1-5/+6
the compare_base() C API doesn't really fit well in python, as it returns 0 for true. Better to have a boolean function for the python interface. Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2011-07-21pyldb: add unit test for ldbDn.compare_baseMatthieu Patou1-0/+11
2011-07-05ldb: make ldb a top level library for Samba 4.0Andrew Bartlett1-0/+748
Signed-off-by: Andrew Tridgell <tridge@samba.org>