summaryrefslogtreecommitdiff
path: root/python/samba/tests/smb.py
AgeCommit message (Collapse)AuthorFilesLines
2024-05-31python:smb tests: remove py2 compatibility codeDouglas Bagnall1-11/+7
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-11-30python: tests: update all super calls to python 3 style in testsRob van der Linde1-2/+2
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> [abartlet@samba.org Some python2 style super() calls remain due to being an actual, even if reasonable, behaviour change]
2023-10-13python:tests: Remove semicolonsJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-21python:tests: Save files with intended contentsJoseph Sutton1-1/+1
We presumably here meant to use the variable ‘contents’, not ‘test_contents’. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-02-07pytests: heed assertEquals deprecation warning en-masseDouglas Bagnall1-5/+5
TestCase.assertEquals() is an alias for TestCase.assertEqual() and has been deprecated since Python 2.7. When we run our tests with in python developer mode (`PYTHONDEVMODE=1 make test`) we get 580 DeprecationWarnings about this. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2019-01-09s3:libsmb: Revert SMB Py bindings name back to libsmb_samba_internalTim Beale1-1/+1
In order to make it clear that the APIs in these Python bindings are unstable and should not be used by external consumers, this patch changes the name of the Python bindings back to libsmb_samba_internal. To make the Python code that uses these bindings (i.e. samba-tool, etc) look a little cleaner, we can just change the module name as we import it, e.g. from samba.samba3 import libsmb_samba_internal as libsmb Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Jan 9 14:30:31 CET 2019 on sn-devel-144
2019-01-07s3:pylibsmb: Rename libsmb_samba_internal Py bindings to libsmbTim Beale1-4/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-01-07tests: Avoid hardcoding domain in testTim Beale1-6/+7
Currently the sysvol domain directory is hard-coded, so the tests can only ever run on the ad_dc. This patch makes things marginally better by using the REALM environmental variable instead. This allows us to run it against other testenvs (like the SMBv2-only restoredc). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-07tests: Completely replace s4 connection in smb testsTim Beale1-5/+1
This test now uses the s3 python bindings completely, so we can remove the s4 connection. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-07s3:pylibsmb: Add .deltree() API to SMB py bindingsTim Beale1-4/+5
This basically re-uses the underlying functionality of existing APIs in order to support a .deltree() API, i.e. - we use the .list() functionality (i.e. do_listing()) to traverse every item in the given directory. - we then use either .unlink() (i.e. unlink_file()) or .rmdir() (i.e. remove_dir()) to delete the individual item. - sub-directories are handled recursively, by repeating the process. Note that the .deltree() API is currently only really used for testing (and deleting GPO files). So the recursion is never going to be excessive. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-07s3:pylibsmb: Add .loadfile() API to SMB py bindingsTim Beale1-6/+6
Add a .loadfile API to read a file's contents. This provides a convenient way to read a file and is consistent with the existing source4 API, which is used by things like the GPO python code and the ntacls backup. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-01-07s3:pylibsmb: Add .savefile() API to SMB py bindingsTim Beale1-8/+8
This provides a simple API for writing a file's contents and makes the s3 API consistent with the s4 API. All the async APIs here support SMBv2 so we don't need to use the sync APIs at all. Note that we have the choice here of using either cli_write_send() or cli_push_send(). I chose the latter, because that's what smbclient uses. It also appears to handle writing a large file better (i.e. one that exceeds the max write size of the underlying connection). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-01-07s3:pylibsmb: Make s3 and s4 listings return the same dictTim Beale1-1/+1
Make the python dictionary generated by the s3 .list() use the same keys as the current source4 dict. The reason for using the source4 dict is that other python code depends on these keys (e.g. ntacls.py), whereas the source3 API is currently unused. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-01-07s3:pylibsmb: Don't return '.'/'..' in .list()Tim Beale1-3/+3
The source4 .list() API wasn't doing this. This makes source3 and source4 have *almost* equivalent functionality, so we can start usign the source3 API in the tests. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-07s3:pylibsmb: Add .chkpath() API to SMB py bindingsTim Beale1-8/+8
Note that this is checking the existence of *directories*, not *files*. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-07s3:pylibsmb: Add .mkdir(), .rmdir() APIS to SMB py bindingsTim Beale1-5/+5
I kept these separate from the chkpath API because it's a nice way to use the old s4 API in the tests to verify the new s3 API works correctly. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-07s3:pylibsmb: Add .unlink() API to SMB Py bindingsTim Beale1-1/+10
Add a basic .unlink() API to the source3 bindings. This is based on the source4 python bindings, but uses the source3 client library APIs. (We use a helper function to do most of the work, because we will need to reuse it in order to support the deltree API). Update the source4 test to use the source3 API. We will gradually convert it over, and then delete the source4 python bindings. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-12tests: Add SMB Py binding .deltree test caseTim Beale1-2/+60
Add a more thorough test case that .deltree works as expected. Note that we get a slightly different NT_STATUS error in file_exists() if the parent directory doesn't exist, e.g. /non-existent-dir/nonexistent.txt BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Dec 12 08:23:07 CET 2018 on sn-devel-144
2018-12-12tests: Extend SMB test_save_load_text case to check overwriteTim Beale1-0/+7
Extend the test case to check overwriting a file as well. Currently this has the behaviour of appending to the existing file, rather than overwriting the file with new contents. It's not clear from the API that this is the intended behaviour in this case, so I've marked it as a failure. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-12tests: Extend SMB Py binding .list() test-caseTim Beale1-0/+22
Extend the tests to better reflect some of the .list() functionality we expect. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-12tests: Fix SMB Py binding .unlink() test case assertionTim Beale1-1/+20
The current assertion would never detect if the unlink API is broken. The chkpath() API is only useful for checking if directories exist, so it will always return False for a regular file (regardless of whether the file actually exists or not). Rework the test case so we assert that the file exists by trying to read its contents (which will throw an error if the file doesn't exist). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-12tests: Add SMB Py binding .chkpath() test caseTim Beale1-0/+24
chkpath was only tested incidentally (and that assertion was wrong). Add a proper test to prove it works correctly. We can then clean-up the incorrect assertion in the next patch. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E703: statement ends with a semicolonJoe 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 E401: multiple imports on one lineJoe Guo1-1/+4
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/+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 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-4/+4
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 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-06-28pysmb: add py_smb_unlink and testJoe Guo1-0/+8
Add unlink api to delete a file with a smb connection. Test added. 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-13python: create test for pysmb module.David Mulder1-0/+89
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>